From 2f1a7536c4b392249ceeb2e25fc06e5dd3f4c149 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 1 Jun 2023 00:26:37 -0700 Subject: [PATCH 001/291] Fixed documentation typo. --- holodeck/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/utils.py b/holodeck/utils.py index 26e72e2f..cd6ac563 100644 --- a/holodeck/utils.py +++ b/holodeck/utils.py @@ -1020,7 +1020,7 @@ def trapz(yy: npt.ArrayLike, xx: npt.ArrayLike, axis: int = -1, cumsum: bool = T Input to be integrated. xx : ArrayLike of scalar, The sample points corresponding to the `yy` values. - This must be either be shaped as + This must either be shaped as * the same number of dimensions as `yy`, with the same length along the `axis` dimension, or * 1D with length matching `yy[axis]` axis : int, From 01bc304d5fef2417db63c7d0b8e6a4cdd041e907 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 1 Jun 2023 00:27:13 -0700 Subject: [PATCH 002/291] messing with trapz integration options in sat_polito_anisotropy.ipynb --- .../anisotropy/anisotropy_paper_plots.ipynb | 2 +- .../anisotropy/sato_polito_anisotropy.ipynb | 253 ++++++++++++++++-- 2 files changed, 237 insertions(+), 18 deletions(-) diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb index 10cb1ef8..75773e38 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb +++ b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb @@ -307,7 +307,7 @@ "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", "\n", - "ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", "ax.set_xlim(fobs[0]*YR-.005, 1)\n", "\n", "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index 625e48e3..66915ad5 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -116,7 +116,8 @@ "$$ \\frac{C_{\\ell>0} (f)}{C_0 (f)} = \\sum_\\mathrm{pixels} \\frac{ h_c^4 (f )}{ A_\\mathrm{pix} h_c^4 (f) \n", "+ h_c^4 (f )}\n", "$$ \n", - "\n" + "\n", + "There should be an A_pixel in the denom of every integral.\n" ] }, { @@ -606,19 +607,66 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# GPF" + "# From Dnum/dens\n", + "\n", + "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", + "= number density of binaries, per unit redshift, mass-ratio, and log10 of mass\n", + "\n", + "* dnum = d^4N / dlog10M dq dz dlnf\n", + "\n", + "* number = dN /dlnf" ] }, { - "attachments": {}, - "cell_type": "markdown", + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(diff_num.shape)\n", + "print(hs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ - "$$ P(M,q,z) = f_0' \\bigg( \\frac{M}{M_0}\\bigg)^{\\alpha_f}(1+z)^{\\beta_f} $$\n", + "def _integrate_grid_differential_number(edges, dnum, freq=False):\n", + " \"\"\"Integrate the differential number-density of binaries over the given grid (edges).\n", + "\n", + " NOTE: the `edges` provided MUST all be in linear space, mass is converted to ``log10(M)``\n", + " and frequency is converted to ``ln(f)``.\n", + " NOTE: the density `dnum` MUST correspond to `dn/ [dlog10(M) dq dz dln(f)]`\n", + "\n", + " Parameters\n", + " ----------\n", + " edges : (4,) iterable of ArrayLike\n", + " dnum : ndarray\n", + " freq : bool\n", + " Whether or not to also integrate the frequency dimension.\n", "\n", - "$$ P(M,q,z) = 0.03 \\bigg( \\frac{M}{1\\times10^{11} M_\\odot} \\bigg)^{0} (1+z)^{0.8} $$\n", + " Returns\n", + " -------\n", + " number : ndarray\n", + " Number of binaries in each bin of mass, mass-ratio, redshift, frequency.\n", + " NOTE: if `freq=False`, then `number` corresponds to `dN/dln(f)`, the number of binaries\n", + " per log-interval of frequency.\n", "\n", - "$$ P(M,q,z) = 0.03 (1+z)^{0.8} $$" + " \"\"\"\n", + " # ---- integrate from differential-number to number per bin\n", + " # integrate over dlog10(M)\n", + " number = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " # integrate over mass-ratio\n", + " number = utils.trapz(number, edges[1], axis=1, cumsum=False)\n", + " # integrate over redshift\n", + " number = trapz(number, edges[2], axis=2, cumsum=False)\n", + " # integrate over frequency (if desired)\n", + " if freq:\n", + " number = trapz(number, np.log(edges[3]), axis=3, cumsum=False)\n", + "\n", + " return number" ] }, { @@ -627,11 +675,22 @@ "metadata": {}, "outputs": [], "source": [ - "print('f_0=', sam._gpf._frac_norm)\n", - "print('m_alpha=', sam._gpf._malpha)\n", - "print('z_beta=', sam._gpf._zbeta)\n", - "print('q_gamma=', sam._gpf._qgamma)\n", - "print('m_ref (M_sun) = %e' % (sam._gpf._mref/MSOL))\n" + "dens = sam._density\n", + "print(dens.shape)\n", + "print(diff_num.shape)\n", + "print(hs.shape)\n", + "print(edges[-1].shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "$$ C_\\ell (f) = \\delta_{\\ell 0}\\delta_{m0} \\bigg( \\frac{f}{4\\pi \\Delta f} \\int d \\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^2 (f,\\vec{\\theta}) \\bigg)^2 \n", + "+ \\big( \\frac{f}{4 \\pi \\Delta f}\\big)^2 \\int d\\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^4 (f, \\vec{\\theta})\n", + "$$\n" ] }, { @@ -640,7 +699,88 @@ "metadata": {}, "outputs": [], "source": [ - "print(np.min(sam.redz), np.max(sam.redz))" + "\n", + "def trapz_weighted(yy, xx, yy_weight=1, axis=-1):\n", + " \"\"\" \n", + " yy_weight should have 1 less element along integration axis than yy,\n", + " 1 yy_weight for each trapezoid.\n", + " \"\"\"\n", + "\n", + " print('xx', xx.shape, 'yy', yy.shape, 'yy_weight', yy_weight.shape)\n", + " xx = np.asarray(xx)\n", + " if np.ndim(xx) == 1:\n", + " pass\n", + " elif np.ndim(xx) == np.ndim(yy):\n", + " xx = xx[axis]\n", + " else:\n", + " err = f\"Bad shape for `xx` (xx.shape={np.shape(xx)}, yy.shape={np.shape(yy)})!\"\n", + " raise ValueError(err)\n", + " ct = np.moveaxis(yy, axis, 0) # type: ignore\n", + " wt = np.moveaxis(yy_weight, axis, 0)\n", + " print('ct', ct.shape, 'weight', wt.shape)\n", + "\n", + " ct = 0.5 * (ct[1:] + ct[:-1])\n", + " ct = np.moveaxis(ct, 0, -1)\n", + " wt = np.moveaxis(wt, 0, -1)\n", + " print('ct', ct.shape, 'np.diff(xx)', np.diff(xx).shape, 'wt', wt.shape)\n", + " \n", + " ct = ct * np.diff(xx) * wt\n", + " ct = np.moveaxis(ct, -1, axis)\n", + " return ct\n", + "\n", + "\n", + "\n", + "def Cl_analytic_from_dnum(fobs_orb_edges, dnum, hs, realize = False):\n", + " \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", + " Parameters\n", + " ----------\n", + " fobs_orb_edges : (F,) 1Darray\n", + " Observed orbital frequency bin edges\n", + " dnum : (M,Q,Z,F) NDarray\n", + " dN / [ dlog10M dq dz dlnf ]\n", + " hs : (M,Q,Z,F) NDarray\n", + " Strain amplitude of each M,q,z bin\n", + " \n", + " \"\"\"\n", + "\n", + "\n", + " # ---- integrate from differential-number to number per bin\n", + " # integrate over dlog10(M)\n", + " num = utils.trapz(dnum, np.log10(edges[0]), yy_weight = hs**2, axis=0)\n", + " # integrate over mass-ratio\n", + " num = utils.trapz(num, edges[1], axis=1)\n", + " # integrate over redshift\n", + " num = utils.trapz(num, edges[2], axis=2)\n", + "\n", + "\n", + "\n", + " numh4 = utils.trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**4, axis=0)\n", + " # integrate over mass-ratio\n", + " numh4 = trapz_weighted(numh4, edges[1], axis=1)\n", + " # integrate over redshift\n", + " numh4 = trapz_weighted(numh4, edges[2], axis=2)\n", + "\n", + " print(numh2.shape, numh4.shape)\n", + "\n", + " df = np.diff(fobs_orb_edges) #: frequency bin widths\n", + " fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", + " # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", + "\n", + " delta_term = (\n", + " fc / (4*np.pi * df) * np.sum(number*hs**2, axis=(0,1,2))\n", + " )**2\n", + "\n", + " Cl = (\n", + " (fc / (4*np.pi*df))**2 * np.sum(number*hs**4, axis=(0,1,2))\n", + " )\n", + "\n", + " C0 = Cl + delta_term\n", + "\n", + " return C0, Cl\n", + "\n", + "C0, Cl = Cl_analytic_from_dnum(fobs_orb_edges, diff_num, hs)" ] }, { @@ -649,8 +789,88 @@ "metadata": {}, "outputs": [], "source": [ - "def P_of_z(z):\n", - " return (0.03*(1+z)*0.8)" + "\n", + "def trapz_weighted(yy, xx, yy_weight=1, axis=-1):\n", + " \"\"\" \n", + " yy_weight should have 1 less element along integration axis than yy,\n", + " 1 yy_weight for each trapezoid.\n", + " \"\"\"\n", + "\n", + " print('xx', xx.shape, 'yy', yy.shape, 'yy_weight', yy_weight.shape)\n", + " xx = np.asarray(xx)\n", + " if np.ndim(xx) == 1:\n", + " pass\n", + " elif np.ndim(xx) == np.ndim(yy):\n", + " xx = xx[axis]\n", + " else:\n", + " err = f\"Bad shape for `xx` (xx.shape={np.shape(xx)}, yy.shape={np.shape(yy)})!\"\n", + " raise ValueError(err)\n", + " ct = np.moveaxis(yy, axis, 0) # type: ignore\n", + " wt = np.moveaxis(yy_weight, axis, 0)\n", + " print('ct', ct.shape, 'weight', wt.shape)\n", + "\n", + " ct = 0.5 * (ct[1:] + ct[:-1])\n", + " ct = np.moveaxis(ct, 0, -1)\n", + " wt = np.moveaxis(wt, 0, -1)\n", + " print('ct', ct.shape, 'np.diff(xx)', np.diff(xx).shape, 'wt', wt.shape)\n", + " \n", + " ct = ct * np.diff(xx) * wt\n", + " ct = np.moveaxis(ct, -1, axis)\n", + " return ct\n", + "\n", + "\n", + "\n", + "\n", + "def Cl_analytic_from_dnum(fobs_orb_edges, dnum, hs, realize = False):\n", + " \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", + " Parameters\n", + " ----------\n", + " fobs_orb_edges : (F,) 1Darray\n", + " Observed orbital frequency bin edges\n", + " dnum : (M,Q,Z,F) NDarray\n", + " dN / [ dlog10M dq dz dlnf ]\n", + " hs : (M,Q,Z,F) NDarray\n", + " Strain amplitude of each M,q,z bin\n", + " \n", + " \"\"\"\n", + "\n", + "\n", + " # ---- integrate from differential-number to number per bin\n", + " # integrate over dlog10(M)\n", + " numh2 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**2, axis=0)\n", + " # integrate over mass-ratio\n", + " numh2 = trapz_weighted(numh2, edges[1], axis=1)\n", + " # integrate over redshift\n", + " numh2 = trapz_weighted(numh2, edges[2], axis=2)\n", + "\n", + "\n", + " numh4 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**4, axis=0)\n", + " # integrate over mass-ratio\n", + " numh4 = trapz_weighted(numh4, edges[1], axis=1)\n", + " # integrate over redshift\n", + " numh4 = trapz_weighted(numh4, edges[2], axis=2)\n", + "\n", + " print(numh2.shape, numh4.shape)\n", + "\n", + " df = np.diff(fobs_orb_edges) #: frequency bin widths\n", + " fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", + " # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", + "\n", + " delta_term = (\n", + " fc / (4*np.pi * df) * np.sum(number*hs**2, axis=(0,1,2))\n", + " )**2\n", + "\n", + " Cl = (\n", + " (fc / (4*np.pi*df))**2 * np.sum(number*hs**4, axis=(0,1,2))\n", + " )\n", + "\n", + " C0 = Cl + delta_term\n", + "\n", + " return C0, Cl\n", + "\n", + "C0, Cl = Cl_analytic_from_dnum(fobs_orb_edges, diff_num, hs)" ] }, { @@ -659,8 +879,7 @@ "metadata": {}, "outputs": [], "source": [ - "P_of_z(0.001)\n", - "P_of_z(10)" + "print(hs.shape)" ] }, { From 142925efbc77349b142cee2c070ba3c52bdb7d7f Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 1 Jun 2023 01:13:36 -0700 Subject: [PATCH 003/291] Better version of analytic Sato-Polito ccalculation working using dnum with hs at bin edges. --- .../anisotropy/sato_polito_anisotropy.ipynb | 295 +++++++++--------- 1 file changed, 149 insertions(+), 146 deletions(-) diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index 66915ad5..e85d11ab 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -489,13 +489,16 @@ "\n", "\n", "\n", - "def draw_analytic(ax, Cl, C0, fobs_gw_cents):\n", + "def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic'):\n", " xx = fobs_gw_cents\n", " yy = Cl/C0 # (F,)\n", - " ax.plot(xx, yy, color='tab:orange', lw=2, label='Eq (17) with cython number, full sam')\n", + " ax.plot(xx, yy, color=color, lw=2, label=label)\n", + "\n", + "def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization'):\n", + " xx = fobs_gw_cents\n", " rr = 0\n", " ax.plot(xx, Cl_many[:,rr]/C0_many[:,rr], color='tab:orange', alpha=0.15, linestyle='-', \n", - " label = 'Poisson number/bin realization')\n", + " label = label)\n", " for rr in range(1, nshow):\n", " ax.plot(xx, Cl_many[:,rr]/C0_many[:,rr], color='tab:orange', alpha=0.25, linestyle='-')\n", "\n", @@ -521,6 +524,7 @@ "def plot_ClC0():\n", " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", " draw_analytic(ax, Cl, C0, fobs_gw_cents)\n", + " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", " draw_spk(ax)\n", " draw_bayes(ax, lmax=6)\n", " # ax.set_ylim(10**-6, 10**0)\n", @@ -537,7 +541,7 @@ "metadata": {}, "outputs": [], "source": [ - "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", + "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", "\n", "# load ss info\n", "shape = sph_harm_file['ss_shape']\n", @@ -589,6 +593,7 @@ "def plot_ClC0():\n", " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", " draw_analytic(ax, Cl, C0, fobs_gw_cents)\n", + " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", " draw_spk(ax)\n", " draw_bayes(ax, lmax=6)\n", " draw_ClC0_medians(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", @@ -627,48 +632,6 @@ "print(hs.shape)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def _integrate_grid_differential_number(edges, dnum, freq=False):\n", - " \"\"\"Integrate the differential number-density of binaries over the given grid (edges).\n", - "\n", - " NOTE: the `edges` provided MUST all be in linear space, mass is converted to ``log10(M)``\n", - " and frequency is converted to ``ln(f)``.\n", - " NOTE: the density `dnum` MUST correspond to `dn/ [dlog10(M) dq dz dln(f)]`\n", - "\n", - " Parameters\n", - " ----------\n", - " edges : (4,) iterable of ArrayLike\n", - " dnum : ndarray\n", - " freq : bool\n", - " Whether or not to also integrate the frequency dimension.\n", - "\n", - " Returns\n", - " -------\n", - " number : ndarray\n", - " Number of binaries in each bin of mass, mass-ratio, redshift, frequency.\n", - " NOTE: if `freq=False`, then `number` corresponds to `dN/dln(f)`, the number of binaries\n", - " per log-interval of frequency.\n", - "\n", - " \"\"\"\n", - " # ---- integrate from differential-number to number per bin\n", - " # integrate over dlog10(M)\n", - " number = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", - " # integrate over mass-ratio\n", - " number = utils.trapz(number, edges[1], axis=1, cumsum=False)\n", - " # integrate over redshift\n", - " number = trapz(number, edges[2], axis=2, cumsum=False)\n", - " # integrate over frequency (if desired)\n", - " if freq:\n", - " number = trapz(number, np.log(edges[3]), axis=3, cumsum=False)\n", - "\n", - " return number" - ] - }, { "cell_type": "code", "execution_count": null, @@ -693,48 +656,48 @@ "$$\n" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Cl_analytic_from_dnum" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ + "def strain_amp_at_bin_edges(edges):\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", "\n", - "def trapz_weighted(yy, xx, yy_weight=1, axis=-1):\n", - " \"\"\" \n", - " yy_weight should have 1 less element along integration axis than yy,\n", - " 1 yy_weight for each trapezoid.\n", - " \"\"\"\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", "\n", - " print('xx', xx.shape, 'yy', yy.shape, 'yy_weight', yy_weight.shape)\n", - " xx = np.asarray(xx)\n", - " if np.ndim(xx) == 1:\n", - " pass\n", - " elif np.ndim(xx) == np.ndim(yy):\n", - " xx = xx[axis]\n", - " else:\n", - " err = f\"Bad shape for `xx` (xx.shape={np.shape(xx)}, yy.shape={np.shape(yy)})!\"\n", - " raise ValueError(err)\n", - " ct = np.moveaxis(yy, axis, 0) # type: ignore\n", - " wt = np.moveaxis(yy_weight, axis, 0)\n", - " print('ct', ct.shape, 'weight', wt.shape)\n", - "\n", - " ct = 0.5 * (ct[1:] + ct[:-1])\n", - " ct = np.moveaxis(ct, 0, -1)\n", - " wt = np.moveaxis(wt, 0, -1)\n", - " print('ct', ct.shape, 'np.diff(xx)', np.diff(xx).shape, 'wt', wt.shape)\n", - " \n", - " ct = ct * np.diff(xx) * wt\n", - " ct = np.moveaxis(ct, -1, axis)\n", - " return ct\n", + " # ---- calculate GW strain ----\n", + " mt = (edges[0])\n", + " mr = (edges[1])\n", + " rz = (edges[2])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(rz).cgs.value[np.newaxis,np.newaxis,:,np.newaxis]\n", + "\n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], rz[np.newaxis,np.newaxis,:,np.newaxis])\n", "\n", + " hs_edges = utils.gw_strain_source(mc, dc, fr)\n", + " return hs_edges\n", "\n", "\n", - "def Cl_analytic_from_dnum(fobs_orb_edges, dnum, hs, realize = False):\n", + "def Cl_analytic_from_dnum(edges, dnum):\n", " \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", " Parameters\n", " ----------\n", - " fobs_orb_edges : (F,) 1Darray\n", + " edges : (F,) 1Darray\n", " Observed orbital frequency bin edges\n", " dnum : (M,Q,Z,F) NDarray\n", " dN / [ dlog10M dq dz dlnf ]\n", @@ -743,22 +706,29 @@ " \n", " \"\"\"\n", "\n", + " hs_edges = strain_amp_at_bin_edges(edges)\n", + " fobs_orb_edges = edges[-1]\n", + " fobs_gw_edges = fobs_orb_edges * 2.0\n", "\n", " # ---- integrate from differential-number to number per bin\n", " # integrate over dlog10(M)\n", - " num = utils.trapz(dnum, np.log10(edges[0]), yy_weight = hs**2, axis=0)\n", + " numh2 = utils.trapz(dnum*hs_edges**2, np.log10(edges[0]), axis=0)\n", " # integrate over mass-ratio\n", - " num = utils.trapz(num, edges[1], axis=1)\n", + " numh2 = utils.trapz(numh2, edges[1], axis=1)\n", " # integrate over redshift\n", - " num = utils.trapz(num, edges[2], axis=2)\n", - "\n", + " numh2 = utils.trapz(numh2, edges[2], axis=2)\n", "\n", + " numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", "\n", - " numh4 = utils.trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**4, axis=0)\n", + " # integrate over dlog10(M)\n", + " numh4 = utils.trapz(dnum*hs_edges**4, np.log10(edges[0]), axis=0)\n", " # integrate over mass-ratio\n", - " numh4 = trapz_weighted(numh4, edges[1], axis=1)\n", + " numh4 = utils.trapz(numh4, edges[1], axis=1)\n", " # integrate over redshift\n", - " numh4 = trapz_weighted(numh4, edges[2], axis=2)\n", + " numh4 = utils.trapz(numh4, edges[2], axis=2)\n", + "\n", + " numh4 = numh4 * np.diff(np.log(fobs_gw_edges)) \n", + "\n", "\n", " print(numh2.shape, numh4.shape)\n", "\n", @@ -769,18 +739,27 @@ " # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", "\n", " delta_term = (\n", - " fc / (4*np.pi * df) * np.sum(number*hs**2, axis=(0,1,2))\n", + " fc / (4*np.pi * df) * np.sum(numh2, axis=(0,1,2))\n", " )**2\n", "\n", " Cl = (\n", - " (fc / (4*np.pi*df))**2 * np.sum(number*hs**4, axis=(0,1,2))\n", + " (fc / (4*np.pi*df))**2 * np.sum(numh4, axis=(0,1,2))\n", " )\n", "\n", " C0 = Cl + delta_term\n", "\n", " return C0, Cl\n", "\n", - "C0, Cl = Cl_analytic_from_dnum(fobs_orb_edges, diff_num, hs)" + "C0_dnum, Cl_dnum = Cl_analytic_from_dnum(edges, diff_num)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(C0_dnum.shape)" ] }, { @@ -789,88 +768,112 @@ "metadata": {}, "outputs": [], "source": [ + "def plot_ClC0():\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", + " draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num')\n", + " draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum', color='deeppink')\n", + " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", + " draw_spk(ax)\n", + " draw_bayes(ax, lmax=6)\n", + " draw_ClC0_medians(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", + " # ax.set_ylim(10**-6, 10**0)\n", + " plot._twin_yr(ax, nano=False)\n", + " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", "\n", - "def trapz_weighted(yy, xx, yy_weight=1, axis=-1):\n", - " \"\"\" \n", - " yy_weight should have 1 less element along integration axis than yy,\n", - " 1 yy_weight for each trapezoid.\n", - " \"\"\"\n", + " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)\n", + " return fig\n", "\n", - " print('xx', xx.shape, 'yy', yy.shape, 'yy_weight', yy_weight.shape)\n", - " xx = np.asarray(xx)\n", - " if np.ndim(xx) == 1:\n", - " pass\n", - " elif np.ndim(xx) == np.ndim(yy):\n", - " xx = xx[axis]\n", - " else:\n", - " err = f\"Bad shape for `xx` (xx.shape={np.shape(xx)}, yy.shape={np.shape(yy)})!\"\n", - " raise ValueError(err)\n", - " ct = np.moveaxis(yy, axis, 0) # type: ignore\n", - " wt = np.moveaxis(yy_weight, axis, 0)\n", - " print('ct', ct.shape, 'weight', wt.shape)\n", - "\n", - " ct = 0.5 * (ct[1:] + ct[:-1])\n", - " ct = np.moveaxis(ct, 0, -1)\n", - " wt = np.moveaxis(wt, 0, -1)\n", - " print('ct', ct.shape, 'np.diff(xx)', np.diff(xx).shape, 'wt', wt.shape)\n", + "fig = plot_ClC0() " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def trapz_weighted(yy, xx, yy_weight=1, axis=-1):\n", + "# \"\"\" \n", + "# yy_weight should have 1 less element along integration axis than yy,\n", + "# 1 yy_weight for each trapezoid.\n", + "# \"\"\"\n", + "\n", + "# print('xx', xx.shape, 'yy', yy.shape, 'yy_weight', yy_weight.shape)\n", + "# xx = np.asarray(xx)\n", + "# if np.ndim(xx) == 1:\n", + "# pass\n", + "# elif np.ndim(xx) == np.ndim(yy):\n", + "# xx = xx[axis]\n", + "# else:\n", + "# err = f\"Bad shape for `xx` (xx.shape={np.shape(xx)}, yy.shape={np.shape(yy)})!\"\n", + "# raise ValueError(err)\n", + "# ct = np.moveaxis(yy, axis, 0) # type: ignore\n", + "# wt = np.moveaxis(yy_weight, axis, 0)\n", + "# print('ct', ct.shape, 'weight', wt.shape)\n", + "\n", + "# ct = 0.5 * (ct[1:] + ct[:-1])\n", + "# ct = np.moveaxis(ct, 0, -1)\n", + "# wt = np.moveaxis(wt, 0, -1)\n", + "# print('ct', ct.shape, 'np.diff(xx)', np.diff(xx).shape, 'wt', wt.shape)\n", " \n", - " ct = ct * np.diff(xx) * wt\n", - " ct = np.moveaxis(ct, -1, axis)\n", - " return ct\n", + "# ct = ct * np.diff(xx) * wt\n", + "# ct = np.moveaxis(ct, -1, axis)\n", + "# return ct\n", "\n", "\n", "\n", "\n", - "def Cl_analytic_from_dnum(fobs_orb_edges, dnum, hs, realize = False):\n", - " \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", - " Parameters\n", - " ----------\n", - " fobs_orb_edges : (F,) 1Darray\n", - " Observed orbital frequency bin edges\n", - " dnum : (M,Q,Z,F) NDarray\n", - " dN / [ dlog10M dq dz dlnf ]\n", - " hs : (M,Q,Z,F) NDarray\n", - " Strain amplitude of each M,q,z bin\n", + "# def Cl_analytic_from_dnum(fobs_orb_edges, dnum, hs, realize = False):\n", + "# \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", + "# Parameters\n", + "# ----------\n", + "# fobs_orb_edges : (F,) 1Darray\n", + "# Observed orbital frequency bin edges\n", + "# dnum : (M,Q,Z,F) NDarray\n", + "# dN / [ dlog10M dq dz dlnf ]\n", + "# hs : (M,Q,Z,F) NDarray\n", + "# Strain amplitude of each M,q,z bin\n", " \n", - " \"\"\"\n", + "# \"\"\"\n", "\n", "\n", - " # ---- integrate from differential-number to number per bin\n", - " # integrate over dlog10(M)\n", - " numh2 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**2, axis=0)\n", - " # integrate over mass-ratio\n", - " numh2 = trapz_weighted(numh2, edges[1], axis=1)\n", - " # integrate over redshift\n", - " numh2 = trapz_weighted(numh2, edges[2], axis=2)\n", + "# # ---- integrate from differential-number to number per bin\n", + "# # integrate over dlog10(M)\n", + "# numh2 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**2, axis=0)\n", + "# # integrate over mass-ratio\n", + "# numh2 = trapz_weighted(numh2, edges[1], axis=1)\n", + "# # integrate over redshift\n", + "# numh2 = trapz_weighted(numh2, edges[2], axis=2)\n", + "# # numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", "\n", "\n", - " numh4 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**4, axis=0)\n", - " # integrate over mass-ratio\n", - " numh4 = trapz_weighted(numh4, edges[1], axis=1)\n", - " # integrate over redshift\n", - " numh4 = trapz_weighted(numh4, edges[2], axis=2)\n", + "# numh4 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**4, axis=0)\n", + "# # integrate over mass-ratio\n", + "# numh4 = trapz_weighted(numh4, edges[1], axis=1)\n", + "# # integrate over redshift\n", + "# numh4 = trapz_weighted(numh4, edges[2], axis=2)\n", "\n", - " print(numh2.shape, numh4.shape)\n", + "# print(numh2.shape, numh4.shape)\n", "\n", - " df = np.diff(fobs_orb_edges) #: frequency bin widths\n", - " fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", + "# df = np.diff(fobs_orb_edges) #: frequency bin widths\n", + "# fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", "\n", - " # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", - " # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", + "# # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", + "# # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", "\n", - " delta_term = (\n", - " fc / (4*np.pi * df) * np.sum(number*hs**2, axis=(0,1,2))\n", - " )**2\n", + "# delta_term = (\n", + "# fc / (4*np.pi * df) * np.sum(number*hs**2, axis=(0,1,2))\n", + "# )**2\n", "\n", - " Cl = (\n", - " (fc / (4*np.pi*df))**2 * np.sum(number*hs**4, axis=(0,1,2))\n", - " )\n", + "# Cl = (\n", + "# (fc / (4*np.pi*df))**2 * np.sum(number*hs**4, axis=(0,1,2))\n", + "# )\n", "\n", - " C0 = Cl + delta_term\n", + "# C0 = Cl + delta_term\n", "\n", - " return C0, Cl\n", + "# return C0, Cl\n", "\n", - "C0, Cl = Cl_analytic_from_dnum(fobs_orb_edges, diff_num, hs)" + "# C0, Cl = Cl_analytic_from_dnum(fobs_orb_edges, diff_num, hs)" ] }, { From 56c868025befe384ea9373f8640f9ee850f9f12b Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 1 Jun 2023 09:37:00 -0700 Subject: [PATCH 004/291] Added redz option to Cl_analytic_from_dnum, but it looks weird. --- .../anisotropy/sato_polito_anisotropy.ipynb | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index e85d11ab..70443ac8 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -492,7 +492,7 @@ "def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic'):\n", " xx = fobs_gw_cents\n", " yy = Cl/C0 # (F,)\n", - " ax.plot(xx, yy, color=color, lw=2, label=label)\n", + " ax.plot(xx, yy, color=color, lw=2, label=label, linestyle='dashdot')\n", "\n", "def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization'):\n", " xx = fobs_gw_cents\n", @@ -670,7 +670,7 @@ "metadata": {}, "outputs": [], "source": [ - "def strain_amp_at_bin_edges(edges):\n", + "def strain_amp_at_bin_edges(edges, redz=None):\n", " assert len(edges) == 4\n", " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", "\n", @@ -678,22 +678,29 @@ " df = np.diff(foo) #: frequency bin widths\n", " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", "\n", + "\n", + " if redz is not None:\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else: \n", + " redz = edges[2][np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", + "\n", " # ---- calculate GW strain ----\n", " mt = (edges[0])\n", " mr = (edges[1])\n", - " rz = (edges[2])\n", " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", " mc = mc[:, :, np.newaxis, np.newaxis]\n", - " dc = holo.cosmo.comoving_distance(rz).cgs.value[np.newaxis,np.newaxis,:,np.newaxis]\n", - "\n", + " \n", " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", - " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], rz[np.newaxis,np.newaxis,:,np.newaxis])\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", "\n", " hs_edges = utils.gw_strain_source(mc, dc, fr)\n", " return hs_edges\n", "\n", "\n", - "def Cl_analytic_from_dnum(edges, dnum):\n", + "def Cl_analytic_from_dnum(edges, dnum, redz=None):\n", " \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", " Parameters\n", " ----------\n", @@ -705,8 +712,7 @@ " Strain amplitude of each M,q,z bin\n", " \n", " \"\"\"\n", - "\n", - " hs_edges = strain_amp_at_bin_edges(edges)\n", + " hs_edges = strain_amp_at_bin_edges(edges, redz)\n", " fobs_orb_edges = edges[-1]\n", " fobs_gw_edges = fobs_orb_edges * 2.0\n", "\n", @@ -750,7 +756,8 @@ "\n", " return C0, Cl\n", "\n", - "C0_dnum, Cl_dnum = Cl_analytic_from_dnum(edges, diff_num)" + "C0_dnum, Cl_dnum = Cl_analytic_from_dnum(edges, diff_num)\n", + "C0_redz, Cl_redz = Cl_analytic_from_dnum(edges, diff_num, redz_final)" ] }, { @@ -772,6 +779,7 @@ " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", " draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num')\n", " draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum', color='deeppink')\n", + " draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs using final redshift', color='indigo')\n", " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", " draw_spk(ax)\n", " draw_bayes(ax, lmax=6)\n", @@ -786,6 +794,14 @@ "fig = plot_ClC0() " ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Same, but using final redz" + ] + }, { "cell_type": "code", "execution_count": null, From 772424f6450faaf44bdb537043f701f73b77bfca Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 1 Jun 2023 11:41:55 -0700 Subject: [PATCH 005/291] Anisotropy analytic plots for full SAM look way different. --- .../anisotropy/sato_polito_anisotropy.ipynb | 396 ++++++++++-------- 1 file changed, 226 insertions(+), 170 deletions(-) diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index 70443ac8..1f4d2766 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -283,7 +283,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Back to dN/bin" + "# Back to dN/bin\n", + "## Fresh Set Up" ] }, { @@ -479,6 +480,23 @@ "ax.legend()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_many.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot everything" + ] + }, { "cell_type": "code", "execution_count": null, @@ -489,23 +507,33 @@ "\n", "\n", "\n", - "def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic'):\n", + "def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic', lw=2):\n", " xx = fobs_gw_cents\n", " yy = Cl/C0 # (F,)\n", - " ax.plot(xx, yy, color=color, lw=2, label=label, linestyle='dashdot')\n", + " ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle='dashdot')\n", "\n", - "def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization'):\n", + "def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization',\n", + " show_ci=False, show_reals=True, show_median=False):\n", " xx = fobs_gw_cents\n", - " rr = 0\n", - " ax.plot(xx, Cl_many[:,rr]/C0_many[:,rr], color='tab:orange', alpha=0.15, linestyle='-', \n", - " label = label)\n", - " for rr in range(1, nshow):\n", - " ax.plot(xx, Cl_many[:,rr]/C0_many[:,rr], color='tab:orange', alpha=0.25, linestyle='-')\n", - "\n", - "def draw_spk(ax):\n", + " yy = Cl_many/C0_many # (F,R)\n", + " if show_median:\n", + " ax.plot(xx, np.median(yy[:,:], axis=-1), color=color) #, label='median of samples, $l=%d$' % ll) \n", + " if show_ci:\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:], percs, axis=-1), color=color, alpha=0.1)\n", + " if show_reals:\n", + " rr = 0\n", + " ax.plot(xx, yy[:,rr], color=color, alpha=0.15, linestyle='-', \n", + " label = label)\n", + " for rr in range(1, np.min([nshow, len(Cl_many[0])])):\n", + " ax.plot(xx, yy[:,rr], color=color, alpha=0.25, linestyle='-')\n", + "\n", + "def draw_spk(ax, label='SP & K Rough Estimate'):\n", " spk_xx= np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7]) /YR\n", " spk_yy= np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", - " ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='limegreen', ls='--')\n", + " ax.plot(spk_xx * YR, spk_yy, label=label, color='limegreen', ls='--')\n", "\n", "def draw_bayes(ax, lmax, colors = ['k', 'b', 'r', 'g', 'c', 'm']):\n", " xx_Nihan = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz\n", @@ -520,6 +548,28 @@ " ax.plot(xx_Nihan, Cl_nihan[:,ll]/Cl_nihan[:,0], \n", " label = '$l=%d$' % (ll+1), \n", " color=colors[ll], marker='o', ms=8)\n", + " \n", + "def draw_sim(ax, xx, Cl_best, lmax, nshow, show_ci=True, show_reals=True):\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " if show_ci:\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " if show_reals:\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1, label=label)\n", "\n", "def plot_ClC0():\n", " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", @@ -570,33 +620,13 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_ClC0_medians(ax, xx, Cl_best, lmax, nshow):\n", - "\n", - " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", - " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", - "\n", - " colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", - " for ll in range(lmax):\n", - " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", - " for pp in [50, 98]:\n", - " percs = pp/2\n", - " percs = [50-percs, 50+percs]\n", - " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", - " \n", - " for bb in range(0,nshow):\n", - " # if ll==0 and bb==0:\n", - " # label = \"individual best samples, median of realizations\"\n", - " # else: \n", - " label=None\n", - " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", - " linewidth=1, label=label)\n", "def plot_ClC0():\n", " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", " draw_analytic(ax, Cl, C0, fobs_gw_cents)\n", " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", " draw_spk(ax)\n", " draw_bayes(ax, lmax=6)\n", - " draw_ClC0_medians(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", + " draw_sim(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", @@ -622,29 +652,6 @@ "* number = dN /dlnf" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(diff_num.shape)\n", - "print(hs.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dens = sam._density\n", - "print(dens.shape)\n", - "print(diff_num.shape)\n", - "print(hs.shape)\n", - "print(edges[-1].shape)" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -699,8 +706,44 @@ " hs_edges = utils.gw_strain_source(mc, dc, fr)\n", " return hs_edges\n", "\n", + "def strain_amp_at_bin_centers_redz(edges, redz):\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # redshifts are defined across 4D grid, shape (M, Q, Z, Fc)\n", + " # where M, Q, Z are edges and Fc is frequency centers\n", + " # find midpoints of redshifts in M, Q, Z dimensions, to end up with (M-1, Q-1, Z-1, Fc)\n", + " if redz is not None:\n", + " for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else:\n", + " redz = kale.utils.midpoints(edges[2])[np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", "\n", - "def Cl_analytic_from_dnum(edges, dnum, redz=None):\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = kale.utils.midpoints(edges[0])\n", + " mr = kale.utils.midpoints(edges[1])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " \n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs = utils.gw_strain_source(mc, dc, fr)\n", + " return hs\n", + "\n", + "\n", + "def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False):\n", " \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", " Parameters\n", " ----------\n", @@ -712,34 +755,61 @@ " Strain amplitude of each M,q,z bin\n", " \n", " \"\"\"\n", - " hs_edges = strain_amp_at_bin_edges(edges, redz)\n", " fobs_orb_edges = edges[-1]\n", " fobs_gw_edges = fobs_orb_edges * 2.0\n", "\n", - " # ---- integrate from differential-number to number per bin\n", - " # integrate over dlog10(M)\n", - " numh2 = utils.trapz(dnum*hs_edges**2, np.log10(edges[0]), axis=0)\n", - " # integrate over mass-ratio\n", - " numh2 = utils.trapz(numh2, edges[1], axis=1)\n", - " # integrate over redshift\n", - " numh2 = utils.trapz(numh2, edges[2], axis=2)\n", + " df = np.diff(fobs_orb_edges) #: frequency bin widths\n", + " fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", "\n", - " numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", + " if realize is False:\n", + " hs_edges = strain_amp_at_bin_edges(edges, redz)\n", + "\n", + " # ---- integrate from differential-number to number per bin\n", + " # integrate over dlog10(M)\n", + " numh2 = utils.trapz(dnum*hs_edges**2, np.log10(edges[0]), axis=0)\n", + " # integrate over mass-ratio\n", + " numh2 = utils.trapz(numh2, edges[1], axis=1)\n", + " # integrate over redshift\n", + " numh2 = utils.trapz(numh2, edges[2], axis=2)\n", + " # times dln(f)\n", + " numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", + "\n", + " # integrate over dlog10(M)\n", + " numh4 = utils.trapz(dnum*hs_edges**4, np.log10(edges[0]), axis=0)\n", + " # integrate over mass-ratio\n", + " numh4 = utils.trapz(numh4, edges[1], axis=1)\n", + " # integrate over redshift\n", + " numh4 = utils.trapz(numh4, edges[2], axis=2)\n", + " # times dln(f)\n", + " print('numh4:', numh4.shape, 'np.diff(np.log(fobs_gw_edges))', np.diff(np.log(fobs_gw_edges)).shape)\n", + " numh4 = numh4 * np.diff(np.log(fobs_gw_edges)) # how is this not a shape issue??\n", + "\n", + " elif utils.isinteger(realize):\n", + " # add reals axis\n", + " hs_cents = strain_amp_at_bin_centers_redz(edges, redz)[...,np.newaxis]\n", + " print('hs_cents:', hs_cents.shape)\n", + " df = df[:,np.newaxis] \n", + " fc = fc[:,np.newaxis] \n", "\n", - " # integrate over dlog10(M)\n", - " numh4 = utils.trapz(dnum*hs_edges**4, np.log10(edges[0]), axis=0)\n", - " # integrate over mass-ratio\n", - " numh4 = utils.trapz(numh4, edges[1], axis=1)\n", - " # integrate over redshift\n", - " numh4 = utils.trapz(numh4, edges[2], axis=2)\n", + " \n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, dnum)\n", + " shape = number.shape + (realize,)\n", + " print('number:', number.shape)\n", + " number = holo.gravwaves.poisson_as_needed(number[...,np.newaxis] * np.ones(shape))\n", + " print('number:', number.shape)\n", "\n", - " numh4 = numh4 * np.diff(np.log(fobs_gw_edges)) \n", + " numh2 = number * hs_cents**2 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] \n", + " numh4 = number * hs_cents**4 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] \n", "\n", "\n", - " print(numh2.shape, numh4.shape)\n", "\n", - " df = np.diff(fobs_orb_edges) #: frequency bin widths\n", - " fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", + " else:\n", + " err = \"`realize` ({}) must be one of {{False, integer}}!\".format(realize)\n", + " raise ValueError(err)\n", + "\n", + " print('numh2:', numh2.shape, 'numh4:', numh4.shape)\n", + "\n", "\n", " # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", " # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", @@ -757,7 +827,9 @@ " return C0, Cl\n", "\n", "C0_dnum, Cl_dnum = Cl_analytic_from_dnum(edges, diff_num)\n", - "C0_redz, Cl_redz = Cl_analytic_from_dnum(edges, diff_num, redz_final)" + "C0_dnum_reals, Cl_dnum_reals = Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", + "C0_redz, Cl_redz = Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", + "C0_redz_reals, Cl_redz_reals = Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)" ] }, { @@ -766,7 +838,26 @@ "metadata": {}, "outputs": [], "source": [ - "print(C0_dnum.shape)" + "arr = np.array([1,2,3,4,])\n", + "print(arr[:,np.newaxis].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(C0_dnum.shape)\n", + "print(C0_dnum_reals.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "note that Cl_best does not use the same model as the mockups for Sato-Polito method here!" ] }, { @@ -778,12 +869,17 @@ "def plot_ClC0():\n", " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", " draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num')\n", - " draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum', color='deeppink')\n", - " draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs using final redshift', color='indigo')\n", - " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", - " draw_spk(ax)\n", + " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, label=None, color='tab:orange')\n", + " \n", + " draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum, hs from z_init', color='deeppink')\n", + " draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink')\n", + " \n", + " draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs from z_final', color='indigo')\n", + " draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo')\n", + " \n", + " draw_spk(ax, label='S-P & K')\n", " draw_bayes(ax, lmax=6)\n", - " draw_ClC0_medians(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", + " draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=True, show_reals=True, nshow=10)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", @@ -794,102 +890,40 @@ "fig = plot_ClC0() " ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Same, but using final redz" - ] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# def trapz_weighted(yy, xx, yy_weight=1, axis=-1):\n", - "# \"\"\" \n", - "# yy_weight should have 1 less element along integration axis than yy,\n", - "# 1 yy_weight for each trapezoid.\n", - "# \"\"\"\n", - "\n", - "# print('xx', xx.shape, 'yy', yy.shape, 'yy_weight', yy_weight.shape)\n", - "# xx = np.asarray(xx)\n", - "# if np.ndim(xx) == 1:\n", - "# pass\n", - "# elif np.ndim(xx) == np.ndim(yy):\n", - "# xx = xx[axis]\n", - "# else:\n", - "# err = f\"Bad shape for `xx` (xx.shape={np.shape(xx)}, yy.shape={np.shape(yy)})!\"\n", - "# raise ValueError(err)\n", - "# ct = np.moveaxis(yy, axis, 0) # type: ignore\n", - "# wt = np.moveaxis(yy_weight, axis, 0)\n", - "# print('ct', ct.shape, 'weight', wt.shape)\n", - "\n", - "# ct = 0.5 * (ct[1:] + ct[:-1])\n", - "# ct = np.moveaxis(ct, 0, -1)\n", - "# wt = np.moveaxis(wt, 0, -1)\n", - "# print('ct', ct.shape, 'np.diff(xx)', np.diff(xx).shape, 'wt', wt.shape)\n", + "def plot_ClC0():\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", + " draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num',\n", + " lw=4)\n", + " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, label=None, color='tab:orange',\n", + " show_ci=True, show_median=True)\n", " \n", - "# ct = ct * np.diff(xx) * wt\n", - "# ct = np.moveaxis(ct, -1, axis)\n", - "# return ct\n", - "\n", - "\n", - "\n", - "\n", - "# def Cl_analytic_from_dnum(fobs_orb_edges, dnum, hs, realize = False):\n", - "# \"\"\" Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski\n", - "# Parameters\n", - "# ----------\n", - "# fobs_orb_edges : (F,) 1Darray\n", - "# Observed orbital frequency bin edges\n", - "# dnum : (M,Q,Z,F) NDarray\n", - "# dN / [ dlog10M dq dz dlnf ]\n", - "# hs : (M,Q,Z,F) NDarray\n", - "# Strain amplitude of each M,q,z bin\n", + " draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum, hs from z_init', color='deeppink',\n", + " lw=4)\n", + " draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink',\n", + " show_ci=True, show_median=True)\n", " \n", - "# \"\"\"\n", - "\n", - "\n", - "# # ---- integrate from differential-number to number per bin\n", - "# # integrate over dlog10(M)\n", - "# numh2 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**2, axis=0)\n", - "# # integrate over mass-ratio\n", - "# numh2 = trapz_weighted(numh2, edges[1], axis=1)\n", - "# # integrate over redshift\n", - "# numh2 = trapz_weighted(numh2, edges[2], axis=2)\n", - "# # numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", - "\n", - "\n", - "# numh4 = trapz_weighted(dnum, np.log10(edges[0]), yy_weight = hs**4, axis=0)\n", - "# # integrate over mass-ratio\n", - "# numh4 = trapz_weighted(numh4, edges[1], axis=1)\n", - "# # integrate over redshift\n", - "# numh4 = trapz_weighted(numh4, edges[2], axis=2)\n", - "\n", - "# print(numh2.shape, numh4.shape)\n", - "\n", - "# df = np.diff(fobs_orb_edges) #: frequency bin widths\n", - "# fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!)\n", - "\n", - "# # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", - "# # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray\n", - "\n", - "# delta_term = (\n", - "# fc / (4*np.pi * df) * np.sum(number*hs**2, axis=(0,1,2))\n", - "# )**2\n", - "\n", - "# Cl = (\n", - "# (fc / (4*np.pi*df))**2 * np.sum(number*hs**4, axis=(0,1,2))\n", - "# )\n", - "\n", - "# C0 = Cl + delta_term\n", + " draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs from z_final', color='indigo',\n", + " lw=4)\n", + " draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo',\n", + " show_ci=True, show_median=True)\n", + " \n", + " draw_spk(ax, label='S-P & K')\n", + " draw_bayes(ax, lmax=6)\n", + " draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=False, show_reals=True, nshow=20)\n", + " # ax.set_ylim(10**-6, 10**0)\n", + " plot._twin_yr(ax, nano=False)\n", + " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", "\n", - "# return C0, Cl\n", + " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)\n", + " return fig\n", "\n", - "# C0, Cl = Cl_analytic_from_dnum(fobs_orb_edges, diff_num, hs)" + "fig = plot_ClC0() " ] }, { @@ -898,7 +932,29 @@ "metadata": {}, "outputs": [], "source": [ - "print(hs.shape)" + "def plot_ClC0():\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell>0}/C_0$')\n", + " draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num',\n", + " lw=4)\n", + " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, label=None, color='tab:orange',\n", + " show_ci=True, show_median=True)\n", + " \n", + " draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum, hs from z_init', color='deeppink',\n", + " lw=4)\n", + " draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink',\n", + " show_ci=True, show_median=True)\n", + " \n", + " draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs from z_final', color='indigo',\n", + " lw=4)\n", + " draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo',\n", + " show_ci=True, show_median=True)\n", + " plot._twin_yr(ax, nano=False)\n", + " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", + "\n", + " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=1)\n", + " return fig\n", + "\n", + "fig = plot_ClC0() " ] }, { From e940c9f2c18a7ff9cbd249469fe21b02c254a009 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 1 Jun 2023 23:26:15 -0700 Subject: [PATCH 006/291] Updated lib_anisotropy() to match new ranking functions, with median of difs not dif of meds. --- holodeck/anisotropy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index e5924a0f..1465af5f 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -165,7 +165,7 @@ def lib_anisotropy(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lm # ---- rank samples - nsort, fidx, hc_tt, hc_ref = detstats.rank_samples(hc_ss, hc_bg, fobs, fidx=1, hc_ref=hc_ref_10yr, ret_all=True) + nsort, fidx, hc_ref = detstats.rank_samples(hc_ss, hc_bg, fobs, fidx=1, hc_ref=hc_ref_10yr, ret_all=True) print('Ranked samples by hc_ref = %.2e at fobs = %.2f/yr' % (hc_ref, fobs[fidx]*YR)) From fcad34673da26c21af0acee6fb449aa77e641367 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 2 Jun 2023 16:11:01 -0700 Subject: [PATCH 007/291] Working on analytic anisotroy code. --- .../anisotropy/anisotropy_paper_plots.ipynb | 18 +- .../anisotropy/sato_polito_anisotropy.ipynb | 5 +- holodeck/anisotropy.py | 255 +++++++++++++++++- 3 files changed, 267 insertions(+), 11 deletions(-) diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb index 75773e38..eddcca8b 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb +++ b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb @@ -36,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "# sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "# sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", "\n", "# hdfname = sspath+'/sam_lib.hdf5'\n", "# ssfile = h5py.File(hdfname, 'r')\n", @@ -260,12 +260,13 @@ "outputs": [], "source": [ "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", - " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", "\n", " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", "\n", - " colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", " for ll in range(lmax):\n", " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", " for pp in [50, 98]:\n", @@ -278,7 +279,7 @@ " # label = \"individual best samples, median of realizations\"\n", " # else: \n", " label=None\n", - " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", " linewidth=1, label=label)\n", " \n", " # Add Nihan's data\n", @@ -300,8 +301,8 @@ "metadata": {}, "outputs": [], "source": [ - "fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", - "ax = fig1.axes[0]\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", "\n", "# Sato-Polito & Kamionkowski\n", "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", @@ -311,7 +312,10 @@ "ax.set_xlim(fobs[0]*YR-.005, 1)\n", "\n", "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", - "ax.legend(loc='lower right', ncols=2)" + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" ] }, { diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index 1f4d2766..b541b714 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -318,7 +318,8 @@ "source": [ "fobs_orb_cents = fobs_gw_cents/2.0\n", "fobs_orb_edges = fobs_gw_edges/2.0\n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "hard = holo.hardening.Hard_GW()\n", + "# hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", " fobs_orb_cents, sam, hard, holo.cosmo)\n", "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", @@ -706,7 +707,7 @@ " hs_edges = utils.gw_strain_source(mc, dc, fr)\n", " return hs_edges\n", "\n", - "def strain_amp_at_bin_centers_redz(edges, redz):\n", + "def strain_amp_at_bin_centers_redz(edges, redz=None):\n", " assert len(edges) == 4\n", " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", "\n", diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 1465af5f..16c598dc 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -11,7 +11,7 @@ import h5py import holodeck as holo -from holodeck import utils, cosmo, log, detstats +from holodeck import utils, cosmo, log, detstats, plot from holodeck.constants import YR NSIDE = 32 @@ -195,7 +195,7 @@ def lib_anisotropy(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lm output_name = output_dir+'/sph_harm_lmax%d_nside%d_nbest%d.npz' % (lmax, nside, nbest) print('Saving npz file: ', output_name) np.savez(output_name, - nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref=hc_ref, ss_shape=shape, + nsort=nsort, fidx=fidx, hc_ref=hc_ref, ss_shape=shape, moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs) @@ -263,5 +263,256 @@ def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False): return C0, Cl +def strain_amp_at_bin_edges(edges, redz=None): + """ Calculate strain amplitude at bin edges, with final or initial redz. + + """ + assert len(edges) == 4 + assert np.all([np.ndim(ee) == 1 for ee in edges]) + + foo = edges[-1] #: should be observer-frame orbital-frequencies + # df = np.diff(foo) #: frequency bin widths + fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!) + + + if redz is not None: + dc = +np.inf * np.ones_like(redz) + sel = (redz > 0.0) + dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value + else: + redz = edges[2][np.newaxis,np.newaxis,:,np.newaxis] + dc = holo.cosmo.comoving_distance(redz).cgs.value + + # ---- calculate GW strain ---- + mt = (edges[0]) + mr = (edges[1]) + mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :]) + mc = mc[:, :, np.newaxis, np.newaxis] + + # convert from observer-frame to rest-frame; still using frequency-bin centers + fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz) + + hs_edges = utils.gw_strain_source(mc, dc, fr) + return hs_edges + + +def strain_amp_at_bin_centers_redz(edges, redz=None): + """ Calculate strain amplitude at bin centers, with final or initial redz. + + """ + assert len(edges) == 4 + assert np.all([np.ndim(ee) == 1 for ee in edges]) + + foo = edges[-1] #: should be observer-frame orbital-frequencies + df = np.diff(foo) #: frequency bin widths + fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!) + + # redshifts are defined across 4D grid, shape (M, Q, Z, Fc) + # where M, Q, Z are edges and Fc is frequency centers + # find midpoints of redshifts in M, Q, Z dimensions, to end up with (M-1, Q-1, Z-1, Fc) + if redz is not None: + for dd in range(3): + redz = np.moveaxis(redz, dd, 0) + redz = kale.utils.midpoints(redz, axis=0) + redz = np.moveaxis(redz, 0, dd) + dc = +np.inf * np.ones_like(redz) + sel = (redz > 0.0) + dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value + else: + redz = kale.utils.midpoints(edges[2])[np.newaxis,np.newaxis,:,np.newaxis] + dc = holo.cosmo.comoving_distance(redz).cgs.value + + + # ---- calculate GW strain ---- + mt = kale.utils.midpoints(edges[0]) + mr = kale.utils.midpoints(edges[1]) + mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :]) + mc = mc[:, :, np.newaxis, np.newaxis] + + # convert from observer-frame to rest-frame; still using frequency-bin centers + fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz) + + hs = utils.gw_strain_source(mc, dc, fr) + return hs + + +def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): + """ Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski + Parameters + ---------- + edges : (F,) 1Darray + Observed orbital frequency bin edges + dnum : (M,Q,Z,F) NDarray + dN / [ dlog10M dq dz dlnf ] + hs : (M,Q,Z,F) NDarray + Strain amplitude of each M,q,z bin + + """ + fobs_orb_edges = edges[-1] + fobs_gw_edges = fobs_orb_edges * 2.0 + + df = np.diff(fobs_orb_edges) #: frequency bin widths + fc = kale.utils.midpoints(fobs_orb_edges) #: use frequency-bin centers for strain (more accurate!) + + + if realize is False: + hs_edges = strain_amp_at_bin_edges(edges, redz) + + # ---- integrate from differential-number to number per bin + # integrate over dlog10(M) + numh2 = utils.trapz(dnum*hs_edges**2, np.log10(edges[0]), axis=0) + # integrate over mass-ratio + numh2 = utils.trapz(numh2, edges[1], axis=1) + # integrate over redshift + numh2 = utils.trapz(numh2, edges[2], axis=2) + # times dln(f) + numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) + + # integrate over dlog10(M) + numh4 = utils.trapz(dnum*hs_edges**4, np.log10(edges[0]), axis=0) + # integrate over mass-ratio + numh4 = utils.trapz(numh4, edges[1], axis=1) + # integrate over redshift + numh4 = utils.trapz(numh4, edges[2], axis=2) + # times dln(f) + print('numh4:', numh4.shape, 'np.diff(np.log(fobs_gw_edges))', np.diff(np.log(fobs_gw_edges)).shape) + numh4 = numh4 * np.diff(np.log(fobs_gw_edges)) # how is this not a shape issue?? + + elif utils.isinteger(realize): + # add reals axis + hs_cents = strain_amp_at_bin_centers_redz(edges, redz)[...,np.newaxis] + print('hs_cents:', hs_cents.shape) + df = df[:,np.newaxis] + fc = fc[:,np.newaxis] + + + number = holo.sam_cython.integrate_differential_number_3dx1d(edges, dnum) + shape = number.shape + (realize,) + print('number:', number.shape) + number = holo.gravwaves.poisson_as_needed(number[...,np.newaxis] * np.ones(shape)) + print('number:', number.shape) + + numh2 = number * hs_cents**2 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] + numh4 = number * hs_cents**4 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] + + + + else: + err = "`realize` ({}) must be one of {{False, integer}}!".format(realize) + raise ValueError(err) + + print('numh2:', numh2.shape, 'numh4:', numh4.shape) + + + # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray + # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray + + delta_term = ( + fc / (4*np.pi * df) * np.sum(numh2, axis=(0,1,2)) + )**2 + + Cl = ( + (fc / (4*np.pi*df))**2 * np.sum(numh4, axis=(0,1,2)) + ) + + C0 = Cl + delta_term + + return C0, Cl + +###################################################################### +############# Plotting Functions +###################################################################### + +def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic', lw=2): + xx = fobs_gw_cents + yy = Cl/C0 # (F,) + ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle='dashdot') + +def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization', + show_ci=False, show_reals=True, show_median=False): + xx = fobs_gw_cents + yy = Cl_many/C0_many # (F,R) + if show_median: + ax.plot(xx, np.median(yy[:,:], axis=-1), color=color) #, label='median of samples, $l=%d$' % ll) + if show_ci: + for pp in [50, 98]: + percs = pp/2 + percs = [50-percs, 50+percs] + ax.fill_between(xx, *np.percentile(yy[:,:], percs, axis=-1), color=color, alpha=0.1) + if show_reals: + rr = 0 + ax.plot(xx, yy[:,rr], color=color, alpha=0.15, linestyle='-', + label = label) + for rr in range(1, np.min([nshow, len(Cl_many[0])])): + ax.plot(xx, yy[:,rr], color=color, alpha=0.25, linestyle='-') + +def draw_spk(ax, label='SP & K Rough Estimate'): + spk_xx= np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7]) /YR + spk_yy= np.array([1*10**-5, 1*10**-3, 1*10**-1]) + ax.plot(spk_xx * YR, spk_yy, label=label, color='limegreen', ls='--') + +def draw_bayes(ax, lmax, colors = ['k', 'b', 'r', 'g', 'c', 'm']): + xx_Nihan = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz + + Cl_nihan = np.array([ + [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427], + [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662], + [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785], + [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331], + [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]]) + for ll in range(lmax): + ax.plot(xx_Nihan, Cl_nihan[:,ll]/Cl_nihan[:,0], + label = '$l=%d$' % (ll+1), + color=colors[ll], marker='o', ms=8) + +def draw_sim(ax, xx, Cl_best, lmax, nshow, show_ci=True, show_reals=True): + + yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l) + yy = np.median(yy, axis=-1) # (B,F,l) median over realizations + + colors = ['k', 'b', 'r', 'g', 'c', 'm'] + for ll in range(lmax): + ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll) + if show_ci: + for pp in [50, 98]: + percs = pp/2 + percs = [50-percs, 50+percs] + ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll]) + if show_reals: + for bb in range(0,nshow): + # if ll==0 and bb==0: + # label = "individual best samples, median of realizations" + # else: + label=None + ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1, + linewidth=1, label=label) + + +# def plot_ClC0(fobs_gw_cents, spk=True, bayes=True, +# sim=True, Cl_best_sim=None, lmax_sim=None, +# analytic=False, Cl_analytic, C0_analytic, label_analytic, +# anreals=False, Cl_anreals=None): +# fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\ell>0}/C_0$') +# draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num') +# draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, label=None, color='tab:orange') + +# draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum, hs from z_init', color='deeppink') +# draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink') + +# draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs from z_final', color='indigo') +# draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo') + +# if spk: draw_spk(ax, label='S-P & K') +# if bayes: draw_bayes(ax, lmax=6) +# if sim and (Cl_best_sim is not None) and (lmax_sim is not None): +# draw_sim(ax, fobs_gw_cents, Cl_best_sim, lmax_sim, show_ci=True, show_reals=True, nshow=10) +# # ax.set_ylim(10**-6, 10**0) +# plot._twin_yr(ax, nano=False) +# ax.set_xlim(fobs_gw_cents[0]- 10**(-10), 1/YR) + +# fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3) +# return fig + +# fig = plot_ClC0() From 13f43c06542397567cdf887b92bcf12236ec415f Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 2 Jun 2023 16:11:18 -0700 Subject: [PATCH 008/291] minimal changes --- ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb | 1 + 1 file changed, 1 insertion(+) diff --git a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb index ab1ad5fe..3b4f69b9 100644 --- a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb +++ b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb @@ -15,6 +15,7 @@ "import matplotlib.cm as cm\n", "import h5py\n", "\n", + "\n", "from holodeck import plot, detstats\n", "from holodeck.constants import YR, MSOL, MPC\n", "import holodeck as holo" From 329b5924fac373570dd563fb1745208b53f531b7 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 2 Jun 2023 17:20:56 -0700 Subject: [PATCH 009/291] Comparing different anisotropy methods, automated in analytic_anisotropy_methods.ipynb for different sam and hard. --- .../analytic_anisotropy_methods.ipynb | 394 ++++++++++++++++++ .../anisotropy/analytic_investigation.ipynb | 48 +++ .../anisotropy/sato_polito_anisotropy.ipynb | 83 ++-- holodeck/anisotropy.py | 66 ++- 4 files changed, 524 insertions(+), 67 deletions(-) create mode 100644 ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb create mode 100644 ecg-notebooks/anisotropy/analytic_investigation.ipynb diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb new file mode 100644 index 00000000..a9cf4946 --- /dev/null +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -0,0 +1,394 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import h5py\n", + "import healpy as hp\n", + "import kalepy as kale\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "from holodeck import detstats, plot, utils\n", + "from holodeck.constants import YR, MSOL, GYR" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dur, cad = 16.03*YR, 0.2*YR\n", + "fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + "fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + "# sam = holo.sam.Semi_Analytic_Model()\n", + "sam = holo.sam.Semi_Analytic_Model(shape=20) # faster version\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_orb_cents = fobs_gw_cents/2.0\n", + "fobs_orb_edges = fobs_gw_edges/2.0\n", + "# hard = holo.hardening.Hard_GW()\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Anisotropy" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$ C_\\ell (f) = \\delta_{\\ell 0}\\delta_{m0} \\bigg( \\frac{f}{4\\pi \\Delta f} \\int d \\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^2 (f,\\vec{\\theta}) \\bigg)^2 \n", + "+ \\big( \\frac{f}{4 \\pi \\Delta f}\\big)^2 \\int d\\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^4 (f, \\vec{\\theta})\n", + "$$\n", + "\n", + "\n", + "\n", + "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", + "= number density of binaries, per unit redshift, mass-ratio, and log10 of mass\n", + "\n", + "* dnum = d^4N / dlog10M dq dz dlnf\n", + "\n", + "* number = dN /dlnf" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + " ## Cl_analytic_from_num()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hs = holo.gravwaves.strain_amp_from_bin_edges_redz(edges, redz_final)\n", + "cynum = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + "C0_cynum, Cl_cynum = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs)\n", + "C0_cyreals, Cl_cyreals = anis.Cl_analytic_from_num(fobs_orb_edges, cynum, hs, realize=20)\n", + "\n", + "utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + "utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", + "C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + "ax = fig.axes[0]\n", + "\n", + "anis.draw_analytic(ax, Cl_cynum, C0_cynum, fobs_gw_cents, color='tab:orange', label='cython number', alpha=0.5, lw=4)\n", + "anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", + "anis.draw_analytic(ax, Cl_utnum, C0_utnum, fobs_gw_cents, color='tab:red', label='utils number', alpha=0.5)\n", + "anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", + "fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This confirms that using number function is same, regardless which number we use" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Cl_analytic_from_dnum" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "C0_dnum, Cl_dnum = anis.Cl_analytic_from_dnum(edges, diff_num)\n", + "C0_dnum_reals, Cl_dnum_reals = anis.Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", + "C0_redz, Cl_redz = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", + "C0_redz_reals, Cl_redz_reals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "arr = np.array([1,2,3,4,])\n", + "print(arr[:,np.newaxis].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(C0_dnum.shape)\n", + "print(C0_dnum_reals.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "note that Cl_best does not use the same model as the mockups for Sato-Polito method here!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + "ax = fig.axes[0]\n", + "\n", + "anis.draw_analytic(ax, Cl_cynum, C0_cynum, fobs_gw_cents, color='tab:orange', label='cython number', alpha=0.5, lw=4)\n", + "anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", + "anis.draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='dnum, z_init', color='deeppink')\n", + "anis.draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink')\n", + "\n", + "anis.draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='dnum, z_final', color='indigo')\n", + "anis.draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo')\n", + "\n", + "fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", + "ax.set_title('Shape=%s, %s' % (str(sam.shape), str(hard_name)), fontsize=14)\n", + "\n", + "fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare Models" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges):\n", + "\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "\n", + " # analytic from number\n", + " print('calculating analytic from cython number')\n", + " hs = holo.gravwaves.strain_amp_from_bin_edges_redz(edges, redz_final)\n", + " cynum = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " C0_cynum, Cl_cynum = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs)\n", + " C0_cyreals, Cl_cyreals = anis.Cl_analytic_from_num(fobs_orb_edges, cynum, hs, realize=20)\n", + "\n", + " # analytic from dnum\n", + " print('calculating analytic from dnum, initial redshift')\n", + " C0_dnum, Cl_dnum = anis.Cl_analytic_from_dnum(edges, diff_num)\n", + " C0_dnum_reals, Cl_dnum_reals = anis.Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", + "\n", + " print('calculating analytic from dnum, final redshift')\n", + " C0_redz, Cl_redz = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", + " C0_redz_reals, Cl_redz_reals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)\n", + "\n", + " # plot everything\n", + " print('plotting')\n", + " fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + " ax = fig.axes[0]\n", + "\n", + " anis.draw_analytic(ax, Cl_cynum, C0_cynum, fobs_gw_cents, color='tab:orange', label='cython number', lw=4)\n", + " anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", + " anis.draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='dnum, z_init', color='deeppink', lw=4)\n", + " anis.draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink')\n", + "\n", + " anis.draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='dnum, z_final', color='indigo', lw=4)\n", + " anis.draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo')\n", + "\n", + " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", + " ax.set_title('Shape=%s, %s' % (str(sam.shape), str(hard_name)), fontsize=14)\n", + "\n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Fixed Time, small shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20) \n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GW Only, small shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20) \n", + "hard = holo.hardening.Hard_GW()\n", + "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Fixed Time, full shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=None) \n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GW Only, full shape" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=None) \n", + "hard = holo.hardening.Hard_GW()\n", + "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb new file mode 100644 index 00000000..8d15c004 --- /dev/null +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -0,0 +1,48 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "import matplotlib.pyplot as plot\n", + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index b541b714..dd448870 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -306,8 +306,8 @@ "dur, cad = 16.03*YR, 0.2*YR\n", "fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", "fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", - "sam = holo.sam.Semi_Analytic_Model()\n", - "# sam = holo.sam.Semi_Analytic_Model(mtot=(1.0e4*MSOL, 1.0e11*MSOL, 20), mrat=(1e-3, 1.0, 20), redz=(1e-3, 10.0, 20)) # faster version\n" + "# sam = holo.sam.Semi_Analytic_Model()\n", + "sam = holo.sam.Semi_Analytic_Model(shape=20) # faster version\n" ] }, { @@ -318,14 +318,31 @@ "source": [ "fobs_orb_cents = fobs_gw_cents/2.0\n", "fobs_orb_edges = fobs_gw_edges/2.0\n", - "hard = holo.hardening.Hard_GW()\n", - "# hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "# hard = holo.hardening.Hard_GW()\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", " fobs_orb_cents, sam, hard, holo.cosmo)\n", "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", - "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)" + "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + "\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -592,27 +609,27 @@ "metadata": {}, "outputs": [], "source": [ - "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", + "# sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", "\n", - "# load ss info\n", - "shape = sph_harm_file['ss_shape']\n", - "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - "fobs = sph_harm_file['fobs']\n", + "# # load ss info\n", + "# shape = sph_harm_file['ss_shape']\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# fobs = sph_harm_file['fobs']\n", "\n", - "# load ranking info\n", - "nsort = sph_harm_file['nsort']\n", - "fidx = sph_harm_file['fidx']\n", - "hc_tt = sph_harm_file['hc_tt']\n", - "hc_ref15 = sph_harm_file['hc_ref15']\n", + "# # load ranking info\n", + "# nsort = sph_harm_file['nsort']\n", + "# fidx = sph_harm_file['fidx']\n", + "# hc_tt = sph_harm_file['hc_tt']\n", + "# hc_ref15 = sph_harm_file['hc_ref15']\n", "\n", - "# load harmonics info\n", - "nside = sph_harm_file['nside']\n", - "lmax = sph_harm_file['lmax']\n", - "moll_hc_best = sph_harm_file['moll_hc_best']\n", - "Cl_best = sph_harm_file['Cl_best']\n", - "nbest = len(moll_hc_best)\n", + "# # load harmonics info\n", + "# nside = sph_harm_file['nside']\n", + "# lmax = sph_harm_file['lmax']\n", + "# moll_hc_best = sph_harm_file['moll_hc_best']\n", + "# Cl_best = sph_harm_file['Cl_best']\n", + "# nbest = len(moll_hc_best)\n", "\n", - "sph_harm_file.close()" + "# sph_harm_file.close()" ] }, { @@ -627,7 +644,7 @@ " draw_reals(ax, Cl_many, C0_many, fobs_gw_cents)\n", " draw_spk(ax)\n", " draw_bayes(ax, lmax=6)\n", - " draw_sim(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", + " # draw_sim(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", @@ -672,6 +689,12 @@ "## Cl_analytic_from_dnum" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -880,7 +903,7 @@ " \n", " draw_spk(ax, label='S-P & K')\n", " draw_bayes(ax, lmax=6)\n", - " draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=True, show_reals=True, nshow=10)\n", + " # draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=True, show_reals=True, nshow=10)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", @@ -888,7 +911,8 @@ " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)\n", " return fig\n", "\n", - "fig = plot_ClC0() " + "fig = plot_ClC0() \n", + "fig.suptitle(hard_name, sam.shape)" ] }, { @@ -916,7 +940,7 @@ " \n", " draw_spk(ax, label='S-P & K')\n", " draw_bayes(ax, lmax=6)\n", - " draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=False, show_reals=True, nshow=20)\n", + " # draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=False, show_reals=True, nshow=20)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", @@ -958,6 +982,13 @@ "fig = plot_ClC0() " ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 16c598dc..3a3565b1 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -375,37 +375,25 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): # integrate over redshift numh4 = utils.trapz(numh4, edges[2], axis=2) # times dln(f) - print('numh4:', numh4.shape, 'np.diff(np.log(fobs_gw_edges))', np.diff(np.log(fobs_gw_edges)).shape) numh4 = numh4 * np.diff(np.log(fobs_gw_edges)) # how is this not a shape issue?? elif utils.isinteger(realize): # add reals axis hs_cents = strain_amp_at_bin_centers_redz(edges, redz)[...,np.newaxis] - print('hs_cents:', hs_cents.shape) df = df[:,np.newaxis] fc = fc[:,np.newaxis] number = holo.sam_cython.integrate_differential_number_3dx1d(edges, dnum) shape = number.shape + (realize,) - print('number:', number.shape) number = holo.gravwaves.poisson_as_needed(number[...,np.newaxis] * np.ones(shape)) - print('number:', number.shape) numh2 = number * hs_cents**2 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] numh4 = number * hs_cents**4 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] - - - else: err = "`realize` ({}) must be one of {{False, integer}}!".format(realize) raise ValueError(err) - print('numh2:', numh2.shape, 'numh4:', numh4.shape) - - - # df = fobs_orb_widths[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray - # fc = fobs_orb_cents[np.newaxis, np.newaxis, np.newaxis, :] # (M,Q,Z,F) NDarray delta_term = ( fc / (4*np.pi * df) * np.sum(numh2, axis=(0,1,2)) @@ -425,13 +413,14 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): -def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic', lw=2): +def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic', + alpha=1, lw=2): xx = fobs_gw_cents yy = Cl/C0 # (F,) - ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle='dashdot') + ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle='dashdot', alpha=alpha) def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization', - show_ci=False, show_reals=True, show_median=False): + show_ci=False, show_reals=True, show_median=False, nshow=10): xx = fobs_gw_cents yy = Cl_many/C0_many # (F,R) if show_median: @@ -490,29 +479,24 @@ def draw_sim(ax, xx, Cl_best, lmax, nshow, show_ci=True, show_reals=True): linewidth=1, label=label) -# def plot_ClC0(fobs_gw_cents, spk=True, bayes=True, -# sim=True, Cl_best_sim=None, lmax_sim=None, -# analytic=False, Cl_analytic, C0_analytic, label_analytic, -# anreals=False, Cl_anreals=None): -# fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\ell>0}/C_0$') -# draw_analytic(ax, Cl, C0, fobs_gw_cents, label='analytic from integrated num') -# draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, label=None, color='tab:orange') - -# draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='analytic from dnum, hs from z_init', color='deeppink') -# draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink') - -# draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='analytic from dnum, hs from z_final', color='indigo') -# draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo') - -# if spk: draw_spk(ax, label='S-P & K') -# if bayes: draw_bayes(ax, lmax=6) -# if sim and (Cl_best_sim is not None) and (lmax_sim is not None): -# draw_sim(ax, fobs_gw_cents, Cl_best_sim, lmax_sim, show_ci=True, show_reals=True, nshow=10) -# # ax.set_ylim(10**-6, 10**0) -# plot._twin_yr(ax, nano=False) -# ax.set_xlim(fobs_gw_cents[0]- 10**(-10), 1/YR) - -# fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3) -# return fig - -# fig = plot_ClC0() +def plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=True, + sim=True, Cl_best_sim=None, lmax_sim=None, + analytic=False, Cl_analytic=None, C0_analytic=None, label_analytic='analytic', + anreals=False, Cl_anreals=None, C0_anreals=None, label_anreals=None, + xmax = 1/YR, leg_anchor=(0,-0.15), leg_cols=3, legend=False): + fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\ell>0}/C_0$') + + if analytic: draw_analytic(ax, Cl_analytic, C0_analytic, fobs_gw_cents, label=label_analytic) + if anreals: draw_reals(ax, Cl_anreals, C0_anreals, fobs_gw_cents, label=label_anreals) + + if bayes: draw_bayes(ax, lmax=6) + if spk: draw_spk(ax, label='S-P & K') + if sim and (Cl_best_sim is not None) and (lmax_sim is not None): + draw_sim(ax, fobs_gw_cents, Cl_best_sim, lmax_sim, show_ci=True, show_reals=True, nshow=10) + # ax.set_ylim(10**-6, 10**0) + plot._twin_yr(ax, nano=False) + ax.set_xlim(fobs_gw_cents[0]- 10**(-10), xmax) + + if legend: + fig.legend(bbox_to_anchor=leg_anchor, loc='upper left', bbox_transform = ax.transAxes, ncols=leg_cols) + return fig \ No newline at end of file From 8662c58b0fbf3e16ab803638572bf8dfcf597ea2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 3 Jun 2023 09:13:41 -0700 Subject: [PATCH 010/291] Plotting different integration methods in analytics_investigation,ipynb. --- .../analytic_anisotropy_methods.ipynb | 81 ++++++++++- .../anisotropy/analytic_investigation.ipynb | 132 ++++++++++++++++++ .../anisotropy/sato_polito_anisotropy.ipynb | 117 ++++++++-------- holodeck/anisotropy.py | 9 +- 4 files changed, 274 insertions(+), 65 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index a9cf4946..ee6cdafe 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -119,7 +119,8 @@ "utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", "utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", "C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", - "C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)" + "C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)\n", + "\n" ] }, { @@ -256,6 +257,12 @@ " C0_cynum, Cl_cynum = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs)\n", " C0_cyreals, Cl_cyreals = anis.Cl_analytic_from_num(fobs_orb_edges, cynum, hs, realize=20)\n", "\n", + " # anayltic from cython number\n", + " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + " C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", + " C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)\n", + "\n", " # analytic from dnum\n", " print('calculating analytic from dnum, initial redshift')\n", " C0_dnum, Cl_dnum = anis.Cl_analytic_from_dnum(edges, diff_num)\n", @@ -274,6 +281,10 @@ " anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", " show_reals=True, show_median=True, show_ci=True)\n", "\n", + " anis.draw_analytic(ax, Cl_utnum, C0_utnum, fobs_gw_cents, color='tab:red', label='utils number', lw=3)\n", + " anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", " anis.draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='dnum, z_init', color='deeppink', lw=4)\n", " anis.draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink')\n", "\n", @@ -319,7 +330,8 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=20) \n", + "# sam = holo.sam.Semi_Analytic_Model(shape=20) \n", + "sam - holo.sam.Semi_Analytic_Model(mtot=(1.0e4*MSOL, 1.0e12*MSOL, 20), mrat=(1e-3, 1.0, 20), redz=(1e-3, 10.0, 20))\n", "hard = holo.hardening.Hard_GW()\n", "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" ] @@ -362,6 +374,71 @@ "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(edges[0].shape)\n", + "print(hs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.loglog(edges[0][:-1], hs[:,0,18,5])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + "print(holo.utils.stats(number))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.diff(edges[1]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# integrate over log10mass\n", + "num = utils.trapz(diff_num, np.log10(edges[0]), axis=0)\n", + "# integrate over mass-ratio\n", + "num = utils.trapz(num, edges[1], axis=1)\n", + "# # integrate over redshift\n", + "# num = utils.trapz(num, edges[2], axis=2)\n", + "# # times dln(f)\n", + "# numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", + "print(num.shape)\n", + "plt.loglog(edges[2][:], num[10,10,:,10])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.loglog(edges[1][:-1], number[10,:,18,10])" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb index 8d15c004..140650d5 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -16,6 +16,138 @@ "import numpy as np" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", + "* dnum = d^4N / dlog10M dq dz dlnf\n", + "* number = dN /dlnf" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nbins = 10\n", + "\n", + "# redshift edges 0.01 to 1\n", + "edges = np.geomspace(10**-2, 10**1, nbins+1) # z bins\n", + "print('z edges:', edges)\n", + "\n", + "# dnum up to order 10^5, 10^6\n", + "dnum = np.geomspace(10**6, 10**0, nbins+1) # d^2N / dz dlnf \n", + "print('dnum:', dnum)\n", + "if(dnum[0]>dnum[-1]):\n", + " dnum_str = 'dnum decreasing'\n", + "else: \n", + " dnum_str = 'dnum increasing'\n", + "\n", + "# num \n", + "num = holo.utils.trapz(dnum, edges)\n", + "print('num:', num)\n", + "\n", + "# hs up to 10^-15\n", + "hs_exp_edges = np.linspace(-20, -15, nbins+1) \n", + "hs_exp_cents = holo.utils.midpoints(hs_exp_edges)\n", + "\n", + "hs_edges = 10**hs_exp_edges\n", + "hs_cents = 10**hs_exp_cents\n", + "if(hs_cents[0]>hs_cents[-1]):\n", + " hs_str = 'hs decreasing'\n", + "else:\n", + " hs_str = 'hs increasing'\n", + "print('hs_cents:', hs_cents)\n", + "print('hs_edges:', hs_edges)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "numh2 = num*hs_cents**2\n", + "numh4 = num*hs_cents**4\n", + "\n", + "dnumh2 = dnum*hs_edges**2\n", + "inth2 = holo.utils.trapz(dnumh2, edges)\n", + "\n", + "dnumh4 = dnum*hs_edges**4\n", + "inth4 = holo.utils.trapz(dnumh4, edges)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = holo.plot.figax(xlabel='z edges', ylabel='integral')\n", + "\n", + "ax.plot(edges[:-1], inth2, label=r'$\\int(\\mathrm{dnum}*h^2)$')\n", + "ax.plot(edges[:-1], numh2, label=r'$h^2* \\int(\\mathrm{dnum})$')\n", + "# ax.plot(edges[:-1], inth4, label=r'$\\int(\\mathrm{dnum}*h^4)$')\n", + "# ax.plot(edges[:-1], numh4, label=r'$h^4* \\int(\\mathrm{dnum})$')\n", + "\n", + "ax.legend()\n", + "ax.set_title('z increasing -> %s and %s' % (dnum_str, hs_str))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = holo.plot.figax(xlabel='z edges', ylabel='integral')\n", + "\n", + "# ax.plot(edges[:-1], inth2, label=r'$\\int(\\mathrm{dnum}*h^2)$')\n", + "# ax.plot(edges[:-1], numh2, label=r'$h^2* \\int(\\mathrm{dnum})$')\n", + "ax.plot(edges[:-1], inth4, label=r'$\\int(\\mathrm{dnum}*h^4)$')\n", + "ax.plot(edges[:-1], numh4, label=r'$h^4* \\int(\\mathrm{dnum})$')\n", + "\n", + "ax.legend()\n", + "\n", + "ax.set_title('z increasing -> %s and %s' % (dnum_str, hs_str))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "integrating before just makes the values slightly smaller" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(num)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.floor(num))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb index dd448870..ade40332 100644 --- a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb +++ b/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb @@ -135,19 +135,19 @@ "metadata": {}, "outputs": [], "source": [ - "sspath = '/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/'\n", - "hdfname = sspath+'ss_lib.hdf5'\n", - "ssfile = h5py.File(hdfname, 'r')\n", - "print(list(ssfile.keys()))\n", - "hc_ss = ssfile['hc_ss'][...]\n", - "hc_bg = ssfile['hc_bg'][...]\n", - "fobs = ssfile['fobs'][:]\n", - "dfobs = ssfile['dfobs'][:]\n", - "ssfile.close()\n", - "\n", - "shape = hc_ss.shape\n", - "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - "print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" + "# sspath = '/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/'\n", + "# hdfname = sspath+'ss_lib.hdf5'\n", + "# ssfile = h5py.File(hdfname, 'r')\n", + "# print(list(ssfile.keys()))\n", + "# hc_ss = ssfile['hc_ss'][...]\n", + "# hc_bg = ssfile['hc_bg'][...]\n", + "# fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "# ssfile.close()\n", + "\n", + "# shape = hc_ss.shape\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" ] }, { @@ -164,9 +164,9 @@ "metadata": {}, "outputs": [], "source": [ - "hc_ref15_10yr = 11.2*10**-15 \n", - "nsort, fidx, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", - "print(hc_ref15)" + "# hc_ref15_10yr = 11.2*10**-15 \n", + "# nsort, fidx, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# print(hc_ref15)" ] }, { @@ -183,8 +183,8 @@ "metadata": {}, "outputs": [], "source": [ - "nside=32\n", - "moll_hc = anisotropy.healpix_map(hc_ss[nsort[0]], hc_bg[nsort[0]], nside=nside)" + "# nside=32\n", + "# moll_hc = anisotropy.healpix_map(hc_ss[nsort[0]], hc_bg[nsort[0]], nside=nside)" ] }, { @@ -193,8 +193,8 @@ "metadata": {}, "outputs": [], "source": [ - "rr=0\n", - "hp.mollview(moll_hc[rr,fidx], title='Sample %d, Realization %d, $f$=%.2f yr$^{-1}$' % (nsort[0], rr, fobs[fidx]*YR))" + "# rr=0\n", + "# hp.mollview(moll_hc[rr,fidx], title='Sample %d, Realization %d, $f$=%.2f yr$^{-1}$' % (nsort[0], rr, fobs_gw_cents[fidx]*YR))" ] }, { @@ -221,7 +221,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(moll_hc.shape)" + "# print(moll_hc.shape)" ] }, { @@ -230,25 +230,25 @@ "metadata": {}, "outputs": [], "source": [ - "def ClC0_analytic(moll_hc):\n", - " \"\"\" Calculate Cl/C0 for l>0 using Sato-Polito Eq. 17, modified\n", - " to use characteristic strains from Poisson sampled parameter bins \n", - " already calculated and placed at random pixels.\n", + "# def ClC0_analytic(moll_hc):\n", + "# \"\"\" Calculate Cl/C0 for l>0 using Sato-Polito Eq. 17, modified\n", + "# to use characteristic strains from Poisson sampled parameter bins \n", + "# already calculated and placed at random pixels.\n", "\n", - " Parameters\n", - " ----------\n", - " moll_hc : (F,R,npix) \n", - " \"\"\"\n", + "# Parameters\n", + "# ----------\n", + "# moll_hc : (F,R,npix) \n", + "# \"\"\"\n", " \n", - " nside = hp.npix2nside(len(moll_hc[0,0]))\n", - " area = hp.nside2pixarea(nside)\n", + "# nside = hp.npix2nside(len(moll_hc[0,0]))\n", + "# area = hp.nside2pixarea(nside)\n", "\n", - " sum_term = moll_hc**4 / (area*moll_hc**4 + moll_hc**4)\n", - " ClC0 = np.sum(sum_term, axis=-1) # sum over pixels\n", + "# sum_term = moll_hc**4 / (area*moll_hc**4 + moll_hc**4)\n", + "# ClC0 = np.sum(sum_term, axis=-1) # sum over pixels\n", "\n", - " return ClC0\n", + "# return ClC0\n", "\n", - "print(hp.nside2pixarea(nside))" + "# print(hp.nside2pixarea(nside))" ] }, { @@ -257,8 +257,8 @@ "metadata": {}, "outputs": [], "source": [ - "ClC0 = ClC0_analytic(moll_hc)\n", - "print(ClC0.shape) # F, R" + "# ClC0 = ClC0_analytic(moll_hc)\n", + "# print(ClC0.shape) # F, R" ] }, { @@ -267,15 +267,15 @@ "metadata": {}, "outputs": [], "source": [ - "nshow=20\n", + "# nshow=20\n", "\n", - "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", - "xx = fobs*YR\n", - "for rr in range(nshow):\n", - " yy = ClC0[:,rr]\n", - " ax.plot(xx, yy, color='tab:orange')\n", - "# ax.set_ylim(10**-6, 10**0)\n", - "plot._twin_hz(ax, nano=False)" + "# fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "# xx = fobs*YR\n", + "# for rr in range(nshow):\n", + "# yy = ClC0[:,rr]\n", + "# ax.plot(xx, yy, color='tab:orange')\n", + "# # ax.set_ylim(10**-6, 10**0)\n", + "# plot._twin_hz(ax, nano=False)" ] }, { @@ -318,8 +318,8 @@ "source": [ "fobs_orb_cents = fobs_gw_cents/2.0\n", "fobs_orb_edges = fobs_gw_edges/2.0\n", - "# hard = holo.hardening.Hard_GW()\n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "hard = holo.hardening.Hard_GW()\n", + "# hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", " fobs_orb_cents, sam, hard, holo.cosmo)\n", "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", @@ -647,7 +647,7 @@ " # draw_sim(ax, fobs_gw_cents, Cl_best, lmax, nshow=10)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", - " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", + " ax.set_xlim(fobs_gw_cents[0]- 10**(-10), 1/YR)\n", "\n", " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)\n", " return fig\n", @@ -906,13 +906,13 @@ " # draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=True, show_reals=True, nshow=10)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", - " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", + " ax.set_xlim(fobs_gw_cents[0]- 10**(-10), 1/YR)\n", "\n", " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)\n", " return fig\n", "\n", "fig = plot_ClC0() \n", - "fig.suptitle(hard_name, sam.shape)" + "fig.axes[0].set_title(str(hard_name) +', '+ str(sam.shape))" ] }, { @@ -943,12 +943,13 @@ " # draw_sim(ax, fobs_gw_cents, Cl_best, lmax, show_ci=False, show_reals=True, nshow=20)\n", " # ax.set_ylim(10**-6, 10**0)\n", " plot._twin_yr(ax, nano=False)\n", - " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", + " ax.set_xlim(fobs_gw_cents[0]- 10**(-10), 1/YR)\n", "\n", " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)\n", " return fig\n", "\n", - "fig = plot_ClC0() " + "fig = plot_ClC0() \n", + "fig.axes[0].set_title(str(hard_name) +', '+ str(sam.shape))" ] }, { @@ -974,21 +975,15 @@ " draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo',\n", " show_ci=True, show_median=True)\n", " plot._twin_yr(ax, nano=False)\n", - " ax.set_xlim(fobs[0]- 10**(-10), 1/YR)\n", + " ax.set_xlim(fobs_gw_cents[0]- 10**(-10), 1/YR)\n", "\n", " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=1)\n", " return fig\n", "\n", - "fig = plot_ClC0() " + "fig = plot_ClC0() \n", + "fig.axes[0].set_title(str(hard_name) +', '+ str(sam.shape))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 3a3565b1..425a2cd4 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -214,7 +214,7 @@ def lib_anisotropy(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lm ############# Analytic/Sato-Polito ###################################################################### -def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False): +def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False, floor = False): """ Calculate Cl using Eq. (17) of Sato-Polito & Kamionkowski Parameters ---------- @@ -226,6 +226,8 @@ def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False): Number of sources in each M,q,z, bin realize : boolean or integer How many realizations to Poisson sample. + floor : boolean + Whether or not to round numbers down to nearest integers, if not realizing Returns ------- @@ -251,7 +253,8 @@ def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False): hs = hs[...,np.newaxis] elif realize is True: number = holo.gravwaves.poisson_as_needed(number) - + elif floor is True: + number = np.floor(number) delta_term = (fc/(4*np.pi*df) * np.sum(number*hs**2, axis=(0,1,2)))**2 @@ -407,6 +410,8 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): return C0, Cl + + ###################################################################### ############# Plotting Functions ###################################################################### From c9a882588926ff2cf674996118b072a311fd4afc Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 3 Jun 2023 10:44:59 -0700 Subject: [PATCH 011/291] Getting some good samples for Jeremy's detstats. --- ecg-notebooks/check_libs_hdf_and_npz.ipynb | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/check_libs_hdf_and_npz.ipynb b/ecg-notebooks/check_libs_hdf_and_npz.ipynb index e410b55d..f0aa240b 100644 --- a/ecg-notebooks/check_libs_hdf_and_npz.ipynb +++ b/ecg-notebooks/check_libs_hdf_and_npz.ipynb @@ -48,7 +48,7 @@ "metadata": {}, "outputs": [], "source": [ - "ssfile = h5py.File('/Users/emigardiner/GWs/holodeck/output/2023-05-31-test06_uniform07A_s10/sam_lib.hdf5', 'r+')\n", + "ssfile = h5py.File('/Users/emigardiner/GWs/holodeck/output/awg_output/uniform-07a_new_n500_r100_f40/sam_lib.hdf5', 'r+')\n", "list(ssfile.keys())" ] }, @@ -58,18 +58,31 @@ "metadata": {}, "outputs": [], "source": [ - "hc_bg_com = ssfile['hc_bg']\n", + "hc_bg_com = ssfile['hc_bg'][...]\n", "print(hc_bg_com.shape)\n", - "hc_ss_com = ssfile['hc_ss']\n", + "hc_ss_com = ssfile['hc_ss'][...]\n", "print(hc_ss_com.shape)\n", - "fobs_com = ssfile['fobs']\n", + "fobs_com = ssfile['fobs'][:]\n", "print(fobs_com.shape)\n", - "sspar_com = ssfile['sspar']\n", + "sspar_com = ssfile['sspar'][...]\n", "print(sspar_com.shape)\n", - "bgpar_com = ssfile['bgpar']\n", + "bgpar_com = ssfile['bgpar'][...]\n", "print(bgpar_com.shape)\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsort, fidx, hc_ref = holo.detstats.rank_samples(hc_ss_com, hc_bg_com, fobs_com, fidx=1, hc_ref=holo.detstats.HC_REF15_10YR, ret_all=True)\n", + "np.savez('/Users/emigardiner/GWs/holodeck/output/awg_output/uniform-07a_new_n500_r100_f40/sample_rankinsg.npz', nsort)\n", + "print(nsort[:10])\n", + "print(fobs_com[fidx]*YR)\n", + "print(hc_ref)" + ] + }, { "cell_type": "code", "execution_count": null, From 6723b186659d8b8d92c24700778a981af1b765cf Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 3 Jun 2023 20:19:12 -0700 Subject: [PATCH 012/291] Looking at 1d dnum/d(edge parameter) for each. Compared strain with initial vs final redshift. --- .../analytic_anisotropy_methods.ipynb | 7 +- .../anisotropy/analytic_investigation.ipynb | 330 +++++++++++++++++- 2 files changed, 331 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index ee6cdafe..4e01be13 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -90,10 +90,7 @@ "\n", "\n", "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", - "= number density of binaries, per unit redshift, mass-ratio, and log10 of mass\n", - "\n", "* dnum = d^4N / dlog10M dq dz dlnf\n", - "\n", "* number = dN /dlnf" ] }, @@ -330,8 +327,8 @@ "metadata": {}, "outputs": [], "source": [ - "# sam = holo.sam.Semi_Analytic_Model(shape=20) \n", - "sam - holo.sam.Semi_Analytic_Model(mtot=(1.0e4*MSOL, 1.0e12*MSOL, 20), mrat=(1e-3, 1.0, 20), redz=(1e-3, 10.0, 20))\n", + "sam = holo.sam.Semi_Analytic_Model(shape=20) \n", + "# sam - holo.sam.Semi_Analytic_Model(mtot=(1.0e4*MSOL, 1.0e12*MSOL, 20), mrat=(1e-3, 1.0, 20), redz=(1e-3, 10.0, 20))\n", "hard = holo.hardening.Hard_GW()\n", "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" ] diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb index 140650d5..3f2fe8f2 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -12,7 +12,10 @@ "\n", "import holodeck as holo\n", "import holodeck.anisotropy as anis\n", - "import matplotlib.pyplot as plot\n", + "from holodeck.constants import YR, MSOL, GYR\n", + "from holodeck import utils\n", + "\n", + "import matplotlib.pyplot as plt\n", "import numpy as np" ] }, @@ -148,6 +151,331 @@ "print(np.floor(num))" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def sam_model(\n", + " hard = holo.hardening.Hard_GW(), shape=20, \n", + " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", + " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", + " hard = holo.hardening.Hard_GW()\n", + " sam = holo.sam.Semi_Analytic_Model(shape=shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " if use_redz:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges, redz_final)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges, redz_final)\n", + " else:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges)\n", + "\n", + " vals = {\n", + " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", + " 'hs_cents':hs_cents, 'hs_edges':hs_edges, 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", + " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", + " }\n", + " return vals\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = sam_model(hard=holo.hardening.Hard_GW, shape=10, use_redz=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "edges_mm = vals['edges'][0]\n", + "cents_mm = utils.midpoints(edges_mm, log=True)\n", + "edges_qq = vals['edges'][1]\n", + "cents_qq = utils.midpoints(edges_qq, log=True)\n", + "edges_zz = vals['edges'][2]\n", + "cents_zz = utils.midpoints(edges_zz, log=True)\n", + "dnum = vals['diff_num']\n", + "\n", + "np.set_printoptions(precision=3)\n", + "print('M edges (g)', edges_mm)\n", + "print('q edges', edges_qq)\n", + "print('z edges', edges_zz)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", + " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " return num\n", + "def integrate_qq(dnum, edges): # integrate dN/dq\n", + " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", + " return num\n", + "def integrate_zz(dnum, edges): # dN/dz\n", + " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", + " return num\n", + "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", + " num = dnum*np.diff(np.log(fobs_gw_edges))\n", + " return num \n", + "\n", + "dnum = vals['diff_num']\n", + "edges = vals['edges']\n", + "fobs_gw_edges = vals['fobs_gw_edges']\n", + "fobs_gw_cents = vals['fobs_gw_cents']\n", + "dnum_mm = integrate_ff(integrate_zz(integrate_qq(dnum, edges), edges), fobs_gw_edges)\n", + "dnum_qq = integrate_ff(integrate_qq(integrate_mm(dnum, edges), edges), fobs_gw_edges)\n", + "dnum_zz = integrate_ff(integrate_qq(integrate_mm(dnum, edges), edges), fobs_gw_edges)\n", + "print(dnum_mm.shape, dnum_qq.shape, dnum_zz.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "qq=5\n", + "mm=7\n", + "zz=5\n", + "ff=1\n", + "\n", + "fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + ")\n", + "\n", + "xx = np.array([edges_mm/MSOL, edges_qq, edges_zz])\n", + "yy = np.array([dnum_mm[:,qq,zz,ff], dnum[mm,:,zz,ff], dnum[:,qq,zz,ff]])\n", + "labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + "ylabels = np.array(['$dN/d\\log (M)$', '$dN/dq$', '$dN/dz$'])\n", + "\n", + "for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy[ii], label=labels[ii] \n", + " )\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend(loc='lower left')\n", + "\n", + "fig.tight_layout" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_numbers(vals, mm=8, qq=5, zz=8, ff=1):\n", + " dnum = vals['diff_num']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + " cynum = vals['number']\n", + " tznum = integrate_zz(dnum_zz, edges)\n", + " utnum = utils._integrate_grid_differential_number(edges, dnum, freq=False)\n", + " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[:,qq,zz,ff]])\n", + " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[:,qq,zz,ff]])\n", + " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[:,qq,zz,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$N (M)$', '$N(q)$', '$N(z)$'])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_cyth[ii], label=labels[ii]+' cython', linestyle='-', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_trap[ii], label=labels[ii]+' trapz', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", + " )\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + "\n", + " fig.tight_layout\n", + " return fig\n", + "\n", + "fig = plot_numbers(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "ok cool, my integration is working right" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_strain_amp(vals, mm=7, qq=5, zz=5, ff=1):\n", + " # dnum = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + "\n", + " hs_final = anis.strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", + " hs_initz = anis.strain_amp_at_bin_centers_redz(edges, redz=None)\n", + " print(holo.utils.stats(hs_final/hs_initz))\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " yy_initz = np.array([hs_initz[:,qq,zz,ff], hs_initz[mm,:,zz,ff], hs_initz[:,qq,zz,ff]])\n", + " yy_final = np.array([hs_final[:,qq,zz,ff], hs_final[mm,:,zz,ff], hs_final[:,qq,zz,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$h_s (M)$', '$h_s(q)$', '$h_s(z)$'])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_initz[ii], label=labels[ii]+' initial z', linestyle='-', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_final[ii], label=labels[ii]+' final z', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + "\n", + " fig.tight_layout\n", + " return fig\n", + "\n", + "fig = plot_strain_amp(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Comparing strain amplitude for initial/final redz\n", + "\n", + "conclusion: \n", + "hs differences are almost negligible UNLESS hs_final is just 0 because redz_final has become -1 (never reaches GW emission)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", + "vals = sam_model(hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR), shape=20, use_redz=True)\n", + "fig = plot_strain_amp(vals, mm=18, qq=18, zz=15, ff=32)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "edges_zz = vals['edges'][2]\n", + "cents_zz = utils.midpoints(edges_zz, log=True)\n", + "redz_final = vals['redz_final']\n", + "print(np.unravel_index(np.argmax(np.abs(redz_final-edges_zz[np.newaxis,np.newaxis,:,np.newaxis])), redz_final.shape))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hs_final = anis.strain_amp_at_bin_edges_redz(vals['edges'], vals['redz_final'])\n", + "hs_initz = anis.strain_amp_at_bin_edges_redz(vals['edges'], redz=None)\n", + "print(hs_final[14,0,17,32])\n", + "print(hs_initz[14,0,17,32])\n", + "print(np.unravel_index(np.argmax(np.abs(hs_final-hs_initz)), hs_initz.shape))\n", + "print(hs_final[19,19,0,39])\n", + "print(hs_initz[19,19,0,39])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "plt.scatter(redz_final.flatten(), hs_final.flatten())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(edges_zz, redz_final[19,19,:,39])" + ] + }, { "cell_type": "code", "execution_count": null, From ab116cff49375a1454de46edc66d8fe9148dd49b Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 3 Jun 2023 23:05:07 -0700 Subject: [PATCH 013/291] Compare hs, dN/dpar, and N as functions of different pars. Automated functions for any model. --- .../anisotropy/analytic_investigation.ipynb | 246 +++++++++++------- holodeck/anisotropy.py | 4 +- 2 files changed, 152 insertions(+), 98 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb index 3f2fe8f2..f3b8b31e 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -189,16 +189,19 @@ " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", " }\n", " return vals\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "vals = sam_model(hard=holo.hardening.Hard_GW, shape=10, use_redz=True)" + "\n", + "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", + " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " return num\n", + "def integrate_qq(dnum, edges): # integrate dN/dq\n", + " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", + " return num\n", + "def integrate_zz(dnum, edges): # dN/dz\n", + " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", + " return num\n", + "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", + " num = dnum*np.diff(np.log(fobs_gw_edges))\n", + " return num " ] }, { @@ -207,46 +210,27 @@ "metadata": {}, "outputs": [], "source": [ + "vals = sam_model(hard=holo.hardening.Hard_GW, shape=10)\n", "edges_mm = vals['edges'][0]\n", "cents_mm = utils.midpoints(edges_mm, log=True)\n", "edges_qq = vals['edges'][1]\n", "cents_qq = utils.midpoints(edges_qq, log=True)\n", "edges_zz = vals['edges'][2]\n", "cents_zz = utils.midpoints(edges_zz, log=True)\n", - "dnum = vals['diff_num']\n", + "diff_num = vals['diff_num']\n", "\n", "np.set_printoptions(precision=3)\n", "print('M edges (g)', edges_mm)\n", "print('q edges', edges_qq)\n", - "print('z edges', edges_zz)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", - " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", - " return num\n", - "def integrate_qq(dnum, edges): # integrate dN/dq\n", - " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", - " return num\n", - "def integrate_zz(dnum, edges): # dN/dz\n", - " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", - " return num\n", - "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", - " num = dnum*np.diff(np.log(fobs_gw_edges))\n", - " return num \n", + "print('z edges', edges_zz)\n", + "\n", "\n", - "dnum = vals['diff_num']\n", "edges = vals['edges']\n", "fobs_gw_edges = vals['fobs_gw_edges']\n", "fobs_gw_cents = vals['fobs_gw_cents']\n", - "dnum_mm = integrate_ff(integrate_zz(integrate_qq(dnum, edges), edges), fobs_gw_edges)\n", - "dnum_qq = integrate_ff(integrate_qq(integrate_mm(dnum, edges), edges), fobs_gw_edges)\n", - "dnum_zz = integrate_ff(integrate_qq(integrate_mm(dnum, edges), edges), fobs_gw_edges)\n", + "dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + "dnum_qq = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + "dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", "print(dnum_mm.shape, dnum_qq.shape, dnum_zz.shape)" ] }, @@ -256,34 +240,9 @@ "metadata": {}, "outputs": [], "source": [ - "qq=5\n", - "mm=7\n", - "zz=5\n", - "ff=1\n", - "\n", - "fig, axs = holo.plot.figax(\n", - " xlabel='edge parameters',\n", - " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", - " ncols=3, figsize=(16,5),\n", - " sharey=True\n", - ")\n", - "\n", - "xx = np.array([edges_mm/MSOL, edges_qq, edges_zz])\n", - "yy = np.array([dnum_mm[:,qq,zz,ff], dnum[mm,:,zz,ff], dnum[:,qq,zz,ff]])\n", - "labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", - " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", - " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", - "xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", - "ylabels = np.array(['$dN/d\\log (M)$', '$dN/dq$', '$dN/dz$'])\n", - "\n", - "for ii, ax in enumerate(axs):\n", - " ax.plot(xx[ii], yy[ii], label=labels[ii] \n", - " )\n", - " ax.set_xlabel(xlabels[ii])\n", - " ax.set_ylabel(ylabels[ii])\n", - " ax.legend(loc='lower left')\n", - "\n", - "fig.tight_layout" + "print(edges_zz.flatten().shape)\n", + "plt.scatter(np.arange(len(edges_zz)), edges_zz)\n", + "plt.yscale('log')" ] }, { @@ -291,7 +250,56 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def plot_dnum_dpar(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(18,5),\n", + " sharey=True\n", + " )\n", + "\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$dN/d\\log (M)$', '$dN/dq$', '$dN/dz$'])\n", + "\n", + " xx = np.array([edges_mm/MSOL, edges_qq, edges_zz])\n", + "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " yy = np.array([dnum_mm[:,qq,zz,ff], dnum_qq[mm,:,zz,ff], dnum_zz[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy[ii], label=labels[ii], alpha=0.75, \n", + " )\n", + " for ii, ax in enumerate(axs): \n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend(loc='upper right')\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout\n", + " return fig\n", + "\n", + "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[7,], zz_arr=[7], ff_arr=[2,32])" + ] }, { "cell_type": "code", @@ -299,18 +307,20 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_numbers(vals, mm=8, qq=5, zz=8, ff=1):\n", - " dnum = vals['diff_num']\n", + "def plot_number(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", " edges_mm = vals['edges'][0]\n", " cents_mm = utils.midpoints(edges_mm, log=True)\n", " edges_qq = vals['edges'][1]\n", " cents_qq = utils.midpoints(edges_qq, log=True)\n", " edges_zz = vals['edges'][2]\n", " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", "\n", " cynum = vals['number']\n", " tznum = integrate_zz(dnum_zz, edges)\n", - " utnum = utils._integrate_grid_differential_number(edges, dnum, freq=False)\n", + " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", "\n", " fig, axs = holo.plot.figax(\n", @@ -319,32 +329,39 @@ " ncols=3, figsize=(16,5),\n", " sharey=True\n", " )\n", - "\n", - " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", - " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[:,qq,zz,ff]])\n", - " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[:,qq,zz,ff]])\n", - " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[:,qq,zz,ff]])\n", - " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", - " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", - " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", " ylabels = np.array(['$N (M)$', '$N(q)$', '$N(z)$'])\n", "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " \n", + " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[mm,qq,:,ff]])\n", + " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[mm,qq,:,ff]])\n", + " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_cyth[ii], label=labels[ii]+' cython', linestyle='-', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_trap[ii], label=labels[ii]+' trapz', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", + " )\n", " for ii, ax in enumerate(axs):\n", - " ax.plot(xx[ii], yy_cyth[ii], label=labels[ii]+' cython', linestyle='-', alpha=0.75 \n", - " )\n", - " ax.plot(xx[ii], yy_trap[ii], label=labels[ii]+' trapz', linestyle='--', alpha=0.75 \n", - " )\n", - " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", - " )\n", " ax.set_xlabel(xlabels[ii])\n", " ax.set_ylabel(ylabels[ii])\n", " ax.legend()\n", "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", " fig.tight_layout\n", " return fig\n", "\n", - "fig = plot_numbers(vals)" + "fig = plot_number(vals, mm_arr=[7], qq_arr=[7,], zz_arr=[7], ff_arr=[32])" ] }, { @@ -361,7 +378,7 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_strain_amp(vals, mm=7, qq=5, zz=5, ff=1):\n", + "def plot_strain_amp(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", " # dnum = vals['diff_num']\n", " edges = vals['edges']\n", " edges_mm = vals['edges'][0]\n", @@ -384,27 +401,63 @@ " )\n", "\n", " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", - " yy_initz = np.array([hs_initz[:,qq,zz,ff], hs_initz[mm,:,zz,ff], hs_initz[:,qq,zz,ff]])\n", - " yy_final = np.array([hs_final[:,qq,zz,ff], hs_final[mm,:,zz,ff], hs_final[:,qq,zz,ff]])\n", - " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", - " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", - " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", " ylabels = np.array(['$h_s (M)$', '$h_s(q)$', '$h_s(z)$'])\n", "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " yy_initz = np.array([hs_initz[:,qq,zz,ff], hs_initz[mm,:,zz,ff], hs_initz[mm,qq,:,ff]])\n", + " yy_final = np.array([hs_final[:,qq,zz,ff], hs_final[mm,:,zz,ff], hs_final[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_initz[ii], label=labels[ii]+' initial z', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_final[ii], label=labels[ii]+' final z', linestyle='-', alpha=0.75 \n", + " )\n", " for ii, ax in enumerate(axs):\n", - " ax.plot(xx[ii], yy_initz[ii], label=labels[ii]+' initial z', linestyle='-', alpha=0.75 \n", - " )\n", - " ax.plot(xx[ii], yy_final[ii], label=labels[ii]+' final z', linestyle='--', alpha=0.75 \n", - " )\n", " ax.set_xlabel(xlabels[ii])\n", " ax.set_ylabel(ylabels[ii])\n", " ax.legend()\n", "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", " fig.tight_layout\n", " return fig\n", "\n", - "fig = plot_strain_amp(vals)" + "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[7,], zz_arr=[5], ff_arr=[1,8,])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# All together" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", + "vals = sam_model(hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR), shape=20, use_redz=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", + "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])" ] }, { @@ -415,7 +468,7 @@ "# Comparing strain amplitude for initial/final redz\n", "\n", "conclusion: \n", - "hs differences are almost negligible UNLESS hs_final is just 0 because redz_final has become -1 (never reaches GW emission)\n" + "hs differences are almost negligible UNLESS hs_final is just 0 because redz_final has become -1 (never reaches GW emission). This cuts off the loudest sources, which have the lowest redshifts and largest masses.\n" ] }, { @@ -426,7 +479,8 @@ "source": [ "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", "vals = sam_model(hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR), shape=20, use_redz=True)\n", - "fig = plot_strain_amp(vals, mm=18, qq=18, zz=15, ff=32)" + "fig = plot_strain_amp(vals, mm=14, qq=18, zz=15, ff=32)\n", + "fig.axes[0].set_ylim(10**-16, 10**-11)" ] }, { diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 425a2cd4..6419089a 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -266,7 +266,7 @@ def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False, floor = Fa return C0, Cl -def strain_amp_at_bin_edges(edges, redz=None): +def strain_amp_at_bin_edges_redz(edges, redz=None): """ Calculate strain amplitude at bin edges, with final or initial redz. """ @@ -359,7 +359,7 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): if realize is False: - hs_edges = strain_amp_at_bin_edges(edges, redz) + hs_edges = strain_amp_at_bin_edges_redz(edges, redz) # ---- integrate from differential-number to number per bin # integrate over dlog10(M) From e8587e86863dbb8adf4f88ceda8fa6b37c1f1853 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 00:05:01 -0700 Subject: [PATCH 014/291] Added utils function for midpoints over multiple specified axis --- holodeck/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/holodeck/utils.py b/holodeck/utils.py index cd6ac563..fc219dcc 100644 --- a/holodeck/utils.py +++ b/holodeck/utils.py @@ -640,6 +640,10 @@ def midpoints(vals, axis=-1, log=False): mm = np.moveaxis(mm, 0, axis) return mm +def midpoints_multiax(vals, axis, log=False): + for aa in axis: + vals = midpoints(vals, aa, log=log) + return vals def minmax(vals: npt.ArrayLike, filter: bool = False) -> np.ndarray: """Find the minimum and maximum values in the given array. From 90c8c5d3e6621e9b8389058a7db23ad11d047dbf Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 00:05:48 -0700 Subject: [PATCH 015/291] Plotting int(dnum*h^2) vs h^2*int(dnum) for each 1d edge dnum in analytic_investigation.ipynb. --- .../anisotropy/analytic_investigation.ipynb | 200 +++++++++++++++++- 1 file changed, 193 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb index f3b8b31e..a01bd07f 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -157,20 +157,19 @@ "metadata": {}, "outputs": [], "source": [ - "def sam_model(\n", - " hard = holo.hardening.Hard_GW(), shape=20, \n", + "def sam_model(sam, hard,\n", " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", " fobs_orb_cents = fobs_gw_cents/2.0\n", " fobs_orb_edges = fobs_gw_edges/2.0\n", "\n", - " hard = holo.hardening.Hard_GW()\n", - " sam = holo.sam.Semi_Analytic_Model(shape=shape)\n", " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", " hard_name = 'Fixed Time'\n", " elif isinstance(hard, holo.hardening.Hard_GW):\n", " hard_name = 'GW Only'\n", + " else:\n", + " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", "\n", " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", " fobs_orb_cents, sam, hard, holo.cosmo)\n", @@ -210,7 +209,8 @@ "metadata": {}, "outputs": [], "source": [ - "vals = sam_model(hard=holo.hardening.Hard_GW, shape=10)\n", + "sam = holo.sam.Semi_Analytic_Model(shape=10)\n", + "vals = sam_model(sam, hard=holo.hardening.Hard_GW())\n", "edges_mm = vals['edges'][0]\n", "cents_mm = utils.midpoints(edges_mm, log=True)\n", "edges_qq = vals['edges'][1]\n", @@ -431,6 +431,176 @@ "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[7,], zz_arr=[5], ff_arr=[1,8,])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_number_times_h2(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " hs_cents = vals['hs_cents']\n", + "\n", + " cynum = vals['number']*hs_cents**2\n", + " tznum = integrate_zz(dnum_zz, edges)*hs_cents**2\n", + " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " utnum = utnum * np.diff(np.log(fobs_gw_edges))*hs_cents**2\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array([r'$N (M)\\times h_s^2$', r'$N(q)\\times h_s^2$', r'$N(z)\\times h_s^2$'])\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " \n", + " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[mm,qq,:,ff]])\n", + " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[mm,qq,:,ff]])\n", + " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_cyth[ii], label=labels[ii]+' cython', linestyle='-', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_trap[ii], label=labels[ii]+' trapz', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", + " )\n", + " for ii, ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout\n", + " return fig\n", + "\n", + "fig = plot_number_times_h2(vals, mm_arr=[6,], qq_arr=[7,], zz_arr=[5], ff_arr=[1,8,])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "def plot_integrated(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + " hs_cents = vals['hs_cents']\n", + " hs_edges = vals['hs_edges']\n", + "\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", + " numh4_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", + " print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", + "\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " print('dnum_qq:', dnum_qq.shape)\n", + " print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", + " numh2_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", + " numh4_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**4, edges)\n", + " \n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**2, edges)\n", + " numh4_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**4, edges)\n", + "\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels_h2 = np.array(['$\\int h_s^2 dN/d\\log (M)$', '$\\int h_s^2 dN/dq$', '$\\int h_s^2 dN/dz$'])\n", + " ylabels_h4 = np.array(['$\\int h_s^4 dN/d\\log (M)$', '$\\int h_s^4 dN/dq$', '$\\int h_s^4 dN/dz$'])\n", + "\n", + " cynum = vals['number']\n", + " numh2_cy = cynum*hs_cents**2\n", + " numh4_cy = cynum*hs_cents**4\n", + " # tznum = integrate_zz(dnum_zz, edges)\n", + " # utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " # utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, figsize=(16,8))\n", + "\n", + "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " yy_h2 = np.array([numh2_mm[:,qq,zz,ff], numh2_qq[mm,:,zz,ff], numh2_zz[mm,qq,:,ff]])\n", + " yy_h4 = np.array([numh4_mm[:,qq,zz,ff], numh4_qq[mm,:,zz,ff], numh4_zz[mm,qq,:,ff]])\n", + " cy_h2 = np.array([numh2_cy[:,qq,zz,ff], numh2_cy[mm,:,zz,ff], numh2_cy[mm,qq,:,ff]])\n", + " cy_h4 = np.array([numh4_cy[:,qq,zz,ff], numh4_cy[mm,:,zz,ff], numh4_cy[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs[0,:]): # h2\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " else: cylabel=None\n", + " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " cc = ll.get_color()\n", + " ax.plot(xx[ii], yy_h2[ii], label=labels[ii], linestyle='--', alpha=0.75, color=cc \n", + " )\n", + " for ii, ax in enumerate(axs[1,:]): # h4\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " else: cylabel=None\n", + " ll, = ax.plot(xx[ii], cy_h4[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " cc = ll.get_color()\n", + " ax.plot(xx[ii], yy_h4[ii], label=labels[ii], linestyle='--', alpha=0.75, color=cc )\n", + " \n", + " \n", + "\n", + " for ii, ax in enumerate(axs[0,:]):\n", + " ax.set_ylabel(ylabels_h2[ii])\n", + " # if ii>0: ax.sharey(axs[0,0])\n", + " ax.legend(fontsize=8)\n", + " for ii, ax in enumerate(axs[1,:]):\n", + " ax.set_ylabel(ylabels_h4[ii])\n", + " ax.set_xlabel(xlabels[ii])\n", + " # if ii>0: ax.sharey(axs[1,0])\n", + " ax.sharex(axs[0,ii])\n", + " ax.legend(fontsize=8)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_integrated(vals, mm_arr=[3,6,7], qq_arr=[-1,], zz_arr=[7,], ff_arr=[20])" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -446,7 +616,8 @@ "outputs": [], "source": [ "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", - "vals = sam_model(hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR), shape=20, use_redz=True)" + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", + "print(vals['hard_name'])" ] }, { @@ -457,9 +628,24 @@ "source": [ "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", - "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])" + "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])\n", + "fig = plot_integrated(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "attachments": {}, "cell_type": "markdown", From cf4abf805b666a7cb3dadc70b45626de76fb04f2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 00:16:13 -0700 Subject: [PATCH 016/291] More plots comparing hard_GW model. --- .../anisotropy/analytic_investigation.ipynb | 49 +++++++++++++++++-- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb index a01bd07f..21e4b4e4 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -595,6 +595,7 @@ " ax.sharex(axs[0,ii])\n", " ax.legend(fontsize=8)\n", "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", " fig.tight_layout()\n", " return fig\n", "\n", @@ -606,7 +607,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# All together" + "# All together, fixed time model" ] }, { @@ -629,7 +630,7 @@ "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])\n", - "fig = plot_integrated(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" ] }, { @@ -637,7 +638,49 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[5,17,], ff_arr=[32,])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# All together, GW Only" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Hard_GW())\n", + "print(vals['hard_name'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", + "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])\n", + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[5,17,], ff_arr=[32,])" + ] }, { "cell_type": "code", From 452d881c8cf4b691d8bba415cc91e119df9d6044 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 15:41:25 -0700 Subject: [PATCH 017/291] More plots, including floor rounding of numbers. --- .../anisotropy/analytic_investigation.ipynb | 186 ++++++++++++------ 1 file changed, 127 insertions(+), 59 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation.ipynb index 21e4b4e4..0988a14d 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation.ipynb @@ -42,36 +42,73 @@ "metadata": {}, "outputs": [], "source": [ + "\n", "nbins = 10\n", "\n", "# redshift edges 0.01 to 1\n", - "edges = np.geomspace(10**-2, 10**1, nbins+1) # z bins\n", + "edges = np.geomspace(10**-3, 10**1, nbins+1) # z bins\n", "print('z edges:', edges)\n", "\n", - "# dnum up to order 10^5, 10^6\n", - "dnum = np.geomspace(10**6, 10**0, nbins+1) # d^2N / dz dlnf \n", - "print('dnum:', dnum)\n", - "if(dnum[0]>dnum[-1]):\n", - " dnum_str = 'dnum decreasing'\n", - "else: \n", - " dnum_str = 'dnum increasing'\n", "\n", - "# num \n", - "num = holo.utils.trapz(dnum, edges)\n", - "print('num:', num)\n", + "def setup(\n", + " dnum = np.geomspace(10**0, 10**6, nbins+1), # d^2N / dz dlnf \n", + " hs_exp_edges = np.linspace(-20, -15, nbins+1), \n", + "):\n", + " print('dnum:', dnum)\n", + " if(dnum[0]>dnum[-1]):\n", + " dnum_str = 'dnum decreasing'\n", + " else: \n", + " dnum_str = 'dnum increasing'\n", + "\n", + " # num \n", + " num = holo.utils.trapz(dnum, edges)\n", + " print('num:', num)\n", + "\n", + " # hs up to 10^-15\n", + " hs_exp_cents = holo.utils.midpoints(hs_exp_edges)\n", + "\n", + " hs_edges = 10**hs_exp_edges\n", + " hs_cents = 10**hs_exp_cents\n", + " if(hs_cents[0]>hs_cents[-1]):\n", + " hs_str = 'hs decreasing'\n", + " else:\n", + " hs_str = 'hs increasing'\n", + " print('hs_cents:', hs_cents)\n", + " print('hs_edges:', hs_edges)\n", + "\n", + " numh2 = num*hs_cents**2\n", + " numh4 = num*hs_cents**4\n", + "\n", + " dnumh2 = dnum*hs_edges**2\n", + " inth2 = holo.utils.trapz(dnumh2, edges, cumsum=False)\n", + "\n", + " dnumh4 = dnum*hs_edges**4\n", + " inth4 = holo.utils.trapz(dnumh4, edges, cumsum=False)\n", + "\n", + " return num, dnum, hs_cents, dnum_str, hs_str, numh2, numh4, inth2, inth4\n", + "\n", + "\n", + "def plot_integral_vs_z_edges(): # plots using whatever the nb variables r set to\n", + " fig, (ax1, ax2) = holo.plot.figax(ncols=2, figsize=(12,5),\n", + " xlabel='z edges', ylabel='integral')\n", + " # ax.plot(edges[:-1], inth2, label=r'$\\int(\\mathrm{dnum}*h^2)$')\n", + " # ax.plot(edges[:-1], numh2, label=r'$h^2* \\int(\\mathrm{dnum})$')\n", "\n", - "# hs up to 10^-15\n", - "hs_exp_edges = np.linspace(-20, -15, nbins+1) \n", - "hs_exp_cents = holo.utils.midpoints(hs_exp_edges)\n", + " ax1.plot(edges[:-1], inth2, label=r'$\\int(\\mathrm{dnum}*h^2)$')\n", + " ax1.plot(edges[:-1], numh2, label=r'$h^2* \\int(\\mathrm{dnum})$')\n", + " ax1.legend()\n", "\n", - "hs_edges = 10**hs_exp_edges\n", - "hs_cents = 10**hs_exp_cents\n", - "if(hs_cents[0]>hs_cents[-1]):\n", - " hs_str = 'hs decreasing'\n", - "else:\n", - " hs_str = 'hs increasing'\n", - "print('hs_cents:', hs_cents)\n", - "print('hs_edges:', hs_edges)\n" + " ax2.plot(edges[:-1], inth4, label=r'$\\int(\\mathrm{dnum}*h^4)$')\n", + " ax2.plot(edges[:-1], numh4, label=r'$h^4* \\int(\\mathrm{dnum})$')\n", + " ax2.legend()\n", + " \n", + " fig.suptitle('nbins=%d, z increasing -> %s (%.2e to %.2e) and %s (%.2e to %.2e)' \n", + " % (nbins, dnum_str, dnum[0], dnum[-1], hs_str, hs_cents[0], hs_cents[-1]),\n", + " fontsize=12)\n", + " fig.tight_layout()\n", + " # ax2.set_title('z increasing -> %s and %s' % (dnum_str, hs_str))\n", + "\n", + " return fig\n" ] }, { @@ -80,14 +117,11 @@ "metadata": {}, "outputs": [], "source": [ - "numh2 = num*hs_cents**2\n", - "numh4 = num*hs_cents**4\n", "\n", - "dnumh2 = dnum*hs_edges**2\n", - "inth2 = holo.utils.trapz(dnumh2, edges)\n", - "\n", - "dnumh4 = dnum*hs_edges**4\n", - "inth4 = holo.utils.trapz(dnumh4, edges)" + "num, dnum, hs_cents, dnum_str, hs_str, numh2, numh4, inth2, inth4 = setup(\n", + " dnum = np.geomspace(10**1, 10**2, nbins+1), # d^2N / dz dlnf \n", + " hs_exp_edges = np.linspace(-17, -16.5, nbins+1), )\n", + "fig=plot_integral_vs_z_edges()" ] }, { @@ -96,15 +130,10 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = holo.plot.figax(xlabel='z edges', ylabel='integral')\n", - "\n", - "ax.plot(edges[:-1], inth2, label=r'$\\int(\\mathrm{dnum}*h^2)$')\n", - "ax.plot(edges[:-1], numh2, label=r'$h^2* \\int(\\mathrm{dnum})$')\n", - "# ax.plot(edges[:-1], inth4, label=r'$\\int(\\mathrm{dnum}*h^4)$')\n", - "# ax.plot(edges[:-1], numh4, label=r'$h^4* \\int(\\mathrm{dnum})$')\n", - "\n", - "ax.legend()\n", - "ax.set_title('z increasing -> %s and %s' % (dnum_str, hs_str))" + "num, dnum, hs_cents, dnum_str, hs_str, numh2, numh4, inth2, inth4 = setup(\n", + " dnum = np.geomspace(10**8, 10**-15, nbins+1), # d^2N / dz dlnf \n", + " hs_exp_edges = np.linspace( -10, -35, nbins+1), )\n", + "fig=plot_integral_vs_z_edges()" ] }, { @@ -113,16 +142,22 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = holo.plot.figax(xlabel='z edges', ylabel='integral')\n", - "\n", - "# ax.plot(edges[:-1], inth2, label=r'$\\int(\\mathrm{dnum}*h^2)$')\n", - "# ax.plot(edges[:-1], numh2, label=r'$h^2* \\int(\\mathrm{dnum})$')\n", - "ax.plot(edges[:-1], inth4, label=r'$\\int(\\mathrm{dnum}*h^4)$')\n", - "ax.plot(edges[:-1], numh4, label=r'$h^4* \\int(\\mathrm{dnum})$')\n", - "\n", - "ax.legend()\n", - "\n", - "ax.set_title('z increasing -> %s and %s' % (dnum_str, hs_str))" + "num, dnum, hs_cents, dnum_str, hs_str, numh2, numh4, inth2, inth4 = setup(\n", + " dnum = np.geomspace(10**-5, 10**6, nbins+1), # d^2N / dz dlnf \n", + " hs_exp_edges = np.linspace( -15, -25, nbins+1), )\n", + "fig=plot_integral_vs_z_edges()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "num, dnum, hs_cents, dnum_str, hs_str, numh2, numh4, inth2, inth4 = setup(\n", + " dnum = np.geomspace(10**-3, 10**6, nbins+1), # d^2N / dz dlnf \n", + " hs_exp_edges = np.linspace( -20, -15, nbins+1), )\n", + "fig=plot_integral_vs_z_edges()" ] }, { @@ -301,6 +336,17 @@ "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[7,], zz_arr=[7], ff_arr=[2,32])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "arr = np.linspace(0.5, 3, 10)\n", + "print(arr)\n", + "print(np.floor(arr))" + ] + }, { "cell_type": "code", "execution_count": null, @@ -323,6 +369,8 @@ " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", "\n", + " flnum = np.floor(cynum)\n", + "\n", " fig, axs = holo.plot.figax(\n", " xlabel='edge parameters',\n", " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", @@ -341,6 +389,7 @@ " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[mm,qq,:,ff]])\n", " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[mm,qq,:,ff]])\n", " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[mm,qq,:,ff]])\n", + " yy_flor = np.array([flnum[:,qq,zz,ff], flnum[mm,:,zz,ff], flnum[mm,qq,:,ff]])\n", " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", @@ -352,6 +401,8 @@ " )\n", " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", " )\n", + " ax.plot(xx[ii], yy_flor[ii], label=labels[ii]+' floor', linestyle='-.', alpha=0.75 \n", + " )\n", " for ii, ax in enumerate(axs):\n", " ax.set_xlabel(xlabels[ii])\n", " ax.set_ylabel(ylabels[ii])\n", @@ -544,6 +595,11 @@ " cynum = vals['number']\n", " numh2_cy = cynum*hs_cents**2\n", " numh4_cy = cynum*hs_cents**4\n", + "\n", + "\n", + " flnum = np.floor(cynum)\n", + " numh2_fl = flnum*hs_cents**2\n", + " numh4_fl = flnum*hs_cents**4\n", " # tznum = integrate_zz(dnum_zz, edges)\n", " # utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", " # utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", @@ -562,6 +618,8 @@ " yy_h4 = np.array([numh4_mm[:,qq,zz,ff], numh4_qq[mm,:,zz,ff], numh4_zz[mm,qq,:,ff]])\n", " cy_h2 = np.array([numh2_cy[:,qq,zz,ff], numh2_cy[mm,:,zz,ff], numh2_cy[mm,qq,:,ff]])\n", " cy_h4 = np.array([numh4_cy[:,qq,zz,ff], numh4_cy[mm,:,zz,ff], numh4_cy[mm,qq,:,ff]])\n", + " fl_h2 = np.array([numh2_fl[:,qq,zz,ff], numh2_fl[mm,:,zz,ff], numh2_fl[mm,qq,:,ff]])\n", + " fl_h4 = np.array([numh4_fl[:,qq,zz,ff], numh4_fl[mm,:,zz,ff], numh4_fl[mm,qq,:,ff]])\n", " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", @@ -569,18 +627,28 @@ " for ii, ax in enumerate(axs[0,:]): # h2\n", " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", - " else: cylabel=None\n", - " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " fllabel=r'rounded $h_s^2 \\times \\int dN/dx$'\n", + " else: \n", + " cylabel=None\n", + " fllabel=None\n", + " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.35, lw=4)\n", " cc = ll.get_color()\n", - " ax.plot(xx[ii], yy_h2[ii], label=labels[ii], linestyle='--', alpha=0.75, color=cc \n", - " )\n", + " ax.plot(xx[ii], fl_h2[ii], label=fllabel, linestyle='-', alpha=0.65, color=cc, lw=2)\n", + " ax.plot(xx[ii], yy_h2[ii], label=labels[ii], linestyle='--', alpha=0.75, color=cc, lw=1)\n", " for ii, ax in enumerate(axs[1,:]): # h4\n", " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", - " else: cylabel=None\n", - " ll, = ax.plot(xx[ii], cy_h4[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", - " cc = ll.get_color()\n", - " ax.plot(xx[ii], yy_h4[ii], label=labels[ii], linestyle='--', alpha=0.75, color=cc )\n", + " fllabel=r'rounded $h_s^2 \\times \\int dN/dx$'\n", + " else: \n", + " cylabel=None\n", + " fllabel=None\n", + " # ll, = ax.plot(xx[ii], cy_h4[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " ll = ax.scatter(xx[ii], cy_h4[ii], label=cylabel, marker='o', alpha=0.35, lw=3, s=10)\n", + " # cc = ll.get_color()\n", + " # ax.plot(xx[ii], yy_h4[ii], label=labels[ii], linestyle='x', alpha=0.75, color=cc )\n", + " cc = ll.get_facecolors()\n", + " ax.scatter(xx[ii], fl_h4[ii], label=fllabel, marker='+', alpha=0.65, color=cc)\n", + " ax.scatter(xx[ii], yy_h4[ii], label=labels[ii], marker='x', alpha=0.75, color=cc )\n", " \n", " \n", "\n", @@ -669,7 +737,7 @@ "source": [ "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", - "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])\n", + "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" ] }, @@ -707,8 +775,8 @@ "outputs": [], "source": [ "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", - "vals = sam_model(hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR), shape=20, use_redz=True)\n", - "fig = plot_strain_amp(vals, mm=14, qq=18, zz=15, ff=32)\n", + "vals = sam_model(sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR), use_redz=True)\n", + "fig = plot_strain_amp(vals, mm_arr=[14,], qq_arr=[18,], zz_arr=[15,], ff_arr=[32,])\n", "fig.axes[0].set_ylim(10**-16, 10**-11)" ] }, From 72ceacd4d4bfe44cd76f5dd11a75d0eb9b70ea30 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 16:10:47 -0700 Subject: [PATCH 018/291] Renamed and compared fixed time and gw models for different shapes. --- ...=> analytic_investigation_integrals.ipynb} | 132 ++++++++++++++++-- 1 file changed, 124 insertions(+), 8 deletions(-) rename ecg-notebooks/anisotropy/{analytic_investigation.ipynb => analytic_investigation_integrals.ipynb} (90%) diff --git a/ecg-notebooks/anisotropy/analytic_investigation.ipynb b/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb similarity index 90% rename from ecg-notebooks/anisotropy/analytic_investigation.ipynb rename to ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb index 0988a14d..eabb16f4 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb @@ -724,8 +724,8 @@ "metadata": {}, "outputs": [], "source": [ - "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", - "vals = sam_model(sam=sam, hard=holo.hardening.Hard_GW())\n", + "sam_20=holo.sam.Semi_Analytic_Model(shape=20)\n", + "vals_20GW = sam_model(sam=sam_20, hard=holo.hardening.Hard_GW())\n", "print(vals['hard_name'])" ] }, @@ -735,10 +735,10 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", - "fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", - "fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", - "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" + "fig = plot_dnum_dpar(vals_20GW, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals_20GW, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", + "fig = plot_number(vals_20GW, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "fig = plot_integrated(vals_20GW, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" ] }, { @@ -747,7 +747,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[5,17,], ff_arr=[32,])" + "fig = plot_integrated(vals_20GW, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[2, 32])" ] }, { @@ -755,7 +755,123 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "fig = plot_integrated(vals_20GW, mm_arr=[7,15], qq_arr=[17,], zz_arr=[5,17,], ff_arr=[32,])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Comparing dnum methods" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Full GW Only" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_full = holo.sam.Semi_Analytic_Model(shape=None)\n", + "vals_fullGW = sam_model(sam=sam_full, hard=holo.hardening.Hard_GW())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(vals_fullGW['edges'][2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.plot(np.arange(len(vals_fullGW['edges'][2])), vals_fullGW['edges'][2])\n", + "plt.yscale('log')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals_fullGW, mm_arr=[2,7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals_fullGW, mm_arr=[6,], qq_arr=[17,], zz_arr=[65], ff_arr=[1,8,])\n", + "fig = plot_number(vals_fullGW, mm_arr=[7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_integrated(vals_fullGW, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[65,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_fullGW, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[55,85], ff_arr=[32])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Full Fixed Time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_full = holo.sam.Semi_Analytic_Model(shape=None)\n", + "vals_fullFT = sam_model(sam=sam_full, hard=holo.hardening.Fixed_Time_2PL_SAM(sam_full, 3*GYR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals_fullFT, mm_arr=[2,7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals_fullFT, mm_arr=[6,], qq_arr=[17,], zz_arr=[65], ff_arr=[1,8,])\n", + "fig = plot_number(vals_fullFT, mm_arr=[7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_integrated(vals_fullFT, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[65,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_fullFT, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[55,85], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_fullFT, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[55,85], ff_arr=[32])" + ] }, { "attachments": {}, From 530f5ffb842d44d01a2219993c39fb57cbf7a34c Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 19:17:35 -0700 Subject: [PATCH 019/291] Looking at rounding effect on number*hs^2 in analytic_anisotropy_methods.ipynb. --- .../analytic_anisotropy_methods.ipynb | 398 +++++++++++++++--- 1 file changed, 345 insertions(+), 53 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index 4e01be13..1bfd88c8 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -39,8 +39,89 @@ "dur, cad = 16.03*YR, 0.2*YR\n", "fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", "fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + "fobs_orb_cents = fobs_gw_cents/2.0\n", + "fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", "# sam = holo.sam.Semi_Analytic_Model()\n", - "sam = holo.sam.Semi_Analytic_Model(shape=20) # faster version\n" + "sam_20 = holo.sam.Semi_Analytic_Model(shape=20) # faster version\n", + "hard_FT20 = holo.hardening.Fixed_Time_2PL_SAM(sam_20, 3*GYR)\n", + "\n", + "def setup_calculate_all(sam, hard):\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "\n", + "\n", + " hs = holo.gravwaves.strain_amp_from_bin_edges_redz(edges, redz_final)\n", + " cynum = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " C0_cynum, Cl_cynum = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs)\n", + " C0_cyreals, Cl_cyreals = anis.Cl_analytic_from_num(fobs_orb_edges, cynum, hs, realize=20)\n", + "\n", + " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + " C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", + " C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)\n", + "\n", + " C0_dnum, Cl_dnum = anis.Cl_analytic_from_dnum(edges, diff_num)\n", + " C0_dnum_reals, Cl_dnum_reals = anis.Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", + " C0_redz, Cl_redz = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", + " C0_redz_reals, Cl_redz_reals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)\n", + "\n", + " C0_floor, Cl_floor = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs, realize=False, floor=True)\n", + " flnum = np.floor(cynum)\n", + " C0_flr2, Cl_flr2 = anis.Cl_analytic_from_num(fobs_orb_edges, flnum, hs, realize=False, floor=False)\n", + " \n", + " vals = {\n", + " 'sam':sam, 'hard': hard, 'hard_name':hard_name, 'hs':hs,\n", + " 'edges':edges, 'redz_final':redz_final, 'diff_num':diff_num,\n", + " 'cynum':cynum, 'C0_cynum':C0_cynum, 'Cl_cynum':Cl_cynum, 'Cl_cyreals':Cl_cyreals, 'C0_cyreals':C0_cyreals,\n", + " 'utnum':utnum, 'C0_utnum':C0_utnum, 'Cl_utnum':Cl_utnum, 'Cl_utreals':Cl_utreals, 'C0_utreals':C0_utreals,\n", + " 'C0_dnum':C0_dnum, 'Cl_dnum':Cl_dnum, 'C0_dnum_reals':C0_dnum_reals, 'Cl_dnum_reals':Cl_dnum_reals,\n", + " 'C0_redz':C0_redz, 'Cl_redz':Cl_redz, 'C0_redz_reals':C0_redz_reals, 'Cl_redz_reals':Cl_redz_reals,\n", + " 'flnum':flnum, 'C0_floor':C0_floor, 'Cl_floor':Cl_floor, 'C0_flr2':C0_flr2, 'Cl_flr2':Cl_flr2,\n", + " }\n", + "\n", + "\n", + "\n", + " return vals \n", + "\n", + "vals_FT20 = setup_calculate_all(sam_20, hard_FT20)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Anisotropy" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$ C_\\ell (f) = \\delta_{\\ell 0}\\delta_{m0} \\bigg( \\frac{f}{4\\pi \\Delta f} \\int d \\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^2 (f,\\vec{\\theta}) \\bigg)^2 \n", + "+ \\big( \\frac{f}{4 \\pi \\Delta f}\\big)^2 \\int d\\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^4 (f, \\vec{\\theta})\n", + "$$\n", + "\n", + "\n", + "\n", + "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", + "* dnum = d^4N / dlog10M dq dz dlnf\n", + "* number = dN /dlnf" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + " ### Plot Cl_analytic_from_num()" ] }, { @@ -49,13 +130,54 @@ "metadata": {}, "outputs": [], "source": [ - "fobs_orb_cents = fobs_gw_cents/2.0\n", - "fobs_orb_edges = fobs_gw_edges/2.0\n", - "# hard = holo.hardening.Hard_GW()\n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", - "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", - " fobs_orb_cents, sam, hard, holo.cosmo)\n", - "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]" + "def plot_Cl_analytic_from_num(vals): # uses nb variables\n", + " Cl_cynum = vals['Cl_cynum']\n", + " C0_cynum = vals['C0_cynum']\n", + " Cl_cyreals = vals['Cl_cyreals']\n", + " C0_cyreals = vals['C0_cyreals']\n", + "\n", + " Cl_utnum = vals['Cl_utnum']\n", + " C0_utnum = vals['C0_utnum']\n", + " Cl_utreals = vals['Cl_utreals']\n", + " C0_utreals = vals['C0_utreals']\n", + "\n", + " Cl_floor = vals['Cl_floor']\n", + " C0_floor = vals['C0_floor']\n", + " Cl_flr2 = vals['Cl_flr2']\n", + " C0_flr2 = vals['C0_flr2']\n", + "\n", + " fig1 = anis.plot_ClC0_versions(fobs_gw_cents)\n", + " ax = fig1.axes[0]\n", + " ax.set_title(vals['hard_name']+', '+str(vals['sam'].shape))\n", + "\n", + " anis.draw_analytic(ax, Cl_cynum, C0_cynum, fobs_gw_cents, color='tab:orange', label='cython number', alpha=0.5, lw=4)\n", + " anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", + " anis.draw_analytic(ax, Cl_utnum, C0_utnum, fobs_gw_cents, color='tab:red', label='utils number', alpha=0.5)\n", + " anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", + " show_reals=True, show_median=True, show_ci=True)\n", + "\n", + "\n", + "\n", + " anis.draw_analytic(ax, Cl_floor, C0_floor, fobs_gw_cents, color='tab:blue', label='floor number', alpha=0.5)\n", + "\n", + " anis.draw_analytic(ax, Cl_flr2, C0_flr2, fobs_gw_cents, color='tab:green', label='flr2 number', alpha=0.5, lw=5)\n", + "\n", + " fig1.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", + "\n", + " fig1.tight_layout()\n", + " return fig1\n", + "\n", + "fig = plot_Cl_analytic_from_num(vals_FT20)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot number" ] }, { @@ -64,10 +186,30 @@ "metadata": {}, "outputs": [], "source": [ - "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", - " hard_name = 'Fixed Time'\n", - "elif isinstance(hard, holo.hardening.Hard_GW):\n", - " hard_name = 'GW Only'" + "def plot_num_sums(vals):\n", + " cynum = vals['cynum']\n", + " flnum = vals['flnum']\n", + "\n", + " fig, (ax1, ax2) = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$\\sum_{M,q,z} N$', nrows=2, sharex=True)\n", + "\n", + " xx = fobs_gw_cents\n", + " y1 = np.sum(cynum, axis=(0,1,2))\n", + " y2 = np.sum(flnum, axis=(0,1,2))\n", + " labels = np.array(['number', 'num rounded down'])\n", + "\n", + " for ii,yy in enumerate([y1, y2]):\n", + " ax1.plot(xx, yy, label=labels[ii], alpha=0.5)\n", + " ax1.legend()\n", + " ax1.set_title(vals['hard_name']+', '+str(vals['sam'].shape))\n", + "\n", + "\n", + " ax2.plot(xx, y2/y1, label='rounded / not rounded')\n", + " ax2.legend()\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_num_sums(vals_FT20)" ] }, { @@ -75,7 +217,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Calculate Anisotropy" + "This confirms that using number function is same, regardless which number we use" ] }, { @@ -83,15 +225,65 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "$$ C_\\ell (f) = \\delta_{\\ell 0}\\delta_{m0} \\bigg( \\frac{f}{4\\pi \\Delta f} \\int d \\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^2 (f,\\vec{\\theta}) \\bigg)^2 \n", - "+ \\big( \\frac{f}{4 \\pi \\Delta f}\\big)^2 \\int d\\vec{\\theta} \\frac{d N_{\\Delta f}}{d \\vec{\\theta}} h^4 (f, \\vec{\\theta})\n", - "$$\n", + "### Plot hs^2 and hs^4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_hs2_and_hs4(vals):\n", + " hs = vals['hs']\n", + " \n", + " xx = fobs_gw_cents\n", + " y1 = np.sum(hs**2, axis=(0,1,2))\n", + " y2 = np.sum(hs**4, axis=(0,1,2))\n", + " labels = np.array(['$\\sum_{M,q,z} h_s^2$', '$\\sum_{M,q,z} h_s^4$'])\n", "\n", + " fig, axs = plot.figax(ncols=2,figsize=(8.5,3),\n", + " xlabel=plot.LABEL_GW_FREQUENCY_HZ, sharex=True\n", + " \n", + " )\n", + " for ii, yy in enumerate([y1, y2]):\n", + " axs[ii].scatter(xx, yy)\n", + " axs[ii].set_ylabel(labels[ii])\n", + " fig.tight_layout()\n", "\n", + " return fig\n", "\n", - "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", - "* dnum = d^4N / dlog10M dq dz dlnf\n", - "* number = dN /dlnf" + "def plot_numh2_and_numh4(vals):\n", + " hs = vals['hs']\n", + " cynum = vals['cynum']\n", + " flnum = vals['flnum']\n", + " \n", + " xx = fobs_gw_cents\n", + " cy1 = np.sum(hs**2*cynum, axis=(0,1,2))\n", + " cy2 = np.sum(hs**4*cynum, axis=(0,1,2))\n", + " yy_cy = np.array([cy1, cy2])\n", + " fl1 = np.sum(hs**2*flnum, axis=(0,1,2))\n", + " fl2 = np.sum(hs**4*flnum, axis=(0,1,2))\n", + " yy_fl = np.array([fl1, fl2])\n", + " cylabel = 'num'\n", + " fllabel = 'rounded'\n", + " ylabels = np.array(['$\\sum_{M,q,z} N h_s^2$', '$\\sum_{M,q,z} N h_s^4$'])\n", + "\n", + " fig, axs = plot.figax(ncols=2,figsize=(8.5,3),\n", + " xlabel=plot.LABEL_GW_FREQUENCY_HZ, sharex=True\n", + " \n", + " )\n", + " for ii, ax in enumerate(axs):\n", + " ax.scatter(xx, yy_cy[ii], label=cylabel)\n", + " ax.scatter(xx, yy_fl[ii], label=fllabel)\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = plot_hs2_and_hs4(vals_FT20)\n", + "fig = plot_numh2_and_numh4(vals_FT20)\n" ] }, { @@ -99,7 +291,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - " ## Cl_analytic_from_num()" + "#### FT, Shape 20" ] }, { @@ -108,16 +300,19 @@ "metadata": {}, "outputs": [], "source": [ - "hs = holo.gravwaves.strain_amp_from_bin_edges_redz(edges, redz_final)\n", - "cynum = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", - "C0_cynum, Cl_cynum = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs)\n", - "C0_cyreals, Cl_cyreals = anis.Cl_analytic_from_num(fobs_orb_edges, cynum, hs, realize=20)\n", - "\n", - "utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", - "utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", - "C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", - "C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)\n", - "\n" + "vals = vals_FT20\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_hs2_and_hs4(vals)\n", + "fig = plot_numh2_and_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### FT, Shape 40" ] }, { @@ -126,18 +321,22 @@ "metadata": {}, "outputs": [], "source": [ - "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", - "ax = fig.axes[0]\n", - "\n", - "anis.draw_analytic(ax, Cl_cynum, C0_cynum, fobs_gw_cents, color='tab:orange', label='cython number', alpha=0.5, lw=4)\n", - "anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", - " show_reals=True, show_median=True, show_ci=True)\n", - "\n", - "anis.draw_analytic(ax, Cl_utnum, C0_utnum, fobs_gw_cents, color='tab:red', label='utils number', alpha=0.5)\n", - "anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", - " show_reals=True, show_median=True, show_ci=True)\n", - "\n", - "fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=3)" + "sam_40 = holo.sam.Semi_Analytic_Model(shape=40)\n", + "hard_FT40 = holo.hardening.Fixed_Time_2PL_SAM(sam_40, 3*GYR)\n", + "vals_FT40 = setup_calculate_all(sam_40, hard_FT40)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals_FT40\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_hs2_and_hs4(vals)\n", + "fig = plot_numh2_and_numh4(vals)" ] }, { @@ -145,7 +344,31 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This confirms that using number function is same, regardless which number we use" + "#### FT, Shape full" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_full = holo.sam.Semi_Analytic_Model()\n", + "hard_FTfull = holo.hardening.Fixed_Time_2PL_SAM(sam_full, 3*GYR)\n", + "vals_FTfull = setup_calculate_all(sam_full, hard_FTfull)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals_FTfull\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_hs2_and_hs4(vals)\n", + "fig = plot_numh2_and_numh4(vals)" ] }, { @@ -153,7 +376,37 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Cl_analytic_from_dnum" + "#### GW, Shape 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hard_GW = holo.hardening.Hard_GW()\n", + "vals_GW20 = setup_calculate_all(sam_20, hard_GW)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Cl_analytic_from_num(vals_GW20)\n", + "fig = plot_num_sums(vals_GW20)\n", + "fig = plot_hs2_and_hs4(vals_GW20)\n", + "fig = plot_numh2_and_numh4(vals_GW20)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### GW, Shape 40" ] }, { @@ -162,10 +415,7 @@ "metadata": {}, "outputs": [], "source": [ - "C0_dnum, Cl_dnum = anis.Cl_analytic_from_dnum(edges, diff_num)\n", - "C0_dnum_reals, Cl_dnum_reals = anis.Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", - "C0_redz, Cl_redz = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", - "C0_redz_reals, Cl_redz_reals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)" + "vals_GW40 = setup_calculate_all(sam_40, hard_GW)" ] }, { @@ -174,8 +424,28 @@ "metadata": {}, "outputs": [], "source": [ - "arr = np.array([1,2,3,4,])\n", - "print(arr[:,np.newaxis].shape)" + "vals = vals_GW40\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_hs2_and_hs4(vals)\n", + "fig = plot_numh2_and_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### GW, Shape full" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals_GWfull = setup_calculate_all(sam_full, hard_GW)" ] }, { @@ -184,8 +454,19 @@ "metadata": {}, "outputs": [], "source": [ - "print(C0_dnum.shape)\n", - "print(C0_dnum_reals.shape)" + "vals = vals_GWfull\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_hs2_and_hs4(vals)\n", + "fig = plot_numh2_and_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Cl_analytic_from_dnum" ] }, { @@ -202,6 +483,16 @@ "metadata": {}, "outputs": [], "source": [ + "\n", + "C0_dnum = vals_FT20['C0_dnum']\n", + "Cl_dnum = vals_FT20['Cl_dnum']\n", + "C0_dnum_reals = vals_FT20['C0_dnum_reals']\n", + "Cl_dnum_reals = vals_FT20['Cl_dnum_reals']\n", + "C0_redz = vals_FT20[ 'C0_redz']\n", + "Cl_redz = vals_FT20['Cl_redz']\n", + "C0_redz_reals = vals_FT20['C0_redz_reals'] \n", + "Cl_redz_reals = vals_FT20['Cl_redz_reals']\n", + "\n", "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", "ax = fig.axes[0]\n", "\n", @@ -315,6 +606,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -387,7 +679,7 @@ "metadata": {}, "outputs": [], "source": [ - "plt.loglog(edges[0][:-1], hs[:,0,18,5])" + "# plt.loglog(edges[0][:-1], hs[:,0,18,5])" ] }, { From 32a4ba5be5e06fd42ba12af9a535ae581bd7f5f3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 22:29:26 -0700 Subject: [PATCH 020/291] New plots comparing different dnums and rounded methods, for every model and shape combo, automated in analytic_anisotropy_methods.ipynb. --- .../analytic_anisotropy_methods.ipynb | 236 ++++++++++-------- .../analytic_investigation_integrals.ipynb | 3 +- 2 files changed, 137 insertions(+), 102 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index 1bfd88c8..22360cf1 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -238,20 +238,25 @@ " hs = vals['hs']\n", " \n", " xx = fobs_gw_cents\n", + " fig, axs = plot.figax(ncols=2,figsize=(8.5,3),\n", + " xlabel=plot.LABEL_GW_FREQUENCY_HZ, sharex=True)\n", + " \n", + " draw_hs2_hs4(axs, xx, hs)\n", + " axs[0].set_title(vals['hard_name']+', '+str(vals['sam'].shape))\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + " \n", + "\n", + "def draw_hs2_hs4(axs, xx, hs):\n", " y1 = np.sum(hs**2, axis=(0,1,2))\n", " y2 = np.sum(hs**4, axis=(0,1,2))\n", " labels = np.array(['$\\sum_{M,q,z} h_s^2$', '$\\sum_{M,q,z} h_s^4$'])\n", "\n", - " fig, axs = plot.figax(ncols=2,figsize=(8.5,3),\n", - " xlabel=plot.LABEL_GW_FREQUENCY_HZ, sharex=True\n", - " \n", - " )\n", + "\n", " for ii, yy in enumerate([y1, y2]):\n", " axs[ii].scatter(xx, yy)\n", " axs[ii].set_ylabel(labels[ii])\n", - " fig.tight_layout()\n", - "\n", - " return fig\n", "\n", "def plot_numh2_and_numh4(vals):\n", " hs = vals['hs']\n", @@ -259,6 +264,15 @@ " flnum = vals['flnum']\n", " \n", " xx = fobs_gw_cents\n", + " fig, axs = plot.figax(ncols=2,figsize=(8.5,3),\n", + " xlabel=plot.LABEL_GW_FREQUENCY_HZ, sharex=True)\n", + "\n", + " draw_numh2_numh4(axs, xx, hs, cynum, flnum)\n", + " axs[0].set_title(vals['hard_name']+', '+str(vals['sam'].shape))\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "def draw_numh2_numh4(axs, xx, hs, cynum, flnum):\n", " cy1 = np.sum(hs**2*cynum, axis=(0,1,2))\n", " cy2 = np.sum(hs**4*cynum, axis=(0,1,2))\n", " yy_cy = np.array([cy1, cy2])\n", @@ -269,21 +283,35 @@ " fllabel = 'rounded'\n", " ylabels = np.array(['$\\sum_{M,q,z} N h_s^2$', '$\\sum_{M,q,z} N h_s^4$'])\n", "\n", - " fig, axs = plot.figax(ncols=2,figsize=(8.5,3),\n", - " xlabel=plot.LABEL_GW_FREQUENCY_HZ, sharex=True\n", - " \n", - " )\n", + "\n", " for ii, ax in enumerate(axs):\n", " ax.scatter(xx, yy_cy[ii], label=cylabel)\n", " ax.scatter(xx, yy_fl[ii], label=fllabel)\n", " ax.set_ylabel(ylabels[ii])\n", " ax.legend()\n", - " fig.tight_layout()\n", "\n", + "def plot_h2_h4_numh2_numh4(vals):\n", + " hs = vals['hs']\n", + " cynum = vals['cynum']\n", + " flnum = vals['flnum']\n", + " \n", + " xx = fobs_gw_cents\n", + " fig, axs = plot.figax(ncols=2,nrows=2, figsize=(8.5,4.5),\n", + " sharex=True) \n", + " for ax in axs[1,:]:\n", + " ax.set_xlabel(plot.LABEL_GW_FREQUENCY_HZ)\n", + " draw_hs2_hs4(axs[0,:], xx, hs)\n", + " draw_numh2_numh4(axs[1,:], xx, hs, cynum, flnum)\n", + " axs[0,0].set_title(vals['hard_name']+', '+str(vals['sam'].shape))\n", + " \n", + " fig.tight_layout()\n", " return fig\n", "\n", + "\n", + "\n", "fig = plot_hs2_and_hs4(vals_FT20)\n", - "fig = plot_numh2_and_numh4(vals_FT20)\n" + "fig = plot_numh2_and_numh4(vals_FT20)\n", + "fig = plot_h2_h4_numh2_numh4(vals_FT20)\n" ] }, { @@ -303,8 +331,9 @@ "vals = vals_FT20\n", "fig = plot_Cl_analytic_from_num(vals)\n", "fig = plot_num_sums(vals)\n", - "fig = plot_hs2_and_hs4(vals)\n", - "fig = plot_numh2_and_numh4(vals)" + "# fig = plot_hs2_and_hs4(vals)\n", + "# fig = plot_numh2_and_numh4(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)\n" ] }, { @@ -335,8 +364,9 @@ "vals = vals_FT40\n", "fig = plot_Cl_analytic_from_num(vals)\n", "fig = plot_num_sums(vals)\n", - "fig = plot_hs2_and_hs4(vals)\n", - "fig = plot_numh2_and_numh4(vals)" + "# fig = plot_hs2_and_hs4(vals)\n", + "# fig = plot_numh2_and_numh4(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" ] }, { @@ -367,8 +397,9 @@ "vals = vals_FTfull\n", "fig = plot_Cl_analytic_from_num(vals)\n", "fig = plot_num_sums(vals)\n", - "fig = plot_hs2_and_hs4(vals)\n", - "fig = plot_numh2_and_numh4(vals)" + "# fig = plot_hs2_and_hs4(vals)\n", + "# fig = plot_numh2_and_numh4(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" ] }, { @@ -395,10 +426,12 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_Cl_analytic_from_num(vals_GW20)\n", - "fig = plot_num_sums(vals_GW20)\n", - "fig = plot_hs2_and_hs4(vals_GW20)\n", - "fig = plot_numh2_and_numh4(vals_GW20)" + "vals = vals_GW20\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "# fig = plot_hs2_and_hs4(vals)\n", + "# fig = plot_numh2_and_numh4(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" ] }, { @@ -427,8 +460,9 @@ "vals = vals_GW40\n", "fig = plot_Cl_analytic_from_num(vals)\n", "fig = plot_num_sums(vals)\n", - "fig = plot_hs2_and_hs4(vals)\n", - "fig = plot_numh2_and_numh4(vals)" + "# fig = plot_hs2_and_hs4(vals)\n", + "# fig = plot_numh2_and_numh4(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" ] }, { @@ -457,8 +491,9 @@ "vals = vals_GWfull\n", "fig = plot_Cl_analytic_from_num(vals)\n", "fig = plot_num_sums(vals)\n", - "fig = plot_hs2_and_hs4(vals)\n", - "fig = plot_numh2_and_numh4(vals)" + "# fig = plot_hs2_and_hs4(vals)\n", + "# fig = plot_numh2_and_numh4(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" ] }, { @@ -526,10 +561,24 @@ "metadata": {}, "outputs": [], "source": [ - "def compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges):\n", + "sam = holo.sam.Semi_Analytic_Model(shape=10)\n", + "hard = holo.hardening.Hard_GW()\n", + "print(sam._density)\n", + "fobs_orb_cents = fobs_gw_cents/2.0\n", + "fobs_orb_edges = fobs_gw_edges/2.0\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "print(sam._density.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def compare_all_analytic_anis(sam, hard):\n", "\n", - " fobs_orb_cents = fobs_gw_cents/2.0\n", - " fobs_orb_edges = fobs_gw_edges/2.0\n", " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", " fobs_orb_cents, sam, hard, holo.cosmo)\n", " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", @@ -538,29 +587,34 @@ " elif isinstance(hard, holo.hardening.Hard_GW):\n", " hard_name = 'GW Only'\n", "\n", - " # analytic from number\n", + " # analytic from cython number\n", " print('calculating analytic from cython number')\n", " hs = holo.gravwaves.strain_amp_from_bin_edges_redz(edges, redz_final)\n", " cynum = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", " C0_cynum, Cl_cynum = anis.Cl_analytic_from_num(fobs_orb_edges, number=cynum, hs=hs)\n", " C0_cyreals, Cl_cyreals = anis.Cl_analytic_from_num(fobs_orb_edges, cynum, hs, realize=20)\n", "\n", - " # anayltic from cython number\n", - " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", - " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", - " C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", - " C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)\n", + " # # anayltic from utils number\n", + " # utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " # utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + " # C0_utnum, Cl_utnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=utnum, hs=hs)\n", + " # C0_utreals, Cl_utreals = anis.Cl_analytic_from_num(fobs_orb_edges, utnum, hs, realize=20)\n", + "\n", + " # anayltic from floor (rounded) number\n", + " flnum = np.floor(cynum)\n", + " C0_flnum, Cl_flnum = anis.Cl_analytic_from_num(fobs_orb_edges, number=flnum, hs=hs)\n", "\n", - " # analytic from dnum\n", + " # analytic from dnum, zinit\n", " print('calculating analytic from dnum, initial redshift')\n", - " C0_dnum, Cl_dnum = anis.Cl_analytic_from_dnum(edges, diff_num)\n", - " C0_dnum_reals, Cl_dnum_reals = anis.Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", + " C0_init, Cl_init = anis.Cl_analytic_from_dnum(edges, diff_num)\n", + " C0_inreals, Cl_inreals = anis.Cl_analytic_from_dnum(edges, diff_num, realize=10)\n", "\n", + " # analytic from dnum, zfinal\n", " print('calculating analytic from dnum, final redshift')\n", " C0_redz, Cl_redz = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", - " C0_redz_reals, Cl_redz_reals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)\n", + " C0_rzreals, Cl_rzreals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)\n", "\n", - " # plot everything\n", + " # plot everything\n", " print('plotting')\n", " fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", " ax = fig.axes[0]\n", @@ -569,21 +623,31 @@ " anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", " show_reals=True, show_median=True, show_ci=True)\n", "\n", - " anis.draw_analytic(ax, Cl_utnum, C0_utnum, fobs_gw_cents, color='tab:red', label='utils number', lw=3)\n", - " anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", - " show_reals=True, show_median=True, show_ci=True)\n", + " anis.draw_analytic(ax, Cl_flnum, C0_flnum, fobs_gw_cents, color='tab:red', label='rounded number', lw=4)\n", + " # anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", + " # show_reals=True, show_median=True, show_ci=True)\n", "\n", - " anis.draw_analytic(ax, Cl_dnum, C0_dnum, fobs_gw_cents, label='dnum, z_init', color='deeppink', lw=4)\n", - " anis.draw_reals(ax, Cl_dnum_reals, C0_dnum_reals, fobs_gw_cents, label=None, color='deeppink')\n", + " anis.draw_analytic(ax, Cl_init, C0_init, fobs_gw_cents, label='dnum, z_init', color='deeppink', lw=4)\n", + " anis.draw_reals(ax, Cl_inreals, C0_inreals, fobs_gw_cents, label=None, color='deeppink')\n", "\n", " anis.draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='dnum, z_final', color='indigo', lw=4)\n", - " anis.draw_reals(ax, Cl_redz_reals, C0_redz_reals, fobs_gw_cents, label=None, color='indigo')\n", + " anis.draw_reals(ax, Cl_rzreals, C0_rzreals, fobs_gw_cents, label=None, color='indigo')\n", "\n", " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", - " ax.set_title('Shape=%s, %s' % (str(sam.shape), str(hard_name)), fontsize=14)\n", + " ax.set_title('%s, %s' % ( str(hard_name), str(sam.shape)), fontsize=12)\n", "\n", " fig.tight_layout()\n", - " return fig" + "\n", + "\n", + " vals = {\n", + " 'sam':sam, 'hard':hard, 'edges':edges, 'redz_final':redz_final, 'diff_num':diff_num, 'hs':hs,\n", + " 'cynum':cynum, 'C0_cynum':C0_cynum, 'Cl_cynum':Cl_cynum, 'C0_cyreals':C0_cyreals, 'Cl_cyreals':Cl_cyreals, \n", + " 'flnum':flnum, 'C0_flnum':C0_flnum, 'Cl_flnum':Cl_flnum,\n", + " 'C0_init':C0_init, 'Cl_init':Cl_init, 'C0_inreals':C0_inreals, 'Cl_inreals':Cl_inreals,\n", + " 'C0_redz':C0_redz, 'Cl_redz':Cl_redz, 'C0_rzreals':C0_rzreals, 'Cl_rzreals':Cl_rzreals,\n", + "\n", + " }\n", + " return fig, vals" ] }, { @@ -591,7 +655,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Fixed Time, small shape" + "#### FT, Shape 20" ] }, { @@ -600,9 +664,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=20) \n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", - "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + "fig, vals = compare_all_analytic_anis(sam_20, hard_FT20)" ] }, { @@ -610,7 +672,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## GW Only, small shape" + "#### FT, Shape 40" ] }, { @@ -619,10 +681,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=20) \n", - "# sam - holo.sam.Semi_Analytic_Model(mtot=(1.0e4*MSOL, 1.0e12*MSOL, 20), mrat=(1e-3, 1.0, 20), redz=(1e-3, 10.0, 20))\n", - "hard = holo.hardening.Hard_GW()\n", - "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + "fig, vals = compare_all_analytic_anis(sam_40, hard_FT40)" ] }, { @@ -630,7 +689,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Fixed Time, full shape" + "#### FT, Shape full" ] }, { @@ -639,9 +698,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=None) \n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", - "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + "fig, vals = compare_all_analytic_anis(sam_full, hard_FTfull)" ] }, { @@ -649,18 +706,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## GW Only, full shape" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=None) \n", - "hard = holo.hardening.Hard_GW()\n", - "fig = compare_all_analytic_anis(sam, hard, fobs_gw_cents, fobs_gw_edges)" + "#### GW, Shape 20" ] }, { @@ -669,17 +715,15 @@ "metadata": {}, "outputs": [], "source": [ - "print(edges[0].shape)\n", - "print(hs.shape)" + "fig, vals = compare_all_analytic_anis(sam_20, hard_GW)" ] }, { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "# plt.loglog(edges[0][:-1], hs[:,0,18,5])" + "#### GW, Shape 40" ] }, { @@ -688,17 +732,15 @@ "metadata": {}, "outputs": [], "source": [ - "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", - "print(holo.utils.stats(number))" + "fig, vals = compare_all_analytic_anis(sam_40, hard_GW)" ] }, { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "print(np.diff(edges[1]))" + "#### GW, Shape full" ] }, { @@ -707,25 +749,19 @@ "metadata": {}, "outputs": [], "source": [ - "# integrate over log10mass\n", - "num = utils.trapz(diff_num, np.log10(edges[0]), axis=0)\n", - "# integrate over mass-ratio\n", - "num = utils.trapz(num, edges[1], axis=1)\n", - "# # integrate over redshift\n", - "# num = utils.trapz(num, edges[2], axis=2)\n", - "# # times dln(f)\n", - "# numh2 = numh2 * np.diff(np.log(fobs_gw_edges)) \n", - "print(num.shape)\n", - "plt.loglog(edges[2][:], num[10,10,:,10])" + "fig, vals = compare_all_analytic_anis(sam_full, hard_GW)" ] }, { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "plt.loglog(edges[1][:-1], number[10,:,18,10])" + "# Remaining Questions\n", + "\n", + "Why is np.random(number) * hs^2 from Cl_analytic_from_num different from np.random(integral(dnum)) * hs^2 in Cl_analytic_from_dnum?\n", + "\n", + "Because, in Cl_analytic_from_num we take np.random after multiplying by d/dlnf, whereas in Cl_analytic_from_dnum, we are doing an extra *dif(log(fobs)) that we shouldn't be doing!!" ] }, { diff --git a/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb b/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb index eabb16f4..3df1aa31 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb @@ -49,11 +49,10 @@ "edges = np.geomspace(10**-3, 10**1, nbins+1) # z bins\n", "print('z edges:', edges)\n", "\n", - "\n", "def setup(\n", " dnum = np.geomspace(10**0, 10**6, nbins+1), # d^2N / dz dlnf \n", " hs_exp_edges = np.linspace(-20, -15, nbins+1), \n", - "):\n", + " ):\n", " print('dnum:', dnum)\n", " if(dnum[0]>dnum[-1]):\n", " dnum_str = 'dnum decreasing'\n", From 9740722a10dbbfb7a73efc10336f07fa26dd1654 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 4 Jun 2023 23:52:52 -0700 Subject: [PATCH 021/291] Fixed a bug in anisotropy.Cl_analytic_from_dnum() with random realizations. Investigating weird spike in sam (91,81,101) shape in analytic_anisotropy_methods.ipynb. --- .../analytic_anisotropy_methods.ipynb | 369 +++++++++++++++++- holodeck/anisotropy.py | 8 +- 2 files changed, 372 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index 22360cf1..20b0b784 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -698,7 +698,351 @@ "metadata": {}, "outputs": [], "source": [ - "fig, vals = compare_all_analytic_anis(sam_full, hard_FTfull)" + "fig_FTfull, vals_FTfull = compare_all_analytic_anis(sam_full, hard_FTfull)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Weird bump FT shapes\n", + "##### FT, Shape 60\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_60 = holo.sam.Semi_Analytic_Model(shape=60)\n", + "hard_FT60 = holo.hardening.Fixed_Time_2PL_SAM(sam_60, 3*GYR)\n", + "fig_FT60, vals_FT60 = compare_all_analytic_anis(sam_60, hard_FT60)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 70" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_70 = holo.sam.Semi_Analytic_Model(shape=70)\n", + "hard_FT70 = holo.hardening.Fixed_Time_2PL_SAM(sam_70, 3*GYR)\n", + "fig_FT70, vals_FT70 = compare_all_analytic_anis(sam_70, hard_FT70)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 80" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_80 = holo.sam.Semi_Analytic_Model(shape=80)\n", + "hard_FT80 = holo.hardening.Fixed_Time_2PL_SAM(sam_80, 3*GYR)\n", + "fig_FT80, vals_FT80 = compare_all_analytic_anis(sam_80, hard_FT80)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 90,80,100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9080100 = holo.sam.Semi_Analytic_Model(shape=[90,80,100])\n", + "hard_FT9080100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9080100, 3*GYR)\n", + "fig_FT9080100, vals_FT9080100 = compare_all_analytic_anis(sam_9080100, hard_FT9080100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "look at hs and num" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals2_9080100 = setup_calculate_all(sam_9080100, hard_FT9080100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals2_9080100\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 91,81,101" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9181101 = holo.sam.Semi_Analytic_Model(shape=[91,81,101])\n", + "hard_FT9181101 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181101, 3*GYR)\n", + "fig_FT9181101, vals_FT9181101 = compare_all_analytic_anis(sam_9181101, hard_FT9181101)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "look at hs and num" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals2_9181101 = setup_calculate_all(sam_9181101, hard_FT9181101)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals2_9181101\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 91,80,100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9180100 = holo.sam.Semi_Analytic_Model(shape=[91,80,100])\n", + "hard_FT9180100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9180100, 3*GYR)\n", + "fig_FT9180100, vals_FT9180100 = compare_all_analytic_anis(sam_9180100, hard_FT9180100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 90,81,100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9081100 = holo.sam.Semi_Analytic_Model(shape=[90,81,100])\n", + "hard_FT9081100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9081100, 3*GYR)\n", + "fig_FT9081100, vals_FT9180100 = compare_all_analytic_anis(sam_9081100, hard_FT9081100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 90,80,101" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9080101 = holo.sam.Semi_Analytic_Model(shape=[90,80,101])\n", + "hard_FT9080101 = holo.hardening.Fixed_Time_2PL_SAM(sam_9080101, 3*GYR)\n", + "fig_FT9080101, vals_FT9080101 = compare_all_analytic_anis(sam_9080101, hard_FT9080101)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "look at hs and num" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals2_9080101 = setup_calculate_all(sam_9080101, hard_FT9080101)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals2_9080101\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 91,80,101" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9180101 = holo.sam.Semi_Analytic_Model(shape=[91,80,101])\n", + "hard_FT9180101 = holo.hardening.Fixed_Time_2PL_SAM(sam_9180101, 3*GYR)\n", + "fig_FT9180101, vals_FT9180101 = compare_all_analytic_anis(sam_9180101, hard_FT9180101)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "look at hs and num" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals2_9180101 = setup_calculate_all(sam_9180101, hard_FT9180101)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals2_9180101\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##### FT, Shape 91,81,100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9181100 = holo.sam.Semi_Analytic_Model(shape=[91,81,100])\n", + "hard_FT9181100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181100, 3*GYR)\n", + "fig_FT9181100, vals_FT9181100 = compare_all_analytic_anis(sam_9181100, hard_FT9181100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "look at hs and dnum" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals2_9181100 = setup_calculate_all(sam_9181100, hard_FT9181100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = vals2_9181100\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Back to GW" ] }, { @@ -761,9 +1105,30 @@ "\n", "Why is np.random(number) * hs^2 from Cl_analytic_from_num different from np.random(integral(dnum)) * hs^2 in Cl_analytic_from_dnum?\n", "\n", - "Because, in Cl_analytic_from_num we take np.random after multiplying by d/dlnf, whereas in Cl_analytic_from_dnum, we are doing an extra *dif(log(fobs)) that we shouldn't be doing!!" + "Because, in Cl_analytic_from_num we take np.random after multiplying by d/dlnf, whereas in Cl_analytic_from_dnum, we are doing an extra *dif(log(fobs)) that we shouldn't be doing!! Note: both actually do use the cython number because it's faster than integrating dnum inside the function, so they are literally the exact same and should give the same results." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 6419089a..b754c119 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -253,7 +253,7 @@ def Cl_analytic_from_num(fobs_orb_edges, number, hs, realize = False, floor = Fa hs = hs[...,np.newaxis] elif realize is True: number = holo.gravwaves.poisson_as_needed(number) - elif floor is True: + elif floor is True: # assumes realize is False number = np.floor(number) @@ -391,8 +391,10 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): shape = number.shape + (realize,) number = holo.gravwaves.poisson_as_needed(number[...,np.newaxis] * np.ones(shape)) - numh2 = number * hs_cents**2 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] - numh4 = number * hs_cents**4 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] + # numh2 = number * hs_cents**2 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] + # numh4 = number * hs_cents**4 * np.diff(np.log(fobs_gw_edges))[:,np.newaxis] + numh2 = number * hs_cents**2 + numh4 = number * hs_cents**4 else: err = "`realize` ({}) must be one of {{False, integer}}!".format(realize) raise ValueError(err) From 077493303097bd5cf3971ad9a08fa6a8b2442b6a Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 14:39:09 -0700 Subject: [PATCH 022/291] Comparing hs4 and hs2 terms in analytic_investigation_integrals.ipynb --- .../analytic_anisotropy_methods.ipynb | 136 ++++++++---------- .../analytic_investigation_integrals.ipynb | 55 +++++++ 2 files changed, 116 insertions(+), 75 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index 20b0b784..76a876a6 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -706,8 +706,59 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "#### Weird bump FT shapes\n", - "##### FT, Shape 60\n" + "#### GW, Shape 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, vals = compare_all_analytic_anis(sam_20, hard_GW)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### GW, Shape 40" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, vals = compare_all_analytic_anis(sam_40, hard_GW)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### GW, Shape full" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, vals = compare_all_analytic_anis(sam_full, hard_GW)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Weird bump FT shapes\n", + "#### FT, Shape 60\n" ] }, { @@ -726,7 +777,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 70" + "#### FT, Shape 70" ] }, { @@ -745,7 +796,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 80" + "#### FT, Shape 80" ] }, { @@ -764,7 +815,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 90,80,100" + "#### FT, Shape 90,80,100" ] }, { @@ -779,7 +830,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -812,7 +862,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 91,81,101" + "#### FT, Shape 91,81,101" ] }, { @@ -827,7 +877,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -860,7 +909,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 91,80,100" + "#### FT, Shape 91,80,100" ] }, { @@ -879,7 +928,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 90,81,100" + "#### FT, Shape 90,81,100" ] }, { @@ -898,7 +947,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 90,80,101" + "#### FT, Shape 90,80,101" ] }, { @@ -913,7 +962,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -946,7 +994,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 91,80,101" + "#### FT, Shape 91,80,101" ] }, { @@ -961,7 +1009,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -990,7 +1037,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -1009,7 +1055,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -1037,65 +1082,6 @@ "fig = plot_h2_h4_numh2_numh4(vals)" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Back to GW" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### GW, Shape 20" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, vals = compare_all_analytic_anis(sam_20, hard_GW)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### GW, Shape 40" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, vals = compare_all_analytic_anis(sam_40, hard_GW)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#### GW, Shape full" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, vals = compare_all_analytic_anis(sam_full, hard_GW)" - ] - }, { "attachments": {}, "cell_type": "markdown", diff --git a/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb b/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb index 3df1aa31..56f3aecd 100644 --- a/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb +++ b/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb @@ -942,6 +942,61 @@ "plt.scatter(edges_zz, redz_final[19,19,:,39])" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# C0 Term Comparison" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nbins = 20\n", + "hs = np.geomspace(10**-20, 10**-15, nbins+1)\n", + "num = np.geomspace(10**6, 10**-3, nbins+1)\n", + "\n", + "xh = hs \n", + "xn = num\n", + "\n", + "# when num is more powerful, C0 term becomes more important, dec. anisotropy\n", + "# when hs/num increases, num is less powerful, and anisotropy increases\n", + "xx = hs**2/num \n", + "xlabels= np.array(['$h_s^2/N$', '$h_s$', '$N$', ])\n", + "\n", + "y1 = (num*hs**2)**2\n", + "y2 = (num*hs**4)\n", + "ylabels = np.array(['$(N h_s^2)^2$, C0 term', '$N h_s^4$, both term'])\n", + "\n", + "fig, axs = holo.plot.figax(ncols=1, nrows=3, figsize=(7,7))\n", + "\n", + "for ii, yy, in enumerate([y1, y2]):\n", + " axs[0].plot(xx, yy, label=ylabels[ii])\n", + " axs[1].plot(xh, yy, label=ylabels[ii])\n", + " axs[2].plot(xn, yy, label=ylabels[ii])\n", + "\n", + "for ii, ax in enumerate(axs):\n", + " ax.legend()\n", + " ax.set_xlabel([xlabels[ii]])\n", + "axs[2].set_xlim(axs[2].get_xlim()[::-1])\n", + "fig.tight_layout()\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = holo.plot.figax(xlabel='$h_s^2$', ylabel='$h_s/N$')\n", + "ax.plot(xh, xx)" + ] + }, { "cell_type": "code", "execution_count": null, From 7f30c29fe56a83303dadd943b4a6c2e25ba79b57 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 14:39:29 -0700 Subject: [PATCH 023/291] Recovered gen_lib_ss.py from prev commit. --- scripts/gen_lib_ss.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_lib_ss.py b/scripts/gen_lib_ss.py index b37cdc03..bf660287 100644 --- a/scripts/gen_lib_ss.py +++ b/scripts/gen_lib_ss.py @@ -193,7 +193,7 @@ def _setup_argparse(*args, **kwargs): help='Number of frequency bins', default=DEF_NUM_FBINS) parser.add_argument('-s', '--shape', action='store', dest='sam_shape', type=int, help='Shape of SAM grid', default=DEF_SAM_SHAPE) - parser.add_argument('-l', '--nloudest', action='store', dest='nloudest', type=int, + parser.add_argument('-l', '--loudest', action='store', dest='nloudest', type=int, help='Number of loudest single sources', default=1) parser.add_argument('-p', '--pars', action='store', dest='get_pars', type=int, help='Whether or not to get pars', default=0) From 742bd6e30ecc72823fc222b8e22f5a9a961e0322 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 14:39:58 -0700 Subject: [PATCH 024/291] Calculated ClC0 for redz_prime. --- .../analytic_anisotropy_methods.ipynb | 71 ++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb index 76a876a6..a4a4906a 100644 --- a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb @@ -552,7 +552,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Compare Models" + "# Compare All Analytic Models" ] }, { @@ -614,6 +614,11 @@ " C0_redz, Cl_redz = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final)\n", " C0_rzreals, Cl_rzreals = anis.Cl_analytic_from_dnum(edges, diff_num, redz_final, realize=10)\n", "\n", + " # analytic from dnum, zprime\n", + " print('calculating analytic from dnum, prime redshift')\n", + " C0_priz, Cl_priz = anis.Cl_analytic_from_dnum(edges, diff_num, sam._redz_prime[...,np.newaxis])\n", + " C0_pzreals, Cl_pzreals = anis.Cl_analytic_from_dnum(edges, diff_num, sam._redz_prime[...,np.newaxis], realize=10)\n", + "\n", " # plot everything\n", " print('plotting')\n", " fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", @@ -633,6 +638,9 @@ " anis.draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='dnum, z_final', color='indigo', lw=4)\n", " anis.draw_reals(ax, Cl_rzreals, C0_rzreals, fobs_gw_cents, label=None, color='indigo')\n", "\n", + " anis.draw_analytic(ax, Cl_priz, C0_priz, fobs_gw_cents, label='dnum, z_prime', color='darkmagenta', lw=4)\n", + " anis.draw_reals(ax, Cl_pzreals, C0_pzreals, fobs_gw_cents, label=None, color='darkmagenta')\n", + "\n", " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", " ax.set_title('%s, %s' % ( str(hard_name), str(sam.shape)), fontsize=12)\n", "\n", @@ -645,6 +653,7 @@ " 'flnum':flnum, 'C0_flnum':C0_flnum, 'Cl_flnum':Cl_flnum,\n", " 'C0_init':C0_init, 'Cl_init':Cl_init, 'C0_inreals':C0_inreals, 'Cl_inreals':Cl_inreals,\n", " 'C0_redz':C0_redz, 'Cl_redz':Cl_redz, 'C0_rzreals':C0_rzreals, 'Cl_rzreals':Cl_rzreals,\n", + " 'C0_priz':C0_priz, 'Cl_priz':Cl_priz, 'C0_pzreals':C0_pzreals, 'Cl_pzreals':Cl_pzreals,\n", "\n", " }\n", " return fig, vals" @@ -684,6 +693,24 @@ "fig, vals = compare_all_analytic_anis(sam_40, hard_FT40)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### FT, Shape 91,81,100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9181100 = holo.sam.Semi_Analytic_Model(shape=(91,81,100))\n", + "hard_FT9181100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181100, 3*GYR)\n", + "fig_FTfull, vals_FTfull = compare_all_analytic_anis(sam_9181100, hard_FT9181100)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -1037,10 +1064,11 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "##### FT, Shape 91,81,100" + "#### FT, Shape 91,81,100" ] }, { @@ -1082,6 +1110,45 @@ "fig = plot_h2_h4_numh2_numh4(vals)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### FT, Shape 91,81,102" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_9181102 = holo.sam.Semi_Analytic_Model(shape=[91,81,102])\n", + "hard_FT9181102 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181102, 3*GYR)\n", + "fig_FT9181102, vals_FT9181102 = compare_all_analytic_anis(sam_9181102, hard_FT9181102)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "look at hs and dnum" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals2_9181102 = setup_calculate_all(sam_9181102, hard_FT9181102)\n", + "vals = vals2_9181102\n", + "fig = plot_Cl_analytic_from_num(vals)\n", + "fig = plot_num_sums(vals)\n", + "fig = plot_h2_h4_numh2_numh4(vals)" + ] + }, { "attachments": {}, "cell_type": "markdown", From 165d41aebfa15ed8f1a411cd9d302d3d7a220456 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 17:51:00 -0700 Subject: [PATCH 025/291] Plotting hs vs params for single pspace model in take3_gwb_anatomy.ipynb. par_units correction in single_sources.py. --- .../take2_ss56_redz.ipynb | 13 +- .../take3_gwb_anatomy.ipynb | 274 ++++++++++++++++++ holodeck/single_sources.py | 2 +- 3 files changed, 276 insertions(+), 13 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb diff --git a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb index 3b4f69b9..b07c179e 100644 --- a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb +++ b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb @@ -245,7 +245,7 @@ " fig.text(xx, yy, text, fontsize=10, color='k', alpha=0.75)\n", " \n", "\n", - "def plot_bin_pars_fast(nn, hc_ss, hc_bg, sspar, bgpar, fobs, param_names=space.param_names):\n", + "def plot_bin_pars_fast(nn, hc_ss, hc_bg, sspar, bgpar, fobs, param_names=space.param_names, params=params):\n", " fig, axs = plot.figax(nrows=2, ncols=2, ylabel='$h_c$', sharey=True,\n", " figsize=(9,6))\n", "\n", @@ -451,17 +451,6 @@ "hc_med_of_dif = np.median(hc_dif, axis=-1) # (N,) # median realization difference from ref freqs" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(hc_med_of_dif.shape)\n", - "print(hc_dif_of_med.shape)\n", - "print(nsort.shape)" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb new file mode 100644 index 00000000..6c74cedf --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as ss\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Choose a Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = (30,25,35)\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + " # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "params = pars * pspace.param_samples\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Question: What are bin_params and gwb_params?" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents = data['fobs_cents']\n", + "hc_ss_mid = data['hc_ss']\n", + "hc_bg_mid = data['hc_bg']\n", + "sspar_mid = ss.all_sspars(fobs_cents, data['sspar'])\n", + "bgpar_mid = data['bgpar']\n", + "binpar_names = ss.par_names\n", + "# params = pars*pspace.params\n", + "print(f\"{hc_ss_mid.shape=}\")\n", + "print(f\"{bgpar_mid.shape=}\")\n", + "print(f\"{sspar_mid.shape=}\")\n", + "print(f\"{param_names=}\")\n", + "print(f\"{params=}\")\n", + "print(f\"{binpar_names=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot hc vs. bin pars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(ss.par_labels)\n", + "print(ss.par_units)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = ss.par_labels[idx]\n", + " units = ss.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "detstats.detect_bg_pta()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot everything vs freqs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "arr = np.random.uniform(0,1,100).reshape(5,20)\n", + "print(arr.shape)\n", + "app = np.random.uniform(0,1, 20)\n", + "tot = np.append(arr, app).reshape(6,20)\n", + "print(tot.shape)\n", + "print(np.all(arr[2] == tot[2]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, df_ss, df_bg,\n", + " color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = ss.par_labels[idx]\n", + " units = ss.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 9, F,R,L\n", + " xx_ss = np.append(xx_ss, np.array([hc_ss, dp_ss, dp_bg])\n", + " xx_ss = np.append(xx_ss, dp_ss)\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 9,F,R,L\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " fig.tight_layout()\n", + " return fig" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/holodeck/single_sources.py b/holodeck/single_sources.py index eee18f7f..1754e081 100644 --- a/holodeck/single_sources.py +++ b/holodeck/single_sources.py @@ -29,7 +29,7 @@ log.setLevel(logging.INFO) par_names = np.array(['mtot', 'mrat', 'redz_init', 'redz_final', 'dcom_final', 'sepa_final', 'angs_final']) -par_labels = np.array(['Total Mass $M$ (g)', 'Mass Ratio $q$', 'Initial Redshift $z_i$', 'Final Redshift $z_f$', +par_labels = np.array(['Total Mass $M$ ($M_\odot$)', 'Mass Ratio $q$', 'Initial Redshift $z_i$', 'Final Redshift $z_f$', 'Final Comoving Distance $d_c$ (Mpc)', 'Final Separation (pc)', 'Final Angular Separation (rad)']) par_units = np.array([1/MSOL, 1, 1, 1, 1/MPC, 1/PC, 1]) From 39aeb114e75a695fe66aa513ef0aaa81f7d32da5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 19:41:03 -0700 Subject: [PATCH 026/291] Plotting everything (pars, hs, snr, detprob) vs. freqs for a single model in take3_gwb_anatomy.ipynb. --- .../take3_gwb_anatomy.ipynb | 235 +++++++++++++++--- 1 file changed, 205 insertions(+), 30 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb index 6c74cedf..2dba907e 100644 --- a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb @@ -17,9 +17,11 @@ "\n", "\n", "from holodeck import plot, detstats\n", - "import holodeck.single_sources as ss\n", + "import holodeck.single_sources as sings\n", "from holodeck.constants import YR, MSOL, MPC\n", - "import holodeck as holo" + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" ] }, { @@ -83,9 +85,9 @@ "fobs_cents = data['fobs_cents']\n", "hc_ss_mid = data['hc_ss']\n", "hc_bg_mid = data['hc_bg']\n", - "sspar_mid = ss.all_sspars(fobs_cents, data['sspar'])\n", + "sspar_mid = sings.all_sspars(fobs_cents, data['sspar'])\n", "bgpar_mid = data['bgpar']\n", - "binpar_names = ss.par_names\n", + "binpar_names = sings.par_names\n", "# params = pars*pspace.params\n", "print(f\"{hc_ss_mid.shape=}\")\n", "print(f\"{bgpar_mid.shape=}\")\n", @@ -109,8 +111,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(ss.par_labels)\n", - "print(ss.par_units)" + "print(sings.par_labels)\n", + "print(sings.par_units)" ] }, { @@ -119,6 +121,16 @@ "metadata": {}, "outputs": [], "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", + " if pp == int(len(param_names)/2):\n", + " text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color='k', alpha=0.75)\n", + "\n", + "\n", "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", " show_medians = False, show_ci=False, show_reals=True):\n", " if show_reals:\n", @@ -144,8 +156,8 @@ " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", " idx = [0,1,2,4,5,6]\n", "\n", - " labels = ss.par_labels[idx]\n", - " units = ss.par_units[idx]\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", " print(f\"{xx_ss.shape=}\")\n", @@ -165,6 +177,7 @@ " ax.set_xlabel(labels[ii])\n", " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12)\n", " fig.tight_layout()\n", " return fig\n", "\n", @@ -185,7 +198,66 @@ "metadata": {}, "outputs": [], "source": [ - "detstats.detect_bg_pta()" + "NPSRS = 60\n", + "SIGMA = 1e-7\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " shape = hc_ss.shape\n", + " nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "\n", + "\n", + " # calculate dur, cad, dfobs\n", + " dur = dur * YR\n", + " hifr = nfreqs/dur\n", + " cad = 1.0 / (2 * hifr)\n", + " fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad)\n", + " dfobs = np.diff(fobs_edges)\n", + "\n", + " # build PTA\n", + " print('Building pulsar timing array.')\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + " phi=phis, theta=thetas)\n", + "\n", + " # Build ss skies\n", + " print('Building ss skies.')\n", + " theta_ss, phi_ss, Phi0_ss, iota_ss, psi_ss = detstats._build_skies(nfreqs, nskies, nloudest)\n", + "\n", + "\n", + " # Calculate DPs, SNRs, and DFs\n", + " print('Calculating SS and BG detection statistics.')\n", + " dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, hc_bg, ret_snr=True)\n", + " vals_ss = detstats.detect_ss_pta(\n", + " psrs, cad, dur, fobs_cents, dfobs, hc_ss, hc_bg, \n", + " gamma_cython=True, snr_cython=True, ret_snr=True, \n", + " theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss,\n", + " )\n", + " dp_ss, snr_ss, gamma_ssi = vals_ss[0], vals_ss[1], vals_ss[2]\n", + " df_ss = np.sum(dp_ss>thresh)/(nreals*nskies)\n", + " df_bg = np.sum(dp_bg>thresh)/(nreals)\n", + "\n", + " dsdata = {\n", + " 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, \n", + " 'dp_bg':dp_bg, 'snr_bg':snr_bg,\n", + " 'df_ss':df_ss, 'df_bg':df_bg\n", + " }\n", + "\n", + " return dsdata\n", + "\n", + "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)" ] }, { @@ -216,38 +288,141 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, df_ss, df_bg,\n", - " color_ss='r', color_bg='k', fast_ss=True):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + "dp_ss = dsdata_mid['dp_ss'] \n", + "dp_bg = dsdata_mid['dp_bg']\n", + "snr_ss = dsdata_mid['snr_ss']\n", + "snr_bg = dsdata_mid['snr_bg']\n", + "print(f\"{dp_ss.shape=}, {dp_bg.shape=}, {snr_ss.shape=}, {snr_bg.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest):\n", + " if show_reals:\n", + " if fast:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " else:\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " if ll==0: edgecolor='k'\n", + " else: edgecolor=None\n", + " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " if ll==0: edgecolor='k'\n", + " else: edgecolor=None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " if fast:\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", "\n", - " labels = ss.par_labels[idx]\n", - " units = ss.par_units[idx]\n", - " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 9, F,R,L\n", - " xx_ss = np.append(xx_ss, np.array([hc_ss, dp_ss, dp_bg])\n", - " xx_ss = np.append(xx_ss, dp_ss)\n", - " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 9,F,R,L\n", - " print(f\"{xx_ss.shape=}\")\n", - " print(f\"{xx_bg.shape=}\")\n", - "\n", - " yy_ss = hc_ss\n", - " yy_bg = hc_bg\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", " print(f\"{yy_ss.shape=}\")\n", " print(f\"{yy_bg.shape=}\")\n", "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", "\n", " fig, axs = holo.plot.figax(\n", - " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", - " for ax in axs[:,0]:\n", - " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", - " for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(labels[ii])\n", - " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12) \n", " fig.tight_layout()\n", - " return fig" + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " fast=True)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From a26792a9f5c53cbeaa4dd3f5d2ecdfb44067ed4b Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 20:02:15 -0700 Subject: [PATCH 027/291] Plotted everything for varying hard_time in take3_gwb_anatomy.ipynb --- .../take3_gwb_anatomy.ipynb | 70 ++++++++++++++++--- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb index 2dba907e..80fc6d2f 100644 --- a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb @@ -311,8 +311,7 @@ " else:\n", " for rr in range(nreals):\n", " for ll in range(nloudest):\n", - " if ll==0: edgecolor='k'\n", - " else: edgecolor=None\n", + " edgecolor='k' if ll==0 else None\n", " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", "\n", @@ -330,8 +329,7 @@ " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", " for rr in range(nreals):\n", " for ll in range(nloudest):\n", - " if ll==0: edgecolor='k'\n", - " else: edgecolor=None\n", + " edgecolor = 'k' if ll==0 else None\n", " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", "\n", @@ -354,9 +352,8 @@ " shape = snr_ss.shape\n", " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", " xx = fobs_cents*YR\n", - " if fast:\n", - " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", - " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", "\n", " labels = np.append(sings.par_labels[idx], \n", " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", @@ -414,7 +411,64 @@ "\n", "\n", "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, dp_ss, dp_bg, snr_ss, snr_bg,\n", - " fast=True)" + " fast=False)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare Simulations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Choose a parameter that we're going to vary\n", + "target_param = 'hard_time' # the name of the parameter, has to exist in `param_names`\n", + "params_list = [0.0, 0.5, 1.0] # the values we'll check\n", + "param_idx = param_names.index(target_param)\n", + "\n", + "data_hard_time = []\n", + "for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data_hard_time.append(_data)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dat in data_hard_time:\n", + " plot_everything_vs_freqs_from_data(dat)" ] }, { From ed00e31a322efe9915f9e0c9dec8fb822a6e1cc4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 22:00:53 -0700 Subject: [PATCH 028/291] Plotted all pars for varying all individual parameters. Added new detstats for pspace function to detstats.py. --- .../take3_gwb_anatomy.ipynb | 391 ++++++++++++++++-- holodeck/detstats.py | 52 ++- 2 files changed, 396 insertions(+), 47 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb index 80fc6d2f..05b47ac0 100644 --- a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb @@ -60,6 +60,10 @@ "# construct `sam` and `hard` instances based on these parameters,\n", "# using otherwise all default parameters for this library\n", "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", "\n", "# run this model, retrieving binary parameters and the GWB\n", @@ -122,13 +126,13 @@ "outputs": [], "source": [ "def draw_sample_text(fig, params, param_names, \n", - " xx=0.1, yy=-0.025, fontsize=10):\n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", " text = ''\n", " for pp, name in enumerate(param_names):\n", " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", " if pp == int(len(param_names)/2):\n", " text = text+'\\n'\n", - " fig.text(xx, yy, text, fontsize=fontsize, color='k', alpha=0.75)\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", "\n", "\n", "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", @@ -211,53 +215,16 @@ "metadata": {}, "outputs": [], "source": [ - "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", - " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", - " shape = hc_ss.shape\n", - " nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", - "\n", - "\n", - " # calculate dur, cad, dfobs\n", - " dur = dur * YR\n", - " hifr = nfreqs/dur\n", - " cad = 1.0 / (2 * hifr)\n", - " fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad)\n", - " dfobs = np.diff(fobs_edges)\n", - "\n", - " # build PTA\n", - " print('Building pulsar timing array.')\n", - " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", - " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", - " # sigmas = np.ones_like(phis)*sigma\n", - " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", - " phi=phis, theta=thetas)\n", - "\n", - " # Build ss skies\n", - " print('Building ss skies.')\n", - " theta_ss, phi_ss, Phi0_ss, iota_ss, psi_ss = detstats._build_skies(nfreqs, nskies, nloudest)\n", - "\n", - "\n", - " # Calculate DPs, SNRs, and DFs\n", - " print('Calculating SS and BG detection statistics.')\n", - " dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, hc_bg, ret_snr=True)\n", - " vals_ss = detstats.detect_ss_pta(\n", - " psrs, cad, dur, fobs_cents, dfobs, hc_ss, hc_bg, \n", - " gamma_cython=True, snr_cython=True, ret_snr=True, \n", - " theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss,\n", - " )\n", - " dp_ss, snr_ss, gamma_ssi = vals_ss[0], vals_ss[1], vals_ss[2]\n", - " df_ss = np.sum(dp_ss>thresh)/(nreals*nskies)\n", - " df_bg = np.sum(dp_bg>thresh)/(nreals)\n", "\n", - " dsdata = {\n", - " 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, \n", - " 'dp_bg':dp_bg, 'snr_bg':snr_bg,\n", - " 'df_ss':df_ss, 'df_bg':df_bg\n", - " }\n", "\n", + "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", " return dsdata\n", "\n", - "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)" + "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)\n", + "print(f\"{dsdata_mid.keys()=}\")" ] }, { @@ -422,6 +389,15 @@ "# Compare Simulations" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(pspace.param_samples)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -434,9 +410,12 @@ "param_idx = param_names.index(target_param)\n", "\n", "data_hard_time = []\n", + "params_hard_time = []\n", "for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", + " _params = pspace.param_samples[0]*pars\n", + " params_hard_time.append(_params)\n", " # construct `sam` and `hard` instances based on these parameters\n", " sam, hard = pspace.model_for_normalized_params(pars)\n", " # run this model, retrieving binary parameters and the GWB\n", @@ -471,6 +450,328 @@ " plot_everything_vs_freqs_from_data(dat)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def draw_three_models(\n", + " data, params, hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.05, -0.1, -0.15])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(fobs_cents, dat['hc_ss'], dat['hc_bg'])\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + " hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data_hard_time[0].keys())\n", + "print(data['number'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def draw_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.05, -0.15, -0.25])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + " hard_name, sam.shape, target_param)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(param_names)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vary Parameters!!!!!!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " ):\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " _params = pspace.param_samples[0]*pars\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " return (data, params, hard_name, sam.shape, target_param)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# data, params = data_hard_time, params_hard_time\n", + "fig = draw_three_models(*rv_hard_time)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0') \n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10') \n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex') \n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_gamma_inner'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner') \n", + "fig = draw_three_models(*rv_hard_gamma_inner)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/holodeck/detstats.py b/holodeck/detstats.py index a8a05fe2..cd5715cb 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -22,6 +22,7 @@ GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' HC_REF15_10YR = 11.2*10**-15 +DEF_THRESH=0.5 ###################### Overlap Reduction Function ###################### @@ -1534,7 +1535,7 @@ def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, ######################### Running on Libraries ######################### ######################################################################## -def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=0.5, +def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, dur=None, cad=None, dfobs=None, plot=True, debug=False, grid_path=GAMMA_RHO_GRID_PATH, snr_cython = True): """ Calculate detection statistics for an ss library output. @@ -1858,5 +1859,52 @@ def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref return nsort, fidx, hc_ref return nsort -############################ Calibrate PTA ############################# +######################### Param Space Models ########################### + +def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur, + npsrs, sigma, nskies, thresh=DEF_THRESH, debug=False): + shape = hc_ss.shape + nfreqs, nreals, nloudest = shape[0], shape[1], shape[2] + + # calculate dur, cad, dfobs + dur = dur * YR + hifr = nfreqs/dur + cad = 1.0 / (2 * hifr) + fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad) + dfobs = np.diff(fobs_edges) + + # build PTA + if debug: print('Building pulsar timing array.') + phis = np.random.uniform(0, 2*np.pi, size = npsrs) + thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + # sigmas = np.ones_like(phis)*sigma + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + phi=phis, theta=thetas) + + # Build ss skies + if debug: print('Building ss skies.') + theta_ss, phi_ss, Phi0_ss, iota_ss, psi_ss = _build_skies(nfreqs, nskies, nloudest) + + + # Calculate DPs, SNRs, and DFs + if debug: print('Calculating SS and BG detection statistics.') + dp_bg, snr_bg = detect_bg_pta(psrs, fobs_cents, cad, hc_bg, ret_snr=True) + vals_ss = detect_ss_pta( + psrs, cad, dur, fobs_cents, dfobs, hc_ss, hc_bg, + gamma_cython=True, snr_cython=True, ret_snr=True, + theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss, + ) + dp_ss, snr_ss, gamma_ssi = vals_ss[0], vals_ss[1], vals_ss[2] + df_ss = np.sum(dp_ss>thresh)/(nreals*nskies) + df_bg = np.sum(dp_bg>thresh)/(nreals) + + dsdata = { + 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, + 'dp_bg':dp_bg, 'snr_bg':snr_bg, + 'df_ss':df_ss, 'df_bg':df_bg + } + + return dsdata + +############################ Calibrate PTA ############################# From e0eac0a83c0dbf75f90fe6dc528777a391c2e299 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 22:09:08 -0700 Subject: [PATCH 029/291] Running all param comparisons on full shape in take4_gwb_anatomy_fullyshape.ipynb --- .gitignore | 3 + .../take4_gwb_anatomy_fullshape.ipynb | 754 ++++++++++++++++++ 2 files changed, 757 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb diff --git a/.gitignore b/.gitignore index 26fba259..04db942c 100644 --- a/.gitignore +++ b/.gitignore @@ -134,3 +134,6 @@ run_gen_lib_sams__* *.html .gitattributes *.slurm + +# Mac Desktop Services +.DS_Store \ No newline at end of file diff --git a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb new file mode 100644 index 00000000..1132370c --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb @@ -0,0 +1,754 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Choose a Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + " # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "params = pars * pspace.param_samples\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents = data['fobs_cents']\n", + "hc_ss_mid = data['hc_ss']\n", + "hc_bg_mid = data['hc_bg']\n", + "sspar_mid = sings.all_sspars(fobs_cents, data['sspar'])\n", + "bgpar_mid = data['bgpar']\n", + "binpar_names = sings.par_names\n", + "# params = pars*pspace.params\n", + "print(f\"{hc_ss_mid.shape=}\")\n", + "print(f\"{bgpar_mid.shape=}\")\n", + "print(f\"{sspar_mid.shape=}\")\n", + "print(f\"{param_names=}\")\n", + "print(f\"{params=}\")\n", + "print(f\"{binpar_names=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Mid of all params\n", + "## Plot hc vs. bin pars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", + " if pp == int(len(param_names)/2):\n", + " text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 60\n", + "SIGMA = 1e-7\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata\n", + "\n", + "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)\n", + "print(f\"{dsdata_mid.keys()=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Plot everything vs freqs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss_mid = dsdata_mid['dp_ss'] \n", + "dp_bg_mid = dsdata_mid['dp_bg']\n", + "snr_ss_mid = dsdata_mid['snr_ss']\n", + "snr_bg_mid = dsdata_mid['snr_bg']\n", + "print(f\"{dp_ss_mid.shape=}, {dp_bg_mid.shape=}, {snr_ss_mid.shape=}, {snr_bg_mid.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest):\n", + " if show_reals:\n", + " if fast:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " else:\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor='k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + " fast=False)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare Simulations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Choose a parameter that we're going to vary\n", + "target_param = 'hard_time' # the name of the parameter, has to exist in `param_names`\n", + "params_list = [0.0, 0.5, 1.0] # the values we'll check\n", + "param_idx = param_names.index(target_param)\n", + "\n", + "data_hard_time = []\n", + "params_hard_time = []\n", + "for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " _params = pspace.param_samples[0]*pars\n", + " params_hard_time.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data_hard_time.append(_data)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dat in data_hard_time:\n", + " plot_everything_vs_freqs_from_data(dat)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def draw_three_models(\n", + " data, params, hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.05, -0.1, -0.15])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(fobs_cents, dat['hc_ss'], dat['hc_bg'])\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + " hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data_hard_time[0].keys())\n", + "print(data['number'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def draw_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.05, -0.15, -0.25])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + " hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vary Parameters!!!!!!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " ):\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " _params = pspace.param_samples[0]*pars\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " return (data, params, hard_name, sam.shape, target_param)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# data, params = data_hard_time, params_hard_time\n", + "fig = draw_three_models(*rv_hard_time)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0') \n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10') \n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex') \n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_gamma_inner'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner') \n", + "fig = draw_three_models(*rv_hard_gamma_inner)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From ad5dd14d2497274d5bcf7a5fa45b5b135c3ae9bc Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 5 Jun 2023 22:17:53 -0700 Subject: [PATCH 030/291] Cleaning up take4_gwb_anatomy_fullshape.ipynb. --- .../take4_gwb_anatomy_fullshape.ipynb | 129 ++++++------------ 1 file changed, 45 insertions(+), 84 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb index 1132370c..5609b152 100644 --- a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb @@ -29,7 +29,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Choose a Parameter Space" + "# 1 Choose a Parameter Space" ] }, { @@ -43,7 +43,20 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - " # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "NPSRS = 60\n", + "SIGMA = 1e-7\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", "\n", "# get the parameter names from this library-space\n", @@ -72,6 +85,28 @@ "print(f\"retrieved data: {data.keys()=}\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 Mid of all params\n", + "## 2.1 Plot hc vs. bin pars" + ] + }, { "cell_type": "code", "execution_count": null, @@ -93,15 +128,6 @@ "print(f\"{binpar_names=}\")" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Mid of all params\n", - "## Plot hc vs. bin pars" - ] - }, { "cell_type": "code", "execution_count": null, @@ -176,20 +202,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Calculate detstats" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "NPSRS = 60\n", - "SIGMA = 1e-7\n", - "NSKIES = 25\n", - "THRESH = 0.5\n", - "DUR = holo.librarian.DEF_PTA_DUR" + "## 2.2 Calculate detstats" ] }, { @@ -198,12 +211,6 @@ "metadata": {}, "outputs": [], "source": [ - "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", - " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", - " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", - " npsrs, sigma, nskies, thresh)\n", - " return dsdata\n", - "\n", "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)\n", "print(f\"{dsdata_mid.keys()=}\")" ] @@ -213,7 +220,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Plot everything vs freqs" + "## 2.3 Plot everything vs freqs" ] }, { @@ -354,33 +361,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Compare Simulations" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Choose a parameter that we're going to vary\n", - "target_param = 'hard_time' # the name of the parameter, has to exist in `param_names`\n", - "params_list = [0.0, 0.5, 1.0] # the values we'll check\n", - "param_idx = param_names.index(target_param)\n", - "\n", - "data_hard_time = []\n", - "params_hard_time = []\n", - "for ii, par in enumerate(params_list):\n", - " pars[param_idx] = par\n", - " print(f\"{ii=}, {pars=}\")\n", - " _params = pspace.param_samples[0]*pars\n", - " params_hard_time.append(_params)\n", - " # construct `sam` and `hard` instances based on these parameters\n", - " sam, hard = pspace.model_for_normalized_params(pars)\n", - " # run this model, retrieving binary parameters and the GWB\n", - " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", - " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", - " data_hard_time.append(_data)" + "# 3 Plot-Three Functions" ] }, { @@ -399,16 +380,6 @@ " return fig" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for dat in data_hard_time:\n", - " plot_everything_vs_freqs_from_data(dat)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -492,18 +463,8 @@ "\n", " return fig\n", "\n", - "fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", - " hard_name=hard_name, shape=sam.shape, target_param=target_param)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(data_hard_time[0].keys())\n", - "print(data['number'].shape)" + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" ] }, { @@ -555,8 +516,8 @@ "\n", " return fig\n", "\n", - "fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", - " hard_name, sam.shape, target_param)\n" + "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" ] }, { @@ -564,7 +525,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Vary Parameters!!!!!!!" + "# 4 Vary Parameters!!!!!!!" ] }, { From aa1e96fae0851be917f68e6d85238c57d41d78a4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 6 Jun 2023 00:05:09 -0700 Subject: [PATCH 031/291] Calibrated PTA to dp_bg of mid sample. --- .../take4_gwb_anatomy_fullshape.ipynb | 89 ++++++++++++++----- 1 file changed, 66 insertions(+), 23 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb index 5609b152..cfa0565b 100644 --- a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb @@ -41,13 +41,7 @@ "SHAPE = None\n", "NREALS = 30\n", "NFREQS = 40\n", - "NLOUDEST = 10\n", - "\n", - "NPSRS = 60\n", - "SIGMA = 1e-7\n", - "NSKIES = 25\n", - "THRESH = 0.5\n", - "DUR = holo.librarian.DEF_PTA_DUR" + "NLOUDEST = 10" ] }, { @@ -85,19 +79,6 @@ "print(f\"retrieved data: {data.keys()=}\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", - " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", - " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", - " npsrs, sigma, nskies, thresh)\n", - " return dsdata" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -202,7 +183,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 2.2 Calculate detstats" + "## 2.2 Calibrate PTA" ] }, { @@ -211,8 +192,63 @@ "metadata": {}, "outputs": [], "source": [ - "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)\n", - "print(f\"{dsdata_mid.keys()=}\")" + "NPSRS = 50\n", + "SIGMA = 3.55e-6\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape = hc_ss_mid.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "debug=True\n", + "\n", + "# calculate dur, cad, dfobs\n", + "dur = DUR * YR\n", + "hifr = nfreqs/dur\n", + "cad = 1.0 / (2 * hifr)\n", + "fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad)\n", + "dfobs = np.diff(fobs_edges)\n", + "\n", + "# build PTA\n", + "if debug: print('Building pulsar timing array.')\n", + "phis = np.random.uniform(0, 2*np.pi, size = NPSRS)\n", + "thetas = np.random.uniform(np.pi/2, np.pi/2, size = NPSRS)\n", + "# sigmas = np.ones_like(phis)*sigma\n", + "psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=SIGMA,\n", + " phi=phis, theta=thetas)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, hc_bg_mid)\n", + "print(f\"{np.median(dp_bg)=}, {np.mean(dp_bg)=}, {np.std(dp_bg)=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid,)\n", + "print(f\"{dsdata_mid.keys()=}\")\n" ] }, { @@ -683,6 +719,13 @@ "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, From d3b31a9bfc54a6ea3c4f23a846f70b1c02616cea Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 7 Jun 2023 21:00:37 -0700 Subject: [PATCH 032/291] Updated paper plots. --- ...anisotropy.ipynb => an1_sato_polito.ipynb} | 0 ...pynb => an2_investigation_integrals.ipynb} | 0 ...ods.ipynb => an3_anisotropy_methods.ipynb} | 0 .../anisotropy/anisotropy_paper_plots.ipynb | 138 +++++++++++++++++- holodeck/anisotropy.py | 8 +- 5 files changed, 134 insertions(+), 12 deletions(-) rename ecg-notebooks/anisotropy/{sato_polito_anisotropy.ipynb => an1_sato_polito.ipynb} (100%) rename ecg-notebooks/anisotropy/{analytic_investigation_integrals.ipynb => an2_investigation_integrals.ipynb} (100%) rename ecg-notebooks/anisotropy/{analytic_anisotropy_methods.ipynb => an3_anisotropy_methods.ipynb} (100%) diff --git a/ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb b/ecg-notebooks/anisotropy/an1_sato_polito.ipynb similarity index 100% rename from ecg-notebooks/anisotropy/sato_polito_anisotropy.ipynb rename to ecg-notebooks/anisotropy/an1_sato_polito.ipynb diff --git a/ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb b/ecg-notebooks/anisotropy/an2_investigation_integrals.ipynb similarity index 100% rename from ecg-notebooks/anisotropy/analytic_investigation_integrals.ipynb rename to ecg-notebooks/anisotropy/an2_investigation_integrals.ipynb diff --git a/ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb similarity index 100% rename from ecg-notebooks/anisotropy/analytic_anisotropy_methods.ipynb rename to ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb index eddcca8b..5decaf91 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb +++ b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb @@ -66,10 +66,11 @@ "metadata": {}, "outputs": [], "source": [ + "\n", "# hc_ref15_10yr = 11.2*10**-15 \n", "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", "# nbest = 100\n", - "# print(hc_ref15)\n" + "# print(hc_ref15)" ] }, { @@ -253,6 +254,15 @@ "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, { "cell_type": "code", "execution_count": null, @@ -260,7 +270,7 @@ "outputs": [], "source": [ "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", - " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", "\n", " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", @@ -269,7 +279,7 @@ " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", " for ll in range(lmax):\n", " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", - " for pp in [50, 98]:\n", + " for pp in [50, 95]:\n", " percs = pp/2\n", " percs = [50-percs, 50+percs]\n", " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", @@ -283,7 +293,100 @@ " linewidth=1, label=label)\n", " \n", " # Add Nihan's data\n", - " ax.plot(xx_Nihan, Cl_nihan[:,ll]/Cl_nihan[:,0], \n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", " label = '$l=%d$' % (ll+1), \n", " color=colors[ll], marker='o', ms=8)\n", " \n", @@ -301,7 +404,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", "ax = fig.axes[0]\n", "\n", "# Sato-Polito & Kamionkowski\n", @@ -315,7 +418,30 @@ "ax.legend(loc='lower right', ncols=3)\n", "\n", "fig.tight_layout()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" ] }, { diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index b754c119..8f45eb3a 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -400,13 +400,9 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): raise ValueError(err) - delta_term = ( - fc / (4*np.pi * df) * np.sum(numh2, axis=(0,1,2)) - )**2 + delta_term = (fc / (4*np.pi * df) * np.sum(numh2, axis=(0,1,2)))**2 - Cl = ( - (fc / (4*np.pi*df))**2 * np.sum(numh4, axis=(0,1,2)) - ) + Cl = ((fc / (4*np.pi*df))**2 * np.sum(numh4, axis=(0,1,2))) C0 = Cl + delta_term From 508b460f7576f264f11e20827d8cbe2de4848041 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 7 Jun 2023 21:01:06 -0700 Subject: [PATCH 033/291] Just plotting stuff. --- .../take2_ss56_redz.ipynb | 196 +++++++++++++++++- .../take4_gwb_anatomy_fullshape.ipynb | 72 ++++++- 2 files changed, 256 insertions(+), 12 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb index b07c179e..4ddcce24 100644 --- a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb +++ b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb @@ -830,7 +830,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "$$ \\frac{\\partial N}{\\mathrm{bin}} \\propto \\Phi (M,z) = \\ln (10) \\Phi_0 (z) \\times \\bigg( \\frac{M}{M_0(z)) } \\bigg)^{1+\\alpha_0 (z0)} \\times \\exp \\bigg( -\\frac{M}{M_0(z)} \\bigg) $$" + "## GSMF" ] }, { @@ -838,7 +838,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Phi vs M_0" + "$$ \\frac{\\partial N}{\\mathrm{bin}} \\propto \\Phi (M,z) = \\ln (10) \\Phi_0 (z) \\times \\bigg( \\frac{M}{M_0(z)) } \\bigg)^{1+\\alpha_0 (z0)} \\times \\exp \\bigg( -\\frac{M}{M_0(z)} \\bigg) $$" ] }, { @@ -887,6 +887,14 @@ " " ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Phi vs Phi0" + ] + }, { "cell_type": "code", "execution_count": null, @@ -937,6 +945,14 @@ "ax.plot(mchar0_log10, Phi_mchar0)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Phi vs Mchar0" + ] + }, { "cell_type": "code", "execution_count": null, @@ -957,6 +973,47 @@ "ax.legend()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "samfull = holo.sam.Semi_Analytic_Model()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e, %e' % (np.min(samfull.mtot/MSOL), np.max(samfull.mtot /MSOL)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mstar_arr = np.geomspace(1e4, 1e12, 100)\n", + "Phi_mstar = np.zeros_like(mstar_arr)\n", + "\n", + "fig, ax = plot.figax(\n", + " xlabel='$M_*$ [($M_\\odot$)]',\n", + " ylabel = '$\\Phi$(M,z) [1/Mpc$^{3}$]')\n", + "\n", + "colors = cm.rainbow(np.linspace(0,1,6))\n", + "\n", + "for ii, mchar_val in enumerate([10, 10.5, 11, 11.5, 12, 12.5]):\n", + " for mm, mstar in enumerate(mstar_arr): #, 10**13]):\n", + " Phi_mstar[mm] = gsmf(gsmf_mchar0_log10=mchar_val, mstar=mstar)\n", + " ax.plot(mstar_arr, Phi_mstar, label=r'$M_{\\mathrm{char}, 0}=$'+'%.1f' % mchar_val, color=colors[ii])\n", + "\n", + "ax.legend()" + ] + }, { "cell_type": "code", "execution_count": null, @@ -967,13 +1024,148 @@ "print(holo.utils.stats(bgpar[:,0]/MSOL))" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## MMBulge Relations" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], + "source": [ + "# from MMBulge_KH2013\n", + "mmbulge=holo.relations.MMBulge_KH2013\n", + "MASS_AMP =mmbulge.MASS_AMP # 0.49 + 0.06 - 0.05 in units of [Msol]\n", + "MASS_AMP_LOG10 = 4.29 # vary this\n", + "MASS_REF = mmbulge.MASS_REF # 1e11 Msol\n", + "MASS_PLAW = mmbulge.MASS_PLAW # 1.17 ± 0.08\n", + "SCATTER_DEX = mmbulge.SCATTER_DEX # scatter stdev in dex, vary this" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def mbh_from_mbulge(mbulge, scatter_dex = SCATTER_DEX, mamp = MASS_AMP, \n", + " mplaw = MASS_PLAW, mref =MASS_REF):\n", + " \"\"\"Convert from stellar-bulge mass to black-hole mass.\n", + "\n", + " Parameters\n", + " ----------\n", + " mbulge : array_like,\n", + " Stellar bulge-mass of host galaxy. [grams]\n", + " scatter : bool,\n", + " Whether or not to include scatter in scaling relationship.\n", + " Uses `self._scatter_dex` attribute.\n", + "\n", + " Returns\n", + " -------\n", + " mbh : array_like,\n", + " Mass of black hole. [grams]\n", + "\n", + " \"\"\"\n", + " mbh = holo.relations._log10_relation(mbulge, mamp, mplaw, scatter_dex, x0=mref)\n", + " return mbh" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### M_BH vs M_amp" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mstar_pri, mstar_tot = samfull.mass_stellar()\n", + "# q = m2 / m1\n", + "mstar_rat = mstar_tot / mstar_pri\n", + "# M = m1 + m2\n", + "mstar_tot = mstar_pri + mstar_tot\n", + "print(np.min(mstar_tot), np.max(mstar_tot))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mstar_arr = np.geomspace(1e4, 1e12, 100)\n", + "Phi_mstar = np.zeros_like(mstar_arr)\n", + "\n", + "fig, ax = plot.figax(\n", + " xlabel='$M_*$ [($M_\\odot$)]',\n", + " ylabel = '$\\Phi$(M,z) [1/Mpc$^{3}$]')\n", + "\n", + "colors = cm.rainbow(np.linspace(0,1,6))\n", + "\n", + "for ii, mchar_val in enumerate([10, 10.5, 11, 11.5, 12, 12.5]):\n", + " for mm, mstar in enumerate(mstar_arr): #, 10**13]):\n", + " Phi_mstar[mm] = gsmf(gsmf_mchar0_log10=mchar_val, mstar=mstar)\n", + " ax.plot(mstar_arr, Phi_mstar, label=r'$M_{\\mathrm{char}, 0}=$'+'%.1f' % mchar_val, color=colors[ii])\n", + "\n", + "ax.legend()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# mu_amps = np.geomspace(10**0, 10**8.58)\n", + "mstar_mamps = 10**np.linspace(41, 47)\n", + "mbh_mamps = np.zeros_like(mstar_mamps)\n", + "\n", + "fig, ax = plot.figax(\n", + " xlabel= r'$M_\\mathrm{stellar}$ [($M_\\odot$)]',\n", + " ylabel = r'$M_\\mathrm{BH}$ [($M_\\odot$)]')\n", + "colors = cm.rainbow(np.linspace(0,1,5))\n", + "\n", + "for ii, mu in enumerate([10**0, 10**2, 10**4, 10**6, 10**8]):\n", + " for mm, mstar in enumerate(mstar_mamps):\n", + " mbh_mamps[mm] = mbh_from_mbulge(mstar, mamp=mu)\n", + " ax.plot(mstar_mamps, mbh_mamps, label=r'$\\mu=$'+'%.0e' % mu, color=colors[ii])\n", + "ax.legend()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Scratch" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{(1/2)**-0.2=}\", 'MM0, low M0')\n", + "print(f\"{(8/4)**-0.2=}\", 'M>M0, high M0')" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb index cfa0565b..512fa8a8 100644 --- a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb @@ -198,8 +198,11 @@ "THRESH = 0.5\n", "DUR = holo.librarian.DEF_PTA_DUR\n", "\n", - "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + "def detect_pspace_model(data, dur=DUR,\n", " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", " npsrs, sigma, nskies, thresh)\n", " return dsdata" @@ -247,7 +250,7 @@ "metadata": {}, "outputs": [], "source": [ - "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid,)\n", + "dsdata_mid= detect_pspace_model(data)\n", "print(f\"{dsdata_mid.keys()=}\")\n" ] }, @@ -486,7 +489,7 @@ "\n", " for ii, dat in enumerate(data):\n", " print(f'on dat {ii}')\n", - " dsdat = detect_pspace_model(fobs_cents, dat['hc_ss'], dat['hc_bg'])\n", + " dsdat = detect_pspace_model(dat)\n", " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", @@ -573,7 +576,12 @@ "def vary_parameter(\n", " target_param, # the name of the parameter, has to exist in `param_names`\n", " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + "\n", " ):\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " pars = 0.5 * np.ones(num_pars) \n", + " # Choose parameter to vary\n", " param_idx = param_names.index(target_param)\n", "\n", " data = []\n", @@ -581,10 +589,11 @@ " for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", - " _params = pspace.param_samples[0]*pars\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", " params.append(_params)\n", " # construct `sam` and `hard` instances based on these parameters\n", - " sam, hard = pspace.model_for_normalized_params(pars)\n", + " sam, hard = pspace.model_for_params(_params)\n", " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", " hard_name = 'Fixed Time'\n", " elif isinstance(hard, holo.hardening.Hard_GW):\n", @@ -597,11 +606,13 @@ ] }, { - "attachments": {}, - "cell_type": "markdown", + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ - "## 'hard_time'" + "# print(param_names)\n", + "# print(rv_gsmf_mchar0_log10[1][1])" ] }, { @@ -610,7 +621,15 @@ "metadata": {}, "outputs": [], "source": [ - "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if " + "print(pspace.param_samples[0])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" ] }, { @@ -619,7 +638,7 @@ "metadata": {}, "outputs": [], "source": [ - "# data, params = data_hard_time, params_hard_time\n", + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", "fig = draw_three_models(*rv_hard_time)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_time)" ] @@ -651,6 +670,39 @@ "## 'gsmf_mchar0_log10'" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(rv_gsmf_phi0[0]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# dsdat1 = detect_pspace_model(rv_gsmf_phi0[0][1])\n", + "# dsdat2 = detect_pspace_model(rv_gsmf_mchar0_log10[0][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(param_names)\n", + "# print(rv_gsmf_phi0[1][2])\n", + "# print(rv_gsmf_mchar0_log10[1][1]) # this is using the wrong gsmf_phi0\n", + "# print(rv_hard_time[1][1])\n", + "# print(rv_mmb_mamp_log10[1][1])\n", + "# print(rv_mmb_scatter_dex[1][1])" + ] + }, { "cell_type": "code", "execution_count": null, From fc177c4349584ab3d70775e4bad375a6c5f62c52 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 8 Jun 2023 11:50:48 -0700 Subject: [PATCH 034/291] Updated plots for best sample 346 in ss51 library. --- .../anisotropy/healpix/learning_healpy.ipynb | 2 +- .../healpix/lib_anisotropy_ss51.ipynb | 221 +++++++++++++++--- 2 files changed, 196 insertions(+), 27 deletions(-) diff --git a/ecg-notebooks/anisotropy/healpix/learning_healpy.ipynb b/ecg-notebooks/anisotropy/healpix/learning_healpy.ipynb index ad9c3dcf..1ef44ad9 100644 --- a/ecg-notebooks/anisotropy/healpix/learning_healpy.ipynb +++ b/ecg-notebooks/anisotropy/healpix/learning_healpy.ipynb @@ -187,7 +187,7 @@ "source": [ "saveloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/healpix/2023-05-13_sam02_l10000/'\n", "for ff in range(F):\n", - " fig = ff_mollview(hc_ss, pix_ss, m_strain, ff, saveloc=saveloc)\n", + " fig = ff_mollview(hc_ss, NPIX, m_strain, ff, saveloc=saveloc)\n", " # fig.savefig(saveloc+'hp_ff%02d.png' % ff, dpi=300)\n", " # plt.close(fig)" ] diff --git a/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb b/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb index dd0a7b94..7eb727b9 100644 --- a/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb +++ b/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb @@ -9,6 +9,7 @@ "import holodeck as holo\n", "from holodeck import single_sources, utils, plot, detstats\n", "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", "\n", "import numpy as np\n", "import healpy as hp\n", @@ -232,15 +233,18 @@ "metadata": {}, "outputs": [], "source": [ - "# sspath = '/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/'\n", - "# hdfname = sspath+'ss_lib.hdf5'\n", - "# ssfile = h5py.File(hdfname, 'r')\n", - "# print(list(ssfile.keys()))\n", - "# hc_ss = ssfile['hc_ss'][...]\n", - "# hc_bg = ssfile['hc_bg'][...]\n", - "# fobs = ssfile['fobs'][:]\n", + "nn=346\n", + "\n", + "\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn,...]\n", + "hc_bg = ssfile['hc_bg'][nn,...]\n", + "fobs = ssfile['fobs'][:]\n", "# dfobs = ssfile['dfobs'][:]\n", - "# ssfile.close()\n", + "ssfile.close()\n", "\n", "# shape = hc_ss.shape\n", "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", @@ -255,6 +259,15 @@ "# Find Best Samples" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(hc_ss.shape)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -262,11 +275,24 @@ "outputs": [], "source": [ "# hc_ref15_10yr = 11.2*10**-15 \n", - "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# nsort, fidx, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", "# nbest = 100\n", "# print(hc_ref15)\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# hc_tt = np.sqrt(hc_bg[:,fidx,:]**2 + np.sum(hc_ss[:,fidx,:,:]**2, axis=-1))\n", + "# print(hc_tt.shape)\n", + "# hc_tt = np.median(hc_tt, axis=1)\n", + "# print(hc_tt.shape)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -347,6 +373,13 @@ "# ax.legend(loc='lower left')" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "attachments": {}, "cell_type": "markdown", @@ -382,7 +415,7 @@ "# np.savez(sspath+'sph_harmonics.npz', nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref15=hc_ref15, ss_shape=shape,\n", "# moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs)\n", "\n", - "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", + "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", "\n", "# load ss info\n", "shape = sph_harm_file['ss_shape']\n", @@ -405,6 +438,34 @@ "sph_harm_file.close()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Plot strain of best sample" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = fobs*YR\n", + "yy = anis.HC_REF15_10YR * (xx/.1)**(-2/3)\n", + "fidx=1\n", + "\n", + "fig = plot.plot_bg_ss(fobs, hc_bg, hc_ss[:,:,:100]) # just 100 loudest, cant see more anyway\n", + "ax = fig.axes[0]\n", + "ax.plot(xx,yy,linestyle='dashdot', color='grey', alpha=1, \n", + " label= '$(%.2e) [f/(.1 \\mathrm{yr^-1})]^{-2/3} $' % anis.HC_REF15_10YR)\n", + "ax.axhline(hc_ref15, label='15 yr ref: $h_c(%.2f/\\mathrm{yr}) = %.2e$' % (xx[fidx], hc_ref15), linestyle='dashed', color='tab:red', alpha=0.5)\n", + "ax.axvline(xx[fidx], color='tab:blue', alpha=0.5, linestyle='dashed', label='$f=%.2f\\mathrm{yr}$' % xx[fidx])\n", + "ax.set_title('Sample %d' % nn)\n", + "ax.legend(loc='lower left')" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -1054,7 +1115,7 @@ " nshow=nshow, civals = [50,98,], color='tab:orange')\n", " draw_reals(ax, xx, y3[ff], rlabel='max (sample %d), ' % nn_max, flabel = ('%.2f $yr^{-1}$' % fobs_yrs[ff]),\n", " nshow=nshow, civals = [50,98,], color='tab:green')\n", - " draw_reals(ax, xx, y4[ff], rlabel='best (sample %d), ' % nn_max, flabel = ('%.2f $yr^{-1}$' % fobs_yrs[ff]),\n", + " draw_reals(ax, xx, y4[ff], rlabel='best (sample %d), ' % nsort[0], flabel = ('%.2f $yr^{-1}$' % fobs_yrs[ff]),\n", " nshow=nshow, civals = [50,98,], color='tab:grey')\n", " ax.legend(ncols=2)\n", " ax.set_title(title)\n", @@ -1127,8 +1188,8 @@ "metadata": {}, "outputs": [], "source": [ - "def Clg0_min_max_med(lvals, Cl_best, bb_min, bb_med, bb_max, title='', ff=fidx):\n", - " fig, ax = plot.figax(figsize=(8,5), xlabel='$f$ [yrs$^{-1}$]', ylabel='$C_{\\ell>0}/C_0$')\n", + "def C1C0_min_max_med(lvals, Cl_best, bb_min, bb_med, bb_max, title='', ff=fidx):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel='$f$ [yrs$^{-1}$]', ylabel='$C_1/C_0$')\n", "\n", " xx = fobs_yrs # (l)\n", " y1 = Cl_best[bb_min] # (F,R,l)\n", @@ -1136,10 +1197,10 @@ " y3 = Cl_best[bb_max] # (F,R,l)\n", " y4 = Cl_best[0] # (F,R,l)\n", "\n", - " y1 = np.sum(y1[:,:,1:], axis=-1)/y1[:,:,0] # (F,R,l)\n", - " y2 = np.sum(y2[:,:,1:], axis=-1)/y2[:,:,0] \n", - " y3 = np.sum(y3[:,:,1:], axis=-1)/y3[:,:,0] \n", - " y4 = np.sum(y4[:,:,1:], axis=-1)/y4[:,:,0] \n", + " y1 = (y1[:,:,1])/y1[:,:,0] # (F,R,l)\n", + " y2 = (y2[:,:,1])/y2[:,:,0] \n", + " y3 = (y3[:,:,1])/y3[:,:,0] \n", + " y4 = (y4[:,:,1])/y4[:,:,0] \n", " \n", " y1=np.swapaxes(y1,0,1)\n", " y2=np.swapaxes(y2,0,1)\n", @@ -1160,7 +1221,7 @@ "\n", "title = ('50%% and 98%% confidence intervals of %d realizations, lmax=%d\\nSelected by mean $C_l/C_0$ over all freqs'\n", " % (nreals, lmax))\n", - "fig = Clg0_min_max_med(lvals, Cl_best, bb_min, bb_med, bb_max,title=title, ff=fidx)\n", + "fig = C1C0_min_max_med(lvals, Cl_best, bb_min, bb_med, bb_max,title=title, ff=fidx)\n", "\n", "\n" ] @@ -1327,11 +1388,11 @@ " yy = np.swapaxes(yy, 0, 2) # (l,R,F)\n", "\n", "\n", - " colors=np.array(['','#0a5da4', '#00ba44', '#ff9503',\n", + " colors=np.array(['#0a5da4', '#00ba44', '#ff9503',\n", " '#ff471a', '#845b98', '#474747'])\n", "\n", - " for ll in range(1,7):\n", - " draw_reals(ax, xx, yy[ll], rlabel=('$\\ell=%d$' % ll),\n", + " for ll in range(6):\n", + " draw_reals(ax, xx, yy[ll], rlabel=('$\\ell=%d$' % (ll+1)),\n", " nshow=nshow, civals=[50,], color=colors[ll])\n", "\n", " ax.legend(ncols=3)\n", @@ -1376,10 +1437,10 @@ " yy = np.swapaxes(yy, 0, 2) # (l,R,F)\n", "\n", "\n", - " colors=np.array(['','#0a5da4', '#00ba44', '#ff9503',\n", + " colors=np.array(['#0a5da4', '#00ba44', '#ff9503',\n", " '#ff471a', '#845b98', '#474747'])\n", - " for ll in range(1,7):\n", - " ax.plot(xx, yy[ll,rr], label=('$\\ell=%d$' % ll), color=colors[ll], marker='o', linestyle='-')\n", + " for ll in range(6):\n", + " ax.plot(xx, yy[ll,rr], label=('$\\ell=%d$' % (ll+1)), color=colors[ll], marker='o', linestyle='-')\n", "\n", " ax.legend(ncols=3)\n", " title = ('Sample %d (Median of mean($C_\\ell/C_0$))\\n%dth Realization'\n", @@ -1492,6 +1553,78 @@ "print('Min: Sample %d, Median: Sample %d, Max: Sample %d' % (nn_min, nn_med, nn_max))" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare to hc_ss/hc_bg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort[0])\n", + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sumfreqs_and_l = np.sum(Cl_best[0,1:,:,:], axis=(0,2))\n", + "print(sumfreqs_and_l.shape)\n", + "print(argmedian(sumfreqs_and_l, side='both'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ratio = np.sqrt(np.sum(hc_ss**2, axis=-1)/hc_bg**2)\n", + "\n", + "print(hc_ratio.shape)\n", + "\n", + "\n", + "yy = Cl_best[0] # (F,R,l)\n", + "yy = yy[:,:,1:]/yy[:,:,0,np.newaxis] # Cl/C0, F,R,l\n", + "# choose median realizaton based on all Cl/C0's at all freqs and all l\n", + "# rr=argmedian(np.sum(yy, axis=(0,2)), side='left') \n", + "rr=0\n", + "for rr in range(0,20):\n", + " fig, (ax, ax2) = plot.figax(nrows=1, ncols=2, figsize=(8,6), gridspec_kw={'width_ratios': [4, 1]})\n", + " print(rr)\n", + " colors=cm.rainbow_r(np.linspace(0,1,nfreqs))\n", + " for ff in range(nfreqs):\n", + " if ff in (0, 10, 20, 30, 38):\n", + " label= ('$f$ = %.2f nHz' % fobs_nHz[ff])\n", + " else: label = None\n", + " ax.plot(lvals[1:], yy[ff,rr,:], c=colors[ff], alpha=0.5, label=label,\n", + " marker='o')\n", + " ax2.axhline(hc_ratio[ff,rr], color=colors[ff], alpha=0.5)\n", + " ax.set_xlabel('$\\ell$')\n", + " ax.set_ylabel('$C_\\ell/C_0$')\n", + " ax.set_yscale('log')\n", + " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " ax.legend()\n", + "\n", + " ax2.set_title('$\\sqrt{h_{c,2,000\\ \\mathrm{loudest}}^2/h_{c,\\mathrm{bg}}^2}$')\n", + " ax2.set_yscale('log')\n", + " # fig.suptitle('%d Loudest Single Sources' % L, y=.895)\n", + "\n", + " fig.tight_layout()\n", + "# fig.savefig(saveloc+'all_freqs.png', dpi=1000)\n", + "\n", + "# fig" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1648,7 +1781,7 @@ "fig, axs = plt.subplots(nrows=10, ncols=int(F/10))\n", "for ff in range(F):\n", " title='$f$= %.2f yr$^{-1}$ (bin %d/%d)' % (fobs[ff]*YR, ff, F)\n", - " row, col = int(ff/3), ff%3\n", + " row, col = int(ff/4), ff%4\n", " # print(row,col)\n", " plt.axes(axs[row,col])\n", " hp.mollview(moll_hc[ff,rr], title=title, hold=True)\n", @@ -1661,6 +1794,15 @@ "# fig" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(F)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1675,7 +1817,7 @@ "fig, axs = plt.subplots(nrows=10, ncols=int(F/10))\n", "for ff in range(F):\n", " title='$f$= %.2f yr$^{-1}$ (bin %d/%d)' % (fobs[ff]*YR, ff, F)\n", - " row, col = int(ff/3), ff%3\n", + " row, col = int(ff/4), ff%4\n", " # print(row,col)\n", " plt.axes(axs[row,col])\n", " hp.mollview(moll_sh[ff,rr], title=title, hold=True)\n", @@ -1823,6 +1965,33 @@ "# fig" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x=5" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x=x*2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(x,y)" + ] + }, { "cell_type": "code", "execution_count": null, From 1d2229d71aa2af4bd4bea2fca5403fe9cf48b663 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 8 Jun 2023 14:19:37 -0700 Subject: [PATCH 035/291] Comparing anisotropy for nside=32 and nside=8, looks similar with random realizations. --- .../anisotropy/anisotropy_paper_plots.ipynb | 9 + .../anisotropy_paper_plots_nside8.ipynb | 580 ++++++++++++++++++ 2 files changed, 589 insertions(+) create mode 100644 ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb index 5decaf91..8b3d6972 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb +++ b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb @@ -130,6 +130,15 @@ "sph_harm_file.close()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, { "attachments": {}, "cell_type": "markdown", diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb b/ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb new file mode 100644 index 00000000..3b11122e --- /dev/null +++ b/ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb @@ -0,0 +1,580 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up\n", + "\n", + "## Read in library\n", + "\n", + "ss16 has 10 loudest, definitely will replace this with a better library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "# hdfname = sspath+'/sam_lib.hdf5'\n", + "# ssfile = h5py.File(hdfname, 'r')\n", + "# print(list(ssfile.keys()))\n", + "# hc_ss = ssfile['hc_ss'][...]\n", + "# hc_bg = ssfile['hc_bg'][...]\n", + "# fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "# ssfile.close()\n", + "\n", + "# shape = hc_ss.shape\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Find Best Samples" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# hc_ref15_10yr = 11.2*10**-15 \n", + "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# nbest = 100\n", + "# print(hc_ref15)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load/Calculate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# np.savez(sspath+'sph_harmonics.npz', nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref15=hc_ref15, ss_shape=shape,\n", + "# moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs)\n", + "\n", + "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside8_nbest100_nreals50.npz')\n", + "print(sph_harm_file.files)\n", + "\n", + "# load ss info\n", + "shape = sph_harm_file['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = sph_harm_file['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = sph_harm_file['nsort']\n", + "fidx = sph_harm_file['fidx']\n", + "hc_ref = sph_harm_file['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = sph_harm_file['nside']\n", + "lmax = sph_harm_file['lmax']\n", + "moll_hc_best = sph_harm_file['moll_hc_best']\n", + "Cl_best = sph_harm_file['Cl_best']\n", + "nbest = len(moll_hc_best)\n", + "\n", + "sph_harm_file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = cm.gist_rainbow(np.linspace(0, 1, lmax))\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll], label='$l=%d$' % (ll+1))\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1) \n", + " ax.legend(ncols=2)\n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def plot_Clg0_llp1_medians(xx, Cl_best, lmax, nshow):\n", + "# fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + "# yy = np.sum(Cl_best[:,:,:,1:], axis=-1)/Cl_best[:,:,:,0,] # (B,F,R)\n", + "# yy = np.median(yy, axis=-1) # (B,F) median over realizations\n", + "\n", + "# ax.plot(xx, np.median(yy, axis=0), color='k', label='median of samples, $l_\\mathrm{max}=%d$' % lmax)\n", + "# for pp in [50, 98]:\n", + "# percs = pp/2\n", + "# percs = [50-percs, 50+percs]\n", + "# ax.fill_between(xx, *np.percentile(yy, percs, axis=0), alpha=0.1, color='k')\n", + "\n", + "# colors = cm.rainbow(np.linspace(1, 0, nshow))\n", + "# bb=0\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1, label=\"individual best samples, median of realizations\")\n", + "# for bb in range(1,nshow):\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1)\n", + "# ax.legend()\n", + "# plot._twin_hz(ax, nano=False)\n", + " \n", + "# # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + "# # % (nbest, lmax))\n", + "# return fig\n", + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=100)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# for ll in range(len(Cl_nihan[0])):\n", + " \n", + "\n", + "# ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# # ax.set_xscale('linear')\n", + "# fig.legend(loc='lower right')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# # ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# ax.legend(loc='lower right')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Sato-Polito & Kamionkowski" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "ax = fig.axes[0]\n", + "\n", + "xx = freq_bins_Hz * YR \n", + "ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='tab:orange')\n", + "ax.set_xlim(0, np.max(fobs_yrs))\n", + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "hdfname = sspath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "print('Best sample:', nsort[0])\n", + "hc_ss = ssfile['hc_ss'][nsort[0],...]\n", + "hc_bg = ssfile['hc_bg'][nsort[0],...]\n", + "fobs = ssfile['fobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape = hc_ss.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "print('F,R,L =', nfreqs, nreals, nloudest)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 72c7e525b8eb68321239f73c9f8f795dec28d0d2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 8 Jun 2023 19:10:29 -0700 Subject: [PATCH 036/291] Plotting anisotropy for varying nside in varying_nside.ipynb. --- .../healpix/lib_anisotropy_ss51.ipynb | 121 +++++++- .../anisotropy/healpix/varying_nside.ipynb | 281 ++++++++++++++++++ 2 files changed, 398 insertions(+), 4 deletions(-) create mode 100644 ecg-notebooks/anisotropy/healpix/varying_nside.ipynb diff --git a/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb b/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb index 7eb727b9..7c931cb5 100644 --- a/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb +++ b/ecg-notebooks/anisotropy/healpix/lib_anisotropy_ss51.ipynb @@ -240,8 +240,8 @@ "hdfname = sspath+'sam_lib.hdf5'\n", "ssfile = h5py.File(hdfname, 'r')\n", "print(list(ssfile.keys()))\n", - "hc_ss = ssfile['hc_ss'][nn,...]\n", - "hc_bg = ssfile['hc_bg'][nn,...]\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", "fobs = ssfile['fobs'][:]\n", "# dfobs = ssfile['dfobs'][:]\n", "ssfile.close()\n", @@ -438,6 +438,15 @@ "sph_harm_file.close()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(moll_hc_best.shape)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -1965,13 +1974,104 @@ "# fig" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare nside for same mollview map" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## just one sample" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "x=5" + "print(hc_ss.shape)\n", + "print(nn, nsort[nn])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Cl_nn_nside08 = np.zeros_like(Cl_best[0])\n", + "Cl_nn_nside16 = np.zeros_like(Cl_best[0])\n", + "Cl_nn_nside32 = np.zeros_like(Cl_best[0])\n", + "\n", + "moll_hc08 = anis." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.array([Cl_nn_nside08, Cl_nn_nside16, Cl_nn_nside32]).shape)\n", + "print(lmax)\n", + "print(holo.utils.stats(Cl_nn_nside08))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_dif_nside(fobs, Cl, lmax, bb, ff):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel='$f$', ylabel='$C_\\ell/C_0$', xscale='linear')\n", + " \n", + " xx = fobs # (F)\n", + " yy_nsides = Cl[...,1]/Cl[...,0]\n", + " nsides=(8,16,32)\n", + "\n", + " colors=cm.rainbow(np.linspace(0,1,len(Cl)))\n", + "\n", + " # ax.plot(xx, np.median(yy[:,ff,:], axis=0), color=colors[ff], label=label,\n", + " # linewidth=4)\n", + " # for pp in [50,]:\n", + " # percs = pp/2\n", + " # percs = [50-percs, 50+percs]\n", + " # ax.fill_between(xx, *np.percentile(yy[:,ff,:], percs, axis=0), alpha=0.25, color=colors[ff],\n", + " # linestyle='solid', linewidth=3)\n", + " \n", + " for ii, yy in enumerate(yy_nsides):\n", + " print(f\"{yy.shape=}\")\n", + " ax.plot(xx, np.median(yy, axis=-1), label=('nside=%d' % nsides[ii]))\n", + " print(holo.utils.stats(np.median(yy, axis=-1)))\n", + " print(f\"{np.median(yy, axis=-1).shape=}\")\n", + " # med, ci = np.percentile(yy, (50, 5, 95), axis=1)\n", + " # print(f\"{med.shape=}\")\n", + " # ax.plot(xx, med)\n", + " \n", + "\n", + " ax.legend()\n", + " # ax.set_title('Sample %d: 50%% confidence intervals of the %d realizations, lmax=%d'\n", + " # % (nsort[bb], nreals, lmax))\n", + " return fig\n", + "\n", + "fig = plot_ClC0_dif_nside(fobs, Cl=np.array([Cl_nn_nside08, Cl_nn_nside16, Cl_nn_nside32]),\n", + " lmax = lmax, bb=0, ff = 1, \n", + " )" ] }, { @@ -1989,7 +2089,20 @@ "metadata": {}, "outputs": [], "source": [ - "print(x,y)" + "Cl_346_nside08 = np.zeros_like(Cl_best)\n", + "Cl_best_nside16 = np.zeros_like(Cl_best)\n", + "Cl_best_nside32 = np.zeros_like(Cl_best)\n", + "for nn in range(0,):\n", + " print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + " temp, Cl_best_nside08[nn,...] = sph_harm_from_hc(hc_ss, \n", + " hc_bg,\n", + " nside=8, lmax=lmax)\n", + " temp, Cl_best_nside16[nn,...] = sph_harm_from_hc(hc_ss, \n", + " hc_bg,\n", + " nside=16, lmax=lmax)\n", + " temp, Cl_best_nside32[nn,...] = sph_harm_from_hc(hc_ss, \n", + " hc_bg,\n", + " nside=32, lmax=lmax)" ] }, { diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb new file mode 100644 index 00000000..106d9963 --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb @@ -0,0 +1,281 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=346\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", + "fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape=hc_ss.shape\n", + "nfreqs = shape[-3]\n", + "nreals = shape[-2]\n", + "nloudest = shape[-1]\n", + "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]/np.sqrt(npix)) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "nsides=np.array([8,16,32, 64, 128])\n", + "moll_bg08 = make_bg_map(hc_bg, nside=8)\n", + "moll_bg16 = make_bg_map(hc_bg, nside=16)\n", + "moll_bg32 = make_bg_map(hc_bg, nside=32)\n", + "moll_bg64 = make_bg_map(hc_bg, nside=64)\n", + "moll_bg128 = make_bg_map(hc_bg, nside=128)\n", + "print(moll_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2\n", + " + hc_ss[ff,rr,ll]**2)\n", + " return moll_ss, pix_ss\n", + "moll_ss08, pix_ss08 = make_ss_map(hc_ss, 8)\n", + "print(f\"{moll_ss08.shape=}\")\n", + "print(f\"{pix_ss08.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def convert_pix_ss(pix_ss1, nside1, nside2):\n", + " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", + " print(f\"{theta.shape=}, {phi.shape=}\")\n", + " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", + " return pix_ss2\n", + "\n", + "pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll_ss16, temp = make_ss_map(hc_ss, 16, pix_ss16)\n", + "moll_ss32, temp = make_ss_map(hc_ss, 32, pix_ss32)\n", + "moll_ss64, temp = make_ss_map(hc_ss, 64, pix_ss64)\n", + "moll_ss128, temp = make_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll_tt08 = np.sqrt(moll_ss08**2 + moll_bg08**2)\n", + "moll_tt16 = np.sqrt(moll_ss16**2 + moll_bg16**2)\n", + "moll_tt32 = np.sqrt(moll_ss32**2 + moll_bg32**2)\n", + "moll_tt64 = np.sqrt(moll_ss64**2 + moll_bg64**2)\n", + "moll_tt128 = np.sqrt(moll_ss128**2 + moll_bg128**2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "rr=0\n", + "for ff in range(0,5):\n", + " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + " plt.axes(axs[0])\n", + " hp.mollview(moll_tt08[ff,rr], title='f=%.2f yr$^{-1}$, nside=%d'\n", + " % (fobs[ff]*YR, 8), hold=True )\n", + " plt.axes(axs[1])\n", + " hp.mollview(moll_tt16[ff,rr], title='f=%.2f yr$^{-1}$, nside=%d'\n", + " % (fobs[ff]*YR, 16), hold=True )\n", + " plt.axes(axs[2])\n", + " hp.mollview(moll_tt32[ff,rr], title='f=%.2f yr$^{-1}$, nside=%d'\n", + " % (fobs[ff]*YR, 32), hold=True )\n", + " fig.tight_layout()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lmax=6\n", + "Cl_08 = anis.sph_harm_from_map(moll_tt08, lmax=6)\n", + "Cl_16 = anis.sph_harm_from_map(moll_tt16, lmax=6)\n", + "Cl_32 = anis.sph_harm_from_map(moll_tt32, lmax=6)\n", + "Cl_64 = anis.sph_harm_from_map(moll_tt64, lmax=6)\n", + "Cl_128 = anis.sph_harm_from_map(moll_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Cl_arrs = np.array([Cl_08, Cl_16, Cl_32, Cl_64, Cl_128])\n", + "print(Cl_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl_arrs[...,ll]/Cl_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,:,rr], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl_arrs[...,ll]/Cl_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 5d0cf7f0dfc1f2f17f0042e78320aad8651c8269 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 10 Jun 2023 17:01:32 -0700 Subject: [PATCH 037/291] Investigating weird spike/discontinuity is hs, traced back to redz_final. --- .../anisotropy/an2A_orangespike.ipynb | 1529 +++++++++++++++++ .../anisotropy/an2B_weird_redz_final.ipynb | 459 +++++ .../an2_investigation_integrals.ipynb | 242 ++- .../anisotropy/healpix/varying_nside.ipynb | 3 +- holodeck/anisotropy.py | 2 +- 5 files changed, 2230 insertions(+), 5 deletions(-) create mode 100644 ecg-notebooks/anisotropy/an2A_orangespike.ipynb create mode 100644 ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb diff --git a/ecg-notebooks/anisotropy/an2A_orangespike.ipynb b/ecg-notebooks/anisotropy/an2A_orangespike.ipynb new file mode 100644 index 00000000..70fd8076 --- /dev/null +++ b/ecg-notebooks/anisotropy/an2A_orangespike.ipynb @@ -0,0 +1,1529 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "from holodeck.constants import YR, MSOL, GYR\n", + "from holodeck import utils\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import numpy as np" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "* dens = d^3 n / [dlog10M dq dz] in units of [Mpc^-3] \n", + "* dnum = d^4N / dlog10M dq dz dlnf\n", + "* number = dN /dlnf" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "sam_model()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def sam_model(sam, hard,\n", + " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", + " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " else:\n", + " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", + "\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " if use_redz:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges, redz_final)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges, redz_final)\n", + " else:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges)\n", + "\n", + " vals = {\n", + " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", + " 'hs_cents':hs_cents, 'hs_edges':hs_edges, 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", + " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", + " }\n", + " return vals\n", + "\n", + "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", + " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " return num\n", + "def integrate_qq(dnum, edges): # integrate dN/dq\n", + " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", + " return num\n", + "def integrate_zz(dnum, edges): # dN/dz\n", + " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", + " return num\n", + "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", + " num = dnum*np.diff(np.log(fobs_gw_edges))\n", + " return num " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_dnum_dpar() vs each edge parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_dnum_dpar(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(18,5),\n", + " sharey=True\n", + " )\n", + "\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + "\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$dN/d\\log (M)$', '$dN/dq$', '$dN/dz$'])\n", + "\n", + " xx = np.array([edges_mm/MSOL, edges_qq, edges_zz])\n", + "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " yy = np.array([dnum_mm[:,qq,zz,ff], dnum_qq[mm,:,zz,ff], dnum_zz[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy[ii], label=labels[ii], alpha=0.75, \n", + " )\n", + " for ii, ax in enumerate(axs): \n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend(loc='upper right')\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_number() by cython, utils, trapz, and rounding down" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_number(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + "\n", + " cynum = vals['number']\n", + " tznum = integrate_zz(dnum_zz, edges)\n", + " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "\n", + " flnum = np.floor(cynum)\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$N (M)$', '$N(q)$', '$N(z)$'])\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " \n", + " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[mm,qq,:,ff]])\n", + " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[mm,qq,:,ff]])\n", + " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[mm,qq,:,ff]])\n", + " yy_flor = np.array([flnum[:,qq,zz,ff], flnum[mm,:,zz,ff], flnum[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_cyth[ii], label=labels[ii]+' cython', linestyle='-', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_trap[ii], label=labels[ii]+' trapz', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_flor[ii], label=labels[ii]+' floor', linestyle='-.', alpha=0.75 \n", + " )\n", + " for ii, ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_strain_amp() for initial and final z" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_strain_amp(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " # dnum = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + "\n", + " hs_final = anis.strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", + " hs_initz = anis.strain_amp_at_bin_centers_redz(edges, redz=None)\n", + " print(holo.utils.stats(hs_final/hs_initz))\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$h_s (M)$', '$h_s(q)$', '$h_s(z)$'])\n", + "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " yy_initz = np.array([hs_initz[:,qq,zz,ff], hs_initz[mm,:,zz,ff], hs_initz[mm,qq,:,ff]])\n", + " yy_final = np.array([hs_final[:,qq,zz,ff], hs_final[mm,:,zz,ff], hs_final[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_initz[ii], label=labels[ii]+' initial z', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_final[ii], label=labels[ii]+' final z', linestyle='-', alpha=0.75 \n", + " )\n", + " for ii, ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_number_times_h2()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_number_times_h2(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " hs_cents = vals['hs_cents']\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + "\n", + " cynum = vals['number']*hs_cents**2\n", + " tznum = integrate_zz(dnum_zz, edges)*hs_cents**2\n", + " utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " utnum = utnum * np.diff(np.log(fobs_gw_edges))*hs_cents**2\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array([r'$N (M)\\times h_s^2$', r'$N(q)\\times h_s^2$', r'$N(z)\\times h_s^2$'])\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " \n", + " yy_cyth = np.array([cynum[:,qq,zz,ff], cynum[mm,:,zz,ff], cynum[mm,qq,:,ff]])\n", + " yy_trap = np.array([tznum[:,qq,zz,ff], tznum[mm,:,zz,ff], tznum[mm,qq,:,ff]])\n", + " yy_util = np.array([utnum[:,qq,zz,ff], utnum[mm,:,zz,ff], utnum[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " ax.plot(xx[ii], yy_cyth[ii], label=labels[ii]+' cython', linestyle='-', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_trap[ii], label=labels[ii]+' trapz', linestyle='--', alpha=0.75 \n", + " )\n", + " ax.plot(xx[ii], yy_util[ii], label=labels[ii]+' utils', linestyle=':', alpha=0.75 \n", + " )\n", + " for ii, ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + " ax.legend()\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_integrated()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_integrated(vals, mm_arr, qq_arr, zz_arr, ff_arr):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + " hs_cents = vals['hs_cents']\n", + " hs_edges = vals['hs_edges']\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + "\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", + " numh4_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", + " # print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", + "\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " # print('dnum_qq:', dnum_qq.shape)\n", + " print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", + " numh2_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", + " numh4_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**4, edges)\n", + " \n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**2, edges)\n", + " numh4_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**4, edges)\n", + "\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels_h2 = np.array(['$\\int h_s^2 dN/d\\log (M)$', '$\\int h_s^2 dN/dq$', '$\\int h_s^2 dN/dz$'])\n", + " ylabels_h4 = np.array(['$\\int h_s^4 dN/d\\log (M)$', '$\\int h_s^4 dN/dq$', '$\\int h_s^4 dN/dz$'])\n", + "\n", + " cynum = vals['number']\n", + " numh2_cy = cynum*hs_cents**2\n", + " numh4_cy = cynum*hs_cents**4\n", + "\n", + "\n", + " flnum = np.floor(cynum)\n", + " numh2_fl = flnum*hs_cents**2\n", + " numh4_fl = flnum*hs_cents**4\n", + " # tznum = integrate_zz(dnum_zz, edges)\n", + " # utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " # utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, figsize=(16,8))\n", + "\n", + "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " yy_h2 = np.array([numh2_mm[:,qq,zz,ff], numh2_qq[mm,:,zz,ff], numh2_zz[mm,qq,:,ff]])\n", + " yy_h4 = np.array([numh4_mm[:,qq,zz,ff], numh4_qq[mm,:,zz,ff], numh4_zz[mm,qq,:,ff]])\n", + " cy_h2 = np.array([numh2_cy[:,qq,zz,ff], numh2_cy[mm,:,zz,ff], numh2_cy[mm,qq,:,ff]])\n", + " cy_h4 = np.array([numh4_cy[:,qq,zz,ff], numh4_cy[mm,:,zz,ff], numh4_cy[mm,qq,:,ff]])\n", + " fl_h2 = np.array([numh2_fl[:,qq,zz,ff], numh2_fl[mm,:,zz,ff], numh2_fl[mm,qq,:,ff]])\n", + " fl_h4 = np.array([numh4_fl[:,qq,zz,ff], numh4_fl[mm,:,zz,ff], numh4_fl[mm,qq,:,ff]])\n", + " labels = np.array(['$q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_zz[zz], fobs_gw_cents[ff]*YR),\n", + " '$M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR),])\n", + "\n", + " for ii, ax in enumerate(axs[0,:]): # h2\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times$ cynum'\n", + " fllabel=r'$h_s^2 \\times$ flnum'\n", + " else: \n", + " cylabel=None\n", + " fllabel=None\n", + " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.35, lw=4)\n", + " cc = ll.get_color()\n", + " ax.plot(xx[ii], fl_h2[ii], label=fllabel, linestyle='-', alpha=0.65, color=cc, lw=2)\n", + " ax.plot(xx[ii], yy_h2[ii], label=labels[ii], linestyle='--', alpha=0.75, color=cc, lw=1)\n", + " for ii, ax in enumerate(axs[1,:]): # h4\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times$ cynum'\n", + " fllabel=r'$h_s^2 \\times$ flnum'\n", + " else: \n", + " cylabel=None\n", + " fllabel=None\n", + " # ll, = ax.plot(xx[ii], cy_h4[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " ll = ax.scatter(xx[ii], cy_h4[ii], label=cylabel, marker='o', alpha=0.35, lw=3, s=10)\n", + " # cc = ll.get_color()\n", + " # ax.plot(xx[ii], yy_h4[ii], label=labels[ii], linestyle='x', alpha=0.75, color=cc )\n", + " cc = ll.get_facecolors()\n", + " ax.scatter(xx[ii], fl_h4[ii], label=fllabel, marker='+', alpha=0.65, color=cc)\n", + " ax.scatter(xx[ii], yy_h4[ii], label=labels[ii], marker='x', alpha=0.75, color=cc )\n", + " \n", + " \n", + "\n", + " for ii, ax in enumerate(axs[0,:]):\n", + " ax.set_ylabel(ylabels_h2[ii])\n", + " # if ii>0: ax.sharey(axs[0,0])\n", + " ax.legend(fontsize=8)\n", + " for ii, ax in enumerate(axs[1,:]):\n", + " ax.set_ylabel(ylabels_h4[ii])\n", + " ax.set_xlabel(xlabels[ii])\n", + " # if ii>0: ax.sharey(axs[1,0])\n", + " ax.sharex(axs[0,ii])\n", + " ax.legend(fontsize=8)\n", + "\n", + " fig.suptitle('%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape)))\n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_integrated_vary()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calc_integrated(vals):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + "\n", + " hs_cents = vals['hs_cents']\n", + " hs_edges = vals['hs_edges']\n", + "\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", + " numh4_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", + " # print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", + "\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " # print('dnum_qq:', dnum_qq.shape)\n", + " # print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", + " numh2_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", + " numh4_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**4, edges)\n", + " \n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**2, edges)\n", + " numh4_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**4, edges)\n", + " cynum = vals['number']\n", + " numh2_cy = cynum*hs_cents**2\n", + " numh4_cy = cynum*hs_cents**4\n", + "\n", + "\n", + " flnum = np.floor(cynum)\n", + " numh2_fl = flnum*hs_cents**2\n", + " numh4_fl = flnum*hs_cents**4\n", + " # tznum = integrate_zz(dnum_zz, edges)\n", + " # utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " # utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " # print(f\"{xx.shape=}\")\n", + "\n", + " return (xx, numh2_mm, numh2_qq, numh2_zz, numh4_mm, numh4_qq, numh4_zz, \n", + " numh2_cy, numh4_cy, numh2_fl, numh4_fl)\n", + "\n", + "\n", + "\n", + "def plot_integrated_vary(vals, mm_arr, qq_arr, zz_arr, ff_arr, vary='mm'):\n", + "\n", + " # if vary == 'mm':\n", + " # colors=cm.rainbow_r(np.linspace(0,1,np.max(mm_arr)+1))\n", + " # elif vary == 'qq':\n", + " # colors=cm.rainbow_r(np.linspace(0,1,np.max(qq_arr)+1))\n", + " # elif vary == 'zz':\n", + " # colors=cm.rainbow_r(np.linspace(0,1,np.max(zz_arr)+1))\n", + " # else:\n", + " # colors=cm.rainbow_r(np.linspace(0,1,np.max(ff_arr)+1))\n", + "\n", + " if vary == 'mm':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(mm_arr)))\n", + " elif vary == 'qq':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(qq_arr)))\n", + " elif vary == 'zz':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(zz_arr)))\n", + " else:\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(ff_arr)))\n", + "\n", + "\n", + "\n", + " (xx, numh2_mm, numh2_qq, numh2_zz, numh4_mm, numh4_qq, numh4_zz, \n", + " numh2_cy, numh4_cy, numh2_fl, numh4_fl) = calc_integrated(vals)\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, figsize=(16,8))\n", + "\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels_h2 = np.array(['$\\int h_s^2 dN/d\\log (M)$', '$\\int h_s^2 dN/dq$', '$\\int h_s^2 dN/dz$'])\n", + " ylabels_h4 = np.array(['$\\int h_s^4 dN/d\\log (M)$', '$\\int h_s^4 dN/dq$', '$\\int h_s^4 dN/dz$'])\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + "\n", + "\n", + "\n", + " for mi,mm in enumerate(mm_arr):\n", + " for qi,qq in enumerate(qq_arr):\n", + " for zi,zz in enumerate(zz_arr):\n", + " for fi,ff in enumerate(ff_arr):\n", + " if vary == 'mm':\n", + " color=colors[mi]\n", + " elif vary == 'qq':\n", + " color=colors[qi]\n", + " elif vary == 'zz':\n", + " color=colors[zi]\n", + " else:\n", + " color=colors[fi]\n", + " \n", + " yy_h2 = np.array([numh2_mm[:,qq,zz,ff], numh2_qq[mm,:,zz,ff], numh2_zz[mm,qq,:,ff]])\n", + " yy_h4 = np.array([numh4_mm[:,qq,zz,ff], numh4_qq[mm,:,zz,ff], numh4_zz[mm,qq,:,ff]])\n", + " cy_h2 = np.array([numh2_cy[:,qq,zz,ff], numh2_cy[mm,:,zz,ff], numh2_cy[mm,qq,:,ff]])\n", + " cy_h4 = np.array([numh4_cy[:,qq,zz,ff], numh4_cy[mm,:,zz,ff], numh4_cy[mm,qq,:,ff]])\n", + " # fl_h2 = np.array([numh2_fl[:,qq,zz,ff], numh2_fl[mm,:,zz,ff], numh2_fl[mm,qq,:,ff]])\n", + " # fl_h4 = np.array([numh4_fl[:,qq,zz,ff], numh4_fl[mm,:,zz,ff], numh4_fl[mm,qq,:,ff]])\n", + " label0 = '$M=%.2e\\ M_\\odot$, $q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (xx[0,mm], xx[1,qq], xx[2,zz], fobs_gw_cents[ff]*YR)\n", + " for ii, ax in enumerate(axs[0,:]): # h2\n", + " label = label0 if ii==0 else None\n", + "\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " fllabel=r'rounded $h_s^2 \\times \\int dN/dx$'\n", + " else: \n", + " cylabel=None\n", + " fllabel=None\n", + " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.35, lw=4, color=color)\n", + " cc = ll.get_color()\n", + " # ax.plot(xx[ii], fl_h2[ii], label=fllabel, linestyle='-', alpha=0.65, color=cc, lw=2)\n", + " ax.plot(xx[ii], yy_h2[ii], label=label, linestyle='--', alpha=0.75, color=cc, lw=1)\n", + " for ii, ax in enumerate(axs[1,:]): # h4\n", + " # if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " # cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " # fllabel=r'rounded $h_s^2 \\times \\int dN/dx$'\n", + " # else: \n", + " cylabel=None\n", + " fllabel=None\n", + " # ll, = ax.plot(xx[ii], cy_h4[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " ll = ax.scatter(xx[ii], cy_h4[ii], label=cylabel, marker='o', alpha=0.35, lw=3, s=10, color=color)\n", + " # cc = ll.get_color()\n", + " # ax.plot(xx[ii], yy_h4[ii], label=labels[ii], linestyle='x', alpha=0.75, color=cc )\n", + " cc = ll.get_facecolors()\n", + " # ax.scatter(xx[ii], fl_h4[ii], label=fllabel, marker='+', alpha=0.65, color=cc)\n", + " ax.scatter(xx[ii], yy_h4[ii], label=None, marker='x', alpha=0.75, color=cc ) \n", + "\n", + " for ii, ax in enumerate(axs[0,:]):\n", + " ax.set_ylabel(ylabels_h2[ii])\n", + " # if ii>0: ax.sharey(axs[0,0])\n", + " # ax.legend(fontsize=8)\n", + " for ii, ax in enumerate(axs[1,:]):\n", + " ax.set_ylabel(ylabels_h4[ii])\n", + " ax.set_xlabel(xlabels[ii])\n", + " # if ii>0: ax.sharey(axs[1,0])\n", + " ax.sharex(axs[0,ii])\n", + " # ax.legend(fontsize=8)\n", + " leg = fig.legend(ncols=3, bbox_to_anchor=(0.05,0), loc='upper left', fontsize=14)\n", + " title = ('%s, %s, Varying %s' % (str(vals['hard_name']), str(vals['sam'].shape), vary))\n", + "\n", + " fig.suptitle(title)\n", + " fig.tight_layout()\n", + " return fig, title\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot strain_amp_vary()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "def calc_strain_amp(vals):\n", + " # dnum = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + "\n", + " hs_final = anis.strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", + " hs_initz = anis.strain_amp_at_bin_centers_redz(edges, redz=None)\n", + " # print(holo.utils.stats(hs_final/hs_initz))\n", + "\n", + " return hs_initz, hs_final, cents_mm, cents_qq, cents_zz\n", + "\n", + "def plot_strain_amp_vary(vals, mm_arr, qq_arr, zz_arr, ff_arr, vary='ff', initz=True):\n", + " hs_initz, hs_final, cents_mm, cents_qq, cents_zz = calc_strain_amp(vals)\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + "\n", + "\n", + " if vary == 'mm':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(mm_arr)))\n", + " elif vary == 'qq':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(qq_arr)))\n", + " elif vary == 'zz':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(zz_arr)))\n", + " else:\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(ff_arr)))\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$h_s (M)$', '$h_s(q)$', '$h_s(z)$'])\n", + "\n", + "\n", + " for mi,mm in enumerate(mm_arr):\n", + " for qi,qq in enumerate(qq_arr):\n", + " for zi,zz in enumerate(zz_arr):\n", + " for fi,ff in enumerate(ff_arr):\n", + " if vary == 'mm':\n", + " color=colors[mi]\n", + " elif vary == 'qq':\n", + " color=colors[qi]\n", + " elif vary == 'zz':\n", + " color=colors[zi]\n", + " else:\n", + " color=colors[fi]\n", + " \n", + " yy_initz = np.array([hs_initz[:,qq,zz,ff], hs_initz[mm,:,zz,ff], hs_initz[mm,qq,:,ff]])\n", + " yy_final = np.array([hs_final[:,qq,zz,ff], hs_final[mm,:,zz,ff], hs_final[mm,qq,:,ff]])\n", + " label_ii = ('$M=%.2e\\ M_\\odot$, $q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR))\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " label=label_ii if ii==0 else None\n", + " if initz:\n", + " if ii==0 and mi==0 and qi==0 and zi==0 and fi==0:\n", + " label_init = 'initial z'\n", + " else: label_init=None\n", + " ax.plot(xx[ii], yy_initz[ii], label=label_init, linestyle='--', alpha=0.65, \n", + " color=color)\n", + " ax.plot(xx[ii], yy_final[ii], label=label, linestyle='-', alpha=0.75, \n", + " color=color,)\n", + " for ii, ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " leg = fig.legend(ncols=3, bbox_to_anchor=(0.05,0), loc='upper left', fontsize=14)\n", + " title='%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape))\n", + " fig.suptitle(title)\n", + " fig.tight_layout\n", + " return fig, title" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Orange Spike" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## FT, shape 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam=holo.sam.Semi_Analytic_Model(shape=20)\n", + "valsFT20 = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals=valsFT20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_dnum_dpar(vals, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "# fig = plot_strain_amp(vals, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", + "# fig = plot_number(vals, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[32])\n", + "# fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(vals['fobs_gw_cents'][3]/2, utils.midpoints(vals['edges'][3], log=True)[3])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# vary mass, finding weird things happen\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[0,4,9,14,18], qq_arr=[17,], zz_arr=[17,], ff_arr=[32], vary='mm')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### first ff dropoff" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# vary ff, finding weird things happen at high frequencies\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[17,], zz_arr=[17,], ff_arr=[0,10,20,30,38], vary='ff')\n", + "# find where we have dropoff, between 10 and 20\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[17,], zz_arr=[15,], ff_arr=[10,12,14,16,18,20], vary='ff')\n", + "fig.suptitle(title+', first dropoff between ff=10 and ff=20')\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[17,], zz_arr=[15,], ff_arr=[16,17,18,], vary='ff')\n", + "fig.suptitle(title+', first dropoff at ff=15 = fobs_orb=%.2e/yr' % (utils.midpoints(vals['edges'][3], log=True)[15]*YR))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### first ff discontinuity" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# find where we have full discontinuity, between 20 and 30\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[17,], zz_arr=[15,], ff_arr=[20,24,26,28,30], vary='ff')\n", + "fig.suptitle(title+', first discontinuity between ff=20 and ff=30')\n", + "# first discontinuity between 24 and 26\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[17,], zz_arr=[15,], ff_arr=[24,25,26], vary='ff')\n", + "fig.suptitle(title+', first discontinuity at ff=25 = fobs_orb = %.2e /yr' % (utils.midpoints(vals['edges'][3], log=True)[25]*YR))\n", + "# fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[17,], zz_arr=[15,], ff_arr=[25,], vary='ff')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### first qq discontinuity\n", + "\n", + "qq only even shows up for low mm or high zz. should be overlap at mm=15\n", + "overlap exists at mm=15, ff=28\n", + "\n", + "discontinuity is independent of qq" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# vary zz\n", + "# everything else looks normal at these weird\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[0,4,9,14,18,], zz_arr=[17,], ff_arr=[28,], vary='qq')\n", + "fig.suptitle(title+', discontinuity independent of qq')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### first mm discontinuity" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig,title = plot_integrated_vary(vals, mm_arr=[7,12,15,18], qq_arr=[17,], zz_arr=[17,], ff_arr=[28,], vary='mm')\n", + "fig.suptitle(title+', first discontinuity between mm=12 and mm=15')\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[14,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[28,], vary='mm')\n", + "fig.suptitle(title+', first discontinuity at mm=15=%.2e' % (utils.midpoints(vals['edges'][0], log=True)[15]/MSOL))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### varying z, find exact weird spots" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "fig,title = plot_integrated_vary(vals, mm_arr=[15], qq_arr=[18,], zz_arr=[10,12,14,16,18], ff_arr=[28,], vary='zz')\n", + "fig.suptitle(title+', discontinuity at zz=16, $z$=%.2e' % (utils.midpoints(vals['edges'][2], log=True)[16]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "zz_cents = utils.midpoints(vals['edges'][2], log=True)\n", + "for zz in range(len(zz_cents)):\n", + " print('zz=',zz, zz_cents[zz])\n", + "\n", + "# weird stuff happens between z=1 and z=3" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### look at hs for the weird case" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, title = plot_strain_amp_vary(vals, mm_arr=[15,], qq_arr=[18,], zz_arr=[18,], ff_arr=[0,4,9,14,19,24,29,34,38], vary='ff')\n", + "fig, title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[18,], zz_arr=[18,], ff_arr=[0,4,9,14,19,24,29,34,38], vary='ff')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculating hs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(vals['fobs_gw_cents'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(utils.midpoints(sam.redz, log=True)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig, title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[18,], zz_arr=[18,], ff_arr=[0,4,9,14,19,24,29,34,38], vary='ff')\n", + "\n", + "mm, qq, zz, ff = 15, 18, 15, 28 # weird spot\n", + "temp=calc_strain_amp(vals)\n", + "hs_init, hs_final =temp[0], temp[1]\n", + "print('hs_init:', utils.stats(hs_init), f\", {hs_init.shape=}\")\n", + "print('hs_final:', utils.stats(hs_final), f\", {hs_init.shape=}\")\n", + "rz_init = utils.midpoints(sam.redz)\n", + "rz_final = utils.midpoints(vals['redz_final'], axis=(0,), log=True)\n", + "rz_final = utils.midpoints(rz_final, axis=(1,), log=True)\n", + "rz_final = utils.midpoints(rz_final, axis=(2,), log=True)\n", + "print('rz_final:', utils.stats(rz_final), rz_final.shape)\n", + "for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_final=%.2f, hs_init=%.2e, hs_final=%.2e' \n", + " % (zz, rz_init[zz], rz_final[mm,qq,zz,ff], hs_init[mm,qq,zz,ff], hs_final[mm,qq,zz,ff]))\n", + "# print(holo.utils.stats(hs[mm,qq,zz,ff]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# final redshift\n", + "fobs_orb_cents=vals['fobs_orb_cents']\n", + "hard = vals['hard']\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "\n", + "mtot = utils.midpoints(sam.mtot)\n", + "mrat = utils.midpoints(sam.mrat)\n", + "mchirp = utils.chirp_mass_mtmr(mtot[:,np.newaxis], mrat[np.newaxis,:])\n", + "\n", + "redz_init = utils.midpoints(sam.redz)\n", + "dcom = holo.cosmo.comoving_distance(redz_init).cgs.value\n", + "\n", + "frst_orb = utils.frst_from_fobs(fobs_orb_cents[np.newaxis,:], redz_init[:,np.newaxis])\n", + "\n", + "\n", + "\n", + "mm=15\n", + "qq=18\n", + "zz=15\n", + "ff=28\n", + "hs15 = holo.utils.gw_strain_source(mchirp[mm,qq], dcom[zz], frst_orb[zz,ff])\n", + "print(hs15)\n", + "\n", + "mm=15\n", + "qq=18\n", + "zz=16\n", + "ff=28\n", + "hs16 = holo.utils.gw_strain_source(mchirp[mm,qq], dcom[zz], frst_orb[zz,ff])\n", + "print(hs16)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rz = redz_final\n", + "print(redz_final[mm,qq,15,28])\n", + "print(redz_final[mm+1,qq,15,28])\n", + "print(np.mean(rz[mm,qq,15,ff], rz[mm+1,qq,15,ff], rz[mm,qq+1,zz,ff]))\n", + "print(redz_final[mm,qq,16,28])\n", + "print(redz_final[mm+1,qq,16,28])\n", + "print(redz_final[mm,qq,17,28])\n", + "print(redz_final[mm+1,qq,17,28])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%.2e %.2e' % (edges[0][mm]/MSOL, edges[0][mm+1]/MSOL))\n", + "print('%.2e %.2e' % (edges[2][15], edges[2][16]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.max(edges[2]))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "check final redz hs calculation from bin edges in gravwaves" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "\n", + "\n", + "hs_final = holo.gravwaves.strain_amp_from_bin_edges_redz(vals['edges'], vals['redz_final'])\n", + "hs_init = anis.strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", + "hs_final_anis = anis.strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n", + "print(np.all(hs_final == hs_final_anis)) # check, I am calculating hs correctly\n", + "rzfinal_cents = utils.midpoints(redz_final, log=True, axis=0)\n", + "rzfinal_cents = utils.midpoints(rzfinal_cents, log=True, axis=1)\n", + "rzfinal_cents = utils.midpoints(rzfinal_cents, log=True, axis=2)\n", + "\n", + "mm, qq, zz, ff = 15, 18, 15, 28 # weird input\n", + "for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_final_edge=%.2f, z_final_cents=%.2f, hs_init=%.2e, hs_final=%.2e' \n", + " % (zz, rz_init[zz], rz_final[mm,qq,zz,ff], rzfinal_cents[mm,qq,zz,ff], hs_init[mm,qq,zz,ff], hs_final[mm,qq,zz,ff]))\n", + " \n", + "print('low ff')\n", + "mm, qq, zz, ff = 15, 18, 15, 18 # weird input\n", + "for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_final=%.2f, z_final_cents=%.2f, hs_init=%.2e, hs_final=%.2e' \n", + " % (zz, rz_init[zz], rz_final[mm,qq,zz,ff], rzfinal_cents[mm,qq,zz,ff], hs_init[mm,qq,zz,ff], hs_final[mm,qq,zz,ff]))\n", + " \n", + "print('lower zz')\n", + "mm, qq, zz, ff = 15, 18, 15, 28 # weird input\n", + "for zz in (4,5,6):\n", + " print('zz=%d, z_init=%.2f, z_final=%.2f, z_final_cents=%.2f, hs_init=%.2e, hs_final=%.2e' \n", + " % (zz, rz_init[zz], rz_final[mm,qq,zz,ff], rzfinal_cents[mm,qq,zz,ff], hs_init[mm,qq,zz,ff], hs_final[mm,qq,zz,ff]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "print(sam._redz_final)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import kalepy as kale" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_orb_edges=vals['fobs_orb_edges']\n", + "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "\n", + "hs_final = holo.gravwaves.strain_amp_from_bin_edges_redz(edges, redz_final)\n", + "\n", + "redz=redz_final\n", + "\n", + "for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n", + "\n", + "\n", + "rzfinal_cents = utils.midpoints(redz_final, log=False, axis=0)\n", + "rzfinal_cents = utils.midpoints(rzfinal_cents, log=False, axis=1)\n", + "rzfinal_cents = utils.midpoints(rzfinal_cents, log=False, axis=2)\n", + "\n", + "mm, qq, zz, ff = 15, 18, 15, 28 # weird input\n", + "for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_final_edge=%.2f, z_f_cents_kale=%.2f, z_f_cents_utils=%.2f, hs_init=%.2e, hs_final=%.2e' \n", + " % (zz, rz_init[zz], rz_final[mm,qq,zz,ff], redz[mm,qq,zz,ff], rzfinal_cents[mm,qq,zz,ff],\n", + " hs_init[mm,qq,zz,ff], hs_final[mm,qq,zz,ff]))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# intermediates of char_strain_sq_from_bin_edges_redz()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import kalepy as kale\n", + "kale.midpoints()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def char_strain_sq_from_bin_edges_redz(edges, redz):\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # redshifts are defined across 4D grid, shape (M, Q, Z, Fc)\n", + " # where M, Q, Z are edges and Fc is frequency centers\n", + " # find midpoints of redshifts in M, Q, Z dimensions, to end up with (M-1, Q-1, Z-1, Fc)\n", + " for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = kale.utils.midpoints(edges[0])\n", + " mr = kale.utils.midpoints(edges[1])\n", + " # rz = kale.utils.midpoints(edges[2])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = cosmo.comoving_distance(redz[sel]).cgs.value\n", + "\n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs = utils.gw_strain_source(mc, dc, fr)\n", + " hc2 = (hs ** 2) * (fc / df)\n", + " return hc2" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Orange spike, cont." + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GW, shape 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_20=holo.sam.Semi_Analytic_Model(shape=20)\n", + "vals_20GW = sam_model(sam=sam_20, hard=holo.hardening.Hard_GW())\n", + "print(vals['hard_name'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals_20GW, mm_arr=[2,7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals_20GW, mm_arr=[6,], qq_arr=[17,], zz_arr=[15], ff_arr=[1,8,])\n", + "fig = plot_number(vals_20GW, mm_arr=[7], qq_arr=[17,], zz_arr=[17], ff_arr=[2,32])\n", + "fig = plot_integrated(vals_20GW, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_20GW, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[2, 32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_20GW, mm_arr=[7,15], qq_arr=[17,], zz_arr=[5,17,], ff_arr=[32,])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GW, shape full" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_full = holo.sam.Semi_Analytic_Model(shape=None)\n", + "vals_fullGW = sam_model(sam=sam_full, hard=holo.hardening.Hard_GW())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals_fullGW, mm_arr=[2,7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals_fullGW, mm_arr=[6,], qq_arr=[17,], zz_arr=[65], ff_arr=[1,8,])\n", + "fig = plot_number(vals_fullGW, mm_arr=[7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_integrated(vals_fullGW, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[65,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_fullGW, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[55,85], ff_arr=[32])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## FT, shape full" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam_full = holo.sam.Semi_Analytic_Model(shape=None)\n", + "vals_fullFT = sam_model(sam=sam_full, hard=holo.hardening.Fixed_Time_2PL_SAM(sam_full, 3*GYR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_dnum_dpar(vals_fullFT, mm_arr=[2,7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_strain_amp(vals_fullFT, mm_arr=[6,], qq_arr=[17,], zz_arr=[65], ff_arr=[1,8,])\n", + "fig = plot_number(vals_fullFT, mm_arr=[7], qq_arr=[17,], zz_arr=[65], ff_arr=[2,32])\n", + "fig = plot_integrated(vals_fullFT, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[65,], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_fullFT, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[55,85], ff_arr=[32])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals_fullFT, mm_arr=[7, -15], qq_arr=[17,], zz_arr=[55,85], ff_arr=[32])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Looking for orange spike for dif models/shapes" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20, mmbulge=holo.relations.MMBulge_MM2013(scatter_dex=0))\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])\n", + "fig.text(0, 0.98, 'scatter_dex=0', fontsize=18)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(vals.keys())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## shape 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape=20\n", + "sam = holo.sam.Semi_Analytic_Model(shape=shape)\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", + "\n", + "\n", + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])\n", + "\n", + "\n", + "for zz in range(0,shape, int(shape/6)):\n", + " print(f\"{zz=}\")\n", + " fig, leg = plot_integrated_vary(vals, mm_arr=[15.], qq_arr=[17,], zz_arr=[zz,], ff_arr=np.arange(0,41,10), vary='ff')\n", + "\n", + "# ax = fig.axes[0]\n", + "# ax.legend(ncols=3, bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape=30\n", + "sam = holo.sam.Semi_Analytic_Model(shape=shape)\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", + "\n", + "for mm in range(0,shape,int(shape/6)):\n", + " print(f\"{mm=}\")\n", + " for qq in range(0,shape, int(shape/6)):\n", + " print(f\"{qq=}\")\n", + " fig, leg = plot_integrated_vary(vals, mm_arr=np.arange(19), qq_arr=[10,], zz_arr=[17,], ff_arr=[32], vary='mm')\n", + "\n", + "# ax = fig.axes[0]\n", + "# ax.legend(ncols=3, bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x = np.nan\n", + "print( x>0,0)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb b/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb new file mode 100644 index 00000000..b4ac6b08 --- /dev/null +++ b/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb @@ -0,0 +1,459 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "from holodeck.constants import YR, MSOL, GYR\n", + "from holodeck import utils\n", + "\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import numpy as np\n", + "import kalepy as kale" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate and store useful variables for sam+hardening model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def sam_model(sam, hard,\n", + " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", + " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " else:\n", + " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", + "\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " if use_redz:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges, redz_final)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges, redz_final)\n", + " else:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges)\n", + "\n", + " vals = {\n", + " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", + " 'hs_cents':hs_cents, 'hs_edges':hs_edges, 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", + " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", + " }\n", + " return vals\n", + "\n", + "\n", + "def strain_amp_at_bin_centers_redz(edges, redz=None):\n", + " \"\"\" Calculate strain amplitude at bin centers, with final or initial redz.\n", + " \n", + " \"\"\"\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # redshifts are defined across 4D grid, shape (M, Q, Z, Fc)\n", + " # where M, Q, Z are edges and Fc is frequency centers\n", + " # find midpoints of redshifts in M, Q, Z dimensions, to end up with (M-1, Q-1, Z-1, Fc)\n", + " if redz is not None:\n", + " for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else:\n", + " redz = kale.utils.midpoints(edges[2])[np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", + "\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = kale.utils.midpoints(edges[0])\n", + " mr = kale.utils.midpoints(edges[1])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " \n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs = utils.gw_strain_source(mc, dc, fr)\n", + " return hs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20)\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "vals = sam_model(sam, hard)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Print weird rz_final info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mm, qq, zz, ff = 15, 18, 15, 28 # weird spot\n", + "\n", + "fobs_orb_cents = vals['fobs_orb_cents']\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "\n", + "hs_final = holo.gravwaves.strain_amp_from_bin_edges_redz(vals['edges'], redz_final)\n", + "hs_init = anis.strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", + "# hs_final_anis = anis.strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n", + "hs_final_anis = strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n", + "print(np.all(hs_final == hs_final_anis)) # check, I am calculating hs correctly\n", + "\n", + "print('hs_init:', utils.stats(hs_init), f\", {hs_init.shape=}\")\n", + "print('hs_final:', utils.stats(hs_final), f\", {hs_init.shape=}\")\n", + "\n", + "rz_init = kale.utils.midpoints(sam.redz, axis=0)\n", + "rz_final = redz_final\n", + "for dd in range(3):\n", + " rz_final = np.moveaxis(rz_final, dd, 0)\n", + " rz_final = kale.utils.midpoints(rz_final, axis=0)\n", + " rz_final = np.moveaxis(rz_final, 0, dd)\n", + "\n", + "print('M(mm=%d)=%.2e M_sol, q(qq=%d)=%.2e, f_obs,orb(ff=%d)=%.2f/yr' \n", + " % (mm, utils.midpoints(vals['edges'][0])[mm]/MSOL, \n", + " qq, utils.midpoints(vals['edges'][1])[qq],\n", + " ff, fobs_orb_cents[ff]*YR))\n", + "for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_final=%.2f, hs_init=%.2e, hs_final=%.2e' \n", + " % (zz, rz_init[zz], rz_final[mm,qq,zz,ff], hs_init[mm,qq,zz,ff], hs_final[mm,qq,zz,ff]))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plots of Weird Spot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", + " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " return num\n", + "def integrate_qq(dnum, edges): # integrate dN/dq\n", + " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", + " return num\n", + "def integrate_zz(dnum, edges): # dN/dz\n", + " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", + " return num\n", + "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", + " num = dnum*np.diff(np.log(fobs_gw_edges))\n", + " return num " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calc_integrated(vals):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " fobs_gw_edges = vals['fobs_gw_edges']\n", + "\n", + " hs_cents = vals['hs_cents']\n", + " hs_edges = vals['hs_edges']\n", + "\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", + " numh4_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", + " # print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", + "\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " # print('dnum_qq:', dnum_qq.shape)\n", + " # print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", + " numh2_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", + " numh4_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**4, edges)\n", + " \n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**2, edges)\n", + " numh4_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**4, edges)\n", + " cynum = vals['number']\n", + " numh2_cy = cynum*hs_cents**2\n", + " numh4_cy = cynum*hs_cents**4\n", + "\n", + "\n", + " flnum = np.floor(cynum)\n", + " numh2_fl = flnum*hs_cents**2\n", + " numh4_fl = flnum*hs_cents**4\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " # print(f\"{xx.shape=}\")\n", + "\n", + " return (xx, numh2_mm, numh2_qq, numh2_zz, numh4_mm, numh4_qq, numh4_zz, \n", + " numh2_cy, numh4_cy, numh2_fl, numh4_fl)\n", + "\n", + "\n", + "\n", + "def plot_integrated_vary(vals, mm_arr, qq_arr, zz_arr, ff_arr, vary='ff'):\n", + "\n", + "\n", + " if vary == 'mm':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(mm_arr)))\n", + " elif vary == 'qq':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(qq_arr)))\n", + " elif vary == 'zz':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(zz_arr)))\n", + " else:\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(ff_arr)))\n", + "\n", + "\n", + "\n", + " (xx, numh2_mm, numh2_qq, numh2_zz, numh4_mm, numh4_qq, numh4_zz, \n", + " numh2_cy, numh4_cy, numh2_fl, numh4_fl) = calc_integrated(vals)\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, figsize=(16,8))\n", + "\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels_h2 = np.array(['$\\int h_s^2 dN/d\\log (M)$', '$\\int h_s^2 dN/dq$', '$\\int h_s^2 dN/dz$'])\n", + " ylabels_h4 = np.array(['$\\int h_s^4 dN/d\\log (M)$', '$\\int h_s^4 dN/dq$', '$\\int h_s^4 dN/dz$'])\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + "\n", + " for mi,mm in enumerate(mm_arr):\n", + " for qi,qq in enumerate(qq_arr):\n", + " for zi,zz in enumerate(zz_arr):\n", + " for fi,ff in enumerate(ff_arr):\n", + " if vary == 'mm':\n", + " color=colors[mi]\n", + " elif vary == 'qq':\n", + " color=colors[qi]\n", + " elif vary == 'zz':\n", + " color=colors[zi]\n", + " else:\n", + " color=colors[fi]\n", + " \n", + " yy_h2 = np.array([numh2_mm[:,qq,zz,ff], numh2_qq[mm,:,zz,ff], numh2_zz[mm,qq,:,ff]])\n", + " yy_h4 = np.array([numh4_mm[:,qq,zz,ff], numh4_qq[mm,:,zz,ff], numh4_zz[mm,qq,:,ff]])\n", + " cy_h2 = np.array([numh2_cy[:,qq,zz,ff], numh2_cy[mm,:,zz,ff], numh2_cy[mm,qq,:,ff]])\n", + " cy_h4 = np.array([numh4_cy[:,qq,zz,ff], numh4_cy[mm,:,zz,ff], numh4_cy[mm,qq,:,ff]])\n", + "\n", + " label0 = '$M=%.2e\\ M_\\odot$, $q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (xx[0,mm], xx[1,qq], xx[2,zz], fobs_gw_cents[ff]*YR)\n", + " for ii, ax in enumerate(axs[0,:]): # h2\n", + " label = label0 if ii==0 else None\n", + "\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " else: \n", + " cylabel=None\n", + " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.35, lw=4, color=color)\n", + " cc = ll.get_color()\n", + " ax.plot(xx[ii], yy_h2[ii], label=label, linestyle='--', alpha=0.75, color=cc, lw=1)\n", + " for ii, ax in enumerate(axs[1,:]): # h4\n", + " cylabel=None\n", + " ll = ax.scatter(xx[ii], cy_h4[ii], label=cylabel, marker='o', alpha=0.35, lw=3, s=10, color=color)\n", + " cc = ll.get_facecolors()\n", + " ax.scatter(xx[ii], yy_h4[ii], label=None, marker='x', alpha=0.75, color=cc ) \n", + "\n", + " for ii, ax in enumerate(axs[0,:]):\n", + " ax.set_ylabel(ylabels_h2[ii])\n", + " # if ii>0: ax.sharey(axs[0,0])\n", + " # ax.legend(fontsize=8)\n", + " for ii, ax in enumerate(axs[1,:]):\n", + " ax.set_ylabel(ylabels_h4[ii])\n", + " ax.set_xlabel(xlabels[ii])\n", + " # if ii>0: ax.sharey(axs[1,0])\n", + " ax.sharex(axs[0,ii])\n", + " # ax.legend(fontsize=8)\n", + " leg = fig.legend(ncols=3, bbox_to_anchor=(0.05,0), loc='upper left', fontsize=14)\n", + " title = ('%s, %s, Varying %s' % (str(vals['hard_name']), str(vals['sam'].shape), vary))\n", + "\n", + " fig.suptitle(title)\n", + " fig.tight_layout()\n", + " return fig, title\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calc_strain_amp(vals):\n", + " # dnum = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + "\n", + " hs_final = anis.strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", + " hs_initz = anis.strain_amp_at_bin_centers_redz(edges, redz=None)\n", + " # print(holo.utils.stats(hs_final/hs_initz))\n", + "\n", + " return hs_initz, hs_final, cents_mm, cents_qq, cents_zz\n", + "\n", + "def plot_strain_amp_vary(vals, mm_arr, qq_arr, zz_arr, ff_arr, vary='ff', initz=True):\n", + " hs_initz, hs_final, cents_mm, cents_qq, cents_zz = calc_strain_amp(vals)\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + "\n", + "\n", + " if vary == 'mm':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(mm_arr)))\n", + " elif vary == 'qq':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(qq_arr)))\n", + " elif vary == 'zz':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(zz_arr)))\n", + " else:\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(ff_arr)))\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " xlabel='edge parameters',\n", + " ylabel='$dN/d(\\mathrm{edge parameter})$',\n", + " ncols=3, figsize=(16,5),\n", + " sharey=True\n", + " )\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels = np.array(['$h_s (M)$', '$h_s(q)$', '$h_s(z)$'])\n", + "\n", + "\n", + " for mi,mm in enumerate(mm_arr):\n", + " for qi,qq in enumerate(qq_arr):\n", + " for zi,zz in enumerate(zz_arr):\n", + " for fi,ff in enumerate(ff_arr):\n", + " if vary == 'mm':\n", + " color=colors[mi]\n", + " elif vary == 'qq':\n", + " color=colors[qi]\n", + " elif vary == 'zz':\n", + " color=colors[zi]\n", + " else:\n", + " color=colors[fi]\n", + " \n", + " yy_initz = np.array([hs_initz[:,qq,zz,ff], hs_initz[mm,:,zz,ff], hs_initz[mm,qq,:,ff]])\n", + " yy_final = np.array([hs_final[:,qq,zz,ff], hs_final[mm,:,zz,ff], hs_final[mm,qq,:,ff]])\n", + " label_ii = ('$M=%.2e\\ M_\\odot$, $q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (cents_mm[mm]/MSOL, cents_qq[qq], cents_zz[zz], fobs_gw_cents[ff]*YR))\n", + "\n", + " for ii, ax in enumerate(axs):\n", + " label=label_ii if ii==0 else None\n", + " if initz:\n", + " if ii==0 and mi==0 and qi==0 and zi==0 and fi==0:\n", + " label_init = 'initial z'\n", + " else: label_init=None\n", + " ax.plot(xx[ii], yy_initz[ii], label=label_init, linestyle='--', alpha=0.65, \n", + " color=color)\n", + " ax.plot(xx[ii], yy_final[ii], label=label, linestyle='-', alpha=0.75, \n", + " color=color,)\n", + " for ii, ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " leg = fig.legend(ncols=3, bbox_to_anchor=(0.05,0), loc='upper left', fontsize=14)\n", + " title='%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape))\n", + " fig.suptitle(title)\n", + " fig.tight_layout\n", + " return fig, title" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20)\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "vals = sam_model(sam=sam, hard=hard)\n", + "fig, title = plot_strain_amp_vary(vals, mm_arr=[15,], qq_arr=[18,], zz_arr=[18,], ff_arr=[0,4,9,14,19,24,29,34,38], vary='ff')\n", + "fig, title = plot_integrated_vary(vals, mm_arr=[15,], qq_arr=[18,], zz_arr=[18,], ff_arr=[0,4,9,14,19,24,29,34,38], vary='ff')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/an2_investigation_integrals.ipynb b/ecg-notebooks/anisotropy/an2_investigation_integrals.ipynb index 56f3aecd..64a6d7f3 100644 --- a/ecg-notebooks/anisotropy/an2_investigation_integrals.ipynb +++ b/ecg-notebooks/anisotropy/an2_investigation_integrals.ipynb @@ -16,6 +16,7 @@ "from holodeck import utils\n", "\n", "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", "import numpy as np" ] }, @@ -571,10 +572,10 @@ " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", " numh4_mm = integrate_mm(dnum_mm* \n", " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", - " print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", + " # print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", "\n", " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", - " print('dnum_qq:', dnum_qq.shape)\n", + " # print('dnum_qq:', dnum_qq.shape)\n", " print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", " numh2_qq = integrate_qq(dnum_qq*\n", " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", @@ -997,6 +998,243 @@ "ax.plot(xh, xx)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Orange spike " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20, mmbulge=holo.relations.MMBulge_MM2013(scatter_dex=0))\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])\n", + "fig.text(0, 0.98, 'scatter_dex=0', fontsize=18)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(vals.keys())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "\n", + "def calc_integrated(vals):\n", + " diff_num = vals['diff_num']\n", + " edges = vals['edges']\n", + " edges_mm = vals['edges'][0]\n", + " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " edges_qq = vals['edges'][1]\n", + " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " edges_zz = vals['edges'][2]\n", + " cents_zz = utils.midpoints(edges_zz, log=True)\n", + "\n", + " hs_cents = vals['hs_cents']\n", + " hs_edges = vals['hs_edges']\n", + "\n", + " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", + " numh4_mm = integrate_mm(dnum_mm* \n", + " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", + " # print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", + "\n", + " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " # print('dnum_qq:', dnum_qq.shape)\n", + " # print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", + " numh2_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", + " numh4_qq = integrate_qq(dnum_qq*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**4, edges)\n", + " \n", + " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", + " numh2_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**2, edges)\n", + " numh4_zz = integrate_zz(dnum_zz*\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**4, edges)\n", + " cynum = vals['number']\n", + " numh2_cy = cynum*hs_cents**2\n", + " numh4_cy = cynum*hs_cents**4\n", + "\n", + "\n", + " flnum = np.floor(cynum)\n", + " numh2_fl = flnum*hs_cents**2\n", + " numh4_fl = flnum*hs_cents**4\n", + " # tznum = integrate_zz(dnum_zz, edges)\n", + " # utnum = utils._integrate_grid_differential_number(edges, diff_num, freq=False)\n", + " # utnum = utnum * np.diff(np.log(fobs_gw_edges))\n", + "\n", + " xx = np.array([cents_mm/MSOL, cents_qq, cents_zz])\n", + " # print(f\"{xx.shape=}\")\n", + "\n", + " return (xx, numh2_mm, numh2_qq, numh2_zz, numh4_mm, numh4_qq, numh4_zz, \n", + " numh2_cy, numh4_cy, numh2_fl, numh4_fl)\n", + "\n", + "\n", + "\n", + "def plot_integrated_vary(vals, mm_arr, qq_arr, zz_arr, ff_arr, vary='mm'):\n", + "\n", + " if vary == 'mm':\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(mm_arr)))\n", + " elif vary == 'qq':\n", + " colors=cm.rainbow(np.linspace(0,1,len(qq_arr)))\n", + " elif vary == 'zz':\n", + " colors=cm.rainbow(np.linspace(0,1,len(zz_arr)))\n", + " else:\n", + " colors=cm.rainbow(np.linspace(0,1,len(ff_arr)))\n", + "\n", + " (xx, numh2_mm, numh2_qq, numh2_zz, numh4_mm, numh4_qq, numh4_zz, \n", + " numh2_cy, numh4_cy, numh2_fl, numh4_fl) = calc_integrated(vals)\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, figsize=(16,8))\n", + "\n", + " xlabels = np.array(['M ($M_\\odot$)', 'q', 'z'])\n", + " ylabels_h2 = np.array(['$\\int h_s^2 dN/d\\log (M)$', '$\\int h_s^2 dN/dq$', '$\\int h_s^2 dN/dz$'])\n", + " ylabels_h4 = np.array(['$\\int h_s^4 dN/d\\log (M)$', '$\\int h_s^4 dN/dq$', '$\\int h_s^4 dN/dz$'])\n", + "\n", + "\n", + "\n", + " for mm in mm_arr:\n", + " for qq in qq_arr:\n", + " for zz in zz_arr:\n", + " for ff in ff_arr:\n", + " if vary == 'mm':\n", + " color=colors[mm]\n", + " elif vary == 'qq':\n", + " color=colors[qq]\n", + " elif vary == 'zz':\n", + " color=colors[zz]\n", + " else:\n", + " color=colors[ff]\n", + " \n", + " yy_h2 = np.array([numh2_mm[:,qq,zz,ff], numh2_qq[mm,:,zz,ff], numh2_zz[mm,qq,:,ff]])\n", + " yy_h4 = np.array([numh4_mm[:,qq,zz,ff], numh4_qq[mm,:,zz,ff], numh4_zz[mm,qq,:,ff]])\n", + " cy_h2 = np.array([numh2_cy[:,qq,zz,ff], numh2_cy[mm,:,zz,ff], numh2_cy[mm,qq,:,ff]])\n", + " cy_h4 = np.array([numh4_cy[:,qq,zz,ff], numh4_cy[mm,:,zz,ff], numh4_cy[mm,qq,:,ff]])\n", + " # fl_h2 = np.array([numh2_fl[:,qq,zz,ff], numh2_fl[mm,:,zz,ff], numh2_fl[mm,qq,:,ff]])\n", + " # fl_h4 = np.array([numh4_fl[:,qq,zz,ff], numh4_fl[mm,:,zz,ff], numh4_fl[mm,qq,:,ff]])\n", + " label0 = '$M=%.2e\\ M_\\odot$, $q=%.2f$, $z=%.2f$, $f=%.2f$/yr' % (xx[0,mm], xx[1,qq], xx[2,zz], fobs_gw_cents[ff]*YR)\n", + " for ii, ax in enumerate(axs[0,:]): # h2\n", + " label = label0 if ii==0 else None\n", + "\n", + " if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " fllabel=r'rounded $h_s^2 \\times \\int dN/dx$'\n", + " else: \n", + " cylabel=None\n", + " fllabel=None\n", + " ll, = ax.plot(xx[ii], cy_h2[ii], label=cylabel, linestyle='-', alpha=0.35, lw=4, color=color)\n", + " cc = ll.get_color()\n", + " # ax.plot(xx[ii], fl_h2[ii], label=fllabel, linestyle='-', alpha=0.65, color=cc, lw=2)\n", + " ax.plot(xx[ii], yy_h2[ii], label=label, linestyle='--', alpha=0.75, color=cc, lw=1)\n", + " for ii, ax in enumerate(axs[1,:]): # h4\n", + " # if ii==0 and mm==mm_arr[0] and qq==qq_arr[0] and zz==zz_arr[0] and ff==ff_arr[0]:\n", + " # cylabel=r'$h_s^2 \\times \\int dN/dx$'\n", + " # fllabel=r'rounded $h_s^2 \\times \\int dN/dx$'\n", + " # else: \n", + " cylabel=None\n", + " fllabel=None\n", + " # ll, = ax.plot(xx[ii], cy_h4[ii], label=cylabel, linestyle='-', alpha=0.5, lw=3)\n", + " ll = ax.scatter(xx[ii], cy_h4[ii], label=cylabel, marker='o', alpha=0.35, lw=3, s=10, color=color)\n", + " # cc = ll.get_color()\n", + " # ax.plot(xx[ii], yy_h4[ii], label=labels[ii], linestyle='x', alpha=0.75, color=cc )\n", + " cc = ll.get_facecolors()\n", + " # ax.scatter(xx[ii], fl_h4[ii], label=fllabel, marker='+', alpha=0.65, color=cc)\n", + " ax.scatter(xx[ii], yy_h4[ii], label=None, marker='x', alpha=0.75, color=cc ) \n", + "\n", + " for ii, ax in enumerate(axs[0,:]):\n", + " ax.set_ylabel(ylabels_h2[ii])\n", + " # if ii>0: ax.sharey(axs[0,0])\n", + " # ax.legend(fontsize=8)\n", + " for ii, ax in enumerate(axs[1,:]):\n", + " ax.set_ylabel(ylabels_h4[ii])\n", + " ax.set_xlabel(xlabels[ii])\n", + " # if ii>0: ax.sharey(axs[1,0])\n", + " ax.sharex(axs[0,ii])\n", + " # ax.legend(fontsize=8)\n", + " leg = fig.legend(ncols=3, bbox_to_anchor=(0.05,0), loc='upper left')\n", + "\n", + " fig.suptitle('%s, %s, Varying %s' % (str(vals['hard_name']), str(vals['sam'].shape), vary))\n", + " fig.tight_layout()\n", + " return fig, leg\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## shape 20" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape=20\n", + "sam = holo.sam.Semi_Analytic_Model(shape=shape)\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", + "\n", + "\n", + "fig = plot_integrated(vals, mm_arr=[7,15], qq_arr=[17,], zz_arr=[17,], ff_arr=[32])\n", + "\n", + "\n", + "for zz in range(0,shape, int(shape/6)):\n", + " print(f\"{zz=}\")\n", + " fig, leg = plot_integrated_vary(vals, mm_arr=[15.], qq_arr=[17,], zz_arr=[zz,], ff_arr=np.arange(0,41,10), vary='ff')\n", + "\n", + "# ax = fig.axes[0]\n", + "# ax.legend(ncols=3, bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape=30\n", + "sam = holo.sam.Semi_Analytic_Model(shape=shape)\n", + "vals = sam_model(sam=sam, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", + "\n", + "for mm in range(0,shape,int(shape/6)):\n", + " print(f\"{mm=}\")\n", + " for qq in range(0,shape, int(shape/6)):\n", + " print(f\"{qq=}\")\n", + " fig, leg = plot_integrated_vary(vals, mm_arr=np.arange(19), qq_arr=[10,], zz_arr=[17,], ff_arr=[32], vary='mm')\n", + "\n", + "# ax = fig.axes[0]\n", + "# ax.legend(ncols=3, bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb index 106d9963..c33c5e5d 100644 --- a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb +++ b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb @@ -15,8 +15,7 @@ "import healpy as hp\n", "import matplotlib.pyplot as plt\n", "import matplotlib.cm as cm\n", - "import h5py\n", - "\n" + "import h5py" ] }, { diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 8f45eb3a..2d35ba3d 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -192,7 +192,7 @@ def lib_anisotropy(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lm else: print('Writing to an existing directory.') - output_name = output_dir+'/sph_harm_lmax%d_nside%d_nbest%d.npz' % (lmax, nside, nbest) + output_name = output_dir+'/sph_harm_lmax%d_nside%d_nbest%d_nreals%d.npz' % (lmax, nside, nbest, nreals) print('Saving npz file: ', output_name) np.savez(output_name, nsort=nsort, fidx=fidx, hc_ref=hc_ref, ss_shape=shape, From b6cc752f1261736edc9492c5327a11cc2ea77448 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 10 Jun 2023 17:17:10 -0700 Subject: [PATCH 038/291] Removed usage of anisotropy.py in an2B notebook. --- .../anisotropy/an2B_weird_redz_final.ipynb | 110 ++++++++++++------ 1 file changed, 72 insertions(+), 38 deletions(-) diff --git a/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb b/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb index b4ac6b08..ccfbf8fc 100644 --- a/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb +++ b/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb @@ -11,7 +11,7 @@ "from importlib import reload\n", "\n", "import holodeck as holo\n", - "import holodeck.anisotropy as anis\n", + "# import holodeck.anisotropy as anis\n", "from holodeck.constants import YR, MSOL, GYR\n", "from holodeck import utils\n", "\n", @@ -35,38 +35,6 @@ "metadata": {}, "outputs": [], "source": [ - "def sam_model(sam, hard,\n", - " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", - " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", - " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", - " fobs_orb_cents = fobs_gw_cents/2.0\n", - " fobs_orb_edges = fobs_gw_edges/2.0\n", - "\n", - " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", - " hard_name = 'Fixed Time'\n", - " elif isinstance(hard, holo.hardening.Hard_GW):\n", - " hard_name = 'GW Only'\n", - " else:\n", - " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", - "\n", - " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", - " fobs_orb_cents, sam, hard, holo.cosmo)\n", - " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", - " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", - " if use_redz:\n", - " hs_cents = anis.strain_amp_at_bin_centers_redz(edges, redz_final)\n", - " hs_edges = anis.strain_amp_at_bin_edges_redz(edges, redz_final)\n", - " else:\n", - " hs_cents = anis.strain_amp_at_bin_centers_redz(edges)\n", - " hs_edges = anis.strain_amp_at_bin_edges_redz(edges)\n", - "\n", - " vals = {\n", - " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", - " 'hs_cents':hs_cents, 'hs_edges':hs_edges, 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", - " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", - " }\n", - " return vals\n", - "\n", "\n", "def strain_amp_at_bin_centers_redz(edges, redz=None):\n", " \"\"\" Calculate strain amplitude at bin centers, with final or initial redz.\n", @@ -105,7 +73,74 @@ " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", "\n", " hs = utils.gw_strain_source(mc, dc, fr)\n", - " return hs" + " return hs\n", + "\n", + "\n", + "def strain_amp_at_bin_edges_redz(edges, redz=None):\n", + " \"\"\" Calculate strain amplitude at bin edges, with final or initial redz.\n", + " \n", + " \"\"\"\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " # df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + "\n", + " if redz is not None:\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else: \n", + " redz = edges[2][np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = (edges[0])\n", + " mr = (edges[1])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " \n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs_edges = utils.gw_strain_source(mc, dc, fr)\n", + " return hs_edges\n", + "\n", + "\n", + "def sam_model(sam, hard,\n", + " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", + " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " else:\n", + " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", + "\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " if use_redz:\n", + " hs_cents = strain_amp_at_bin_centers_redz(edges, redz_final)\n", + " hs_edges = strain_amp_at_bin_edges_redz(edges, redz_final)\n", + " else:\n", + " hs_cents = strain_amp_at_bin_centers_redz(edges)\n", + " hs_edges = strain_amp_at_bin_edges_redz(edges)\n", + "\n", + " vals = {\n", + " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", + " 'hs_cents':hs_cents, 'hs_edges':hs_edges, 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", + " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", + " }\n", + " return vals\n", + "\n" ] }, { @@ -140,8 +175,7 @@ " fobs_orb_cents, sam, hard, holo.cosmo)\n", "\n", "hs_final = holo.gravwaves.strain_amp_from_bin_edges_redz(vals['edges'], redz_final)\n", - "hs_init = anis.strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", - "# hs_final_anis = anis.strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n", + "hs_init = strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", "hs_final_anis = strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n", "print(np.all(hs_final == hs_final_anis)) # check, I am calculating hs correctly\n", "\n", @@ -344,8 +378,8 @@ " cents_zz = utils.midpoints(edges_zz, log=True)\n", "\n", "\n", - " hs_final = anis.strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", - " hs_initz = anis.strain_amp_at_bin_centers_redz(edges, redz=None)\n", + " hs_final = strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", + " hs_initz = strain_amp_at_bin_centers_redz(edges, redz=None)\n", " # print(holo.utils.stats(hs_final/hs_initz))\n", "\n", " return hs_initz, hs_final, cents_mm, cents_qq, cents_zz\n", From 0ccf628bed0eee44fa68b61cf45c27a2aeff8330 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 10 Jun 2023 19:20:14 -0700 Subject: [PATCH 039/291] plotting hs histograms in an3A_z_init_z_final.ipynb but redz_final for N<0 not working. --- .../anisotropy/an3A_z_init_vs_z_final.ipynb | 331 ++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb diff --git a/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb b/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb new file mode 100644 index 00000000..5769d327 --- /dev/null +++ b/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb @@ -0,0 +1,331 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import h5py\n", + "import healpy as hp\n", + "import kalepy as kale\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "from holodeck import detstats, plot, utils\n", + "from holodeck.constants import YR, MSOL, GYR, SPLC, PC, MPC" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def sam_model(sam, hard,\n", + " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", + " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " else:\n", + " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", + "\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + " if use_redz:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges, redz_final)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges, redz_final)\n", + " else:\n", + " hs_cents = anis.strain_amp_at_bin_centers_redz(edges)\n", + " hs_edges = anis.strain_amp_at_bin_edges_redz(edges)\n", + "\n", + " vals = {\n", + " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", + " 'hs_cents':hs_cents, 'hs_edges':hs_edges, 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", + " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", + " }\n", + " return vals\n", + "\n", + "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", + " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " return num\n", + "def integrate_qq(dnum, edges): # integrate dN/dq\n", + " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", + " return num\n", + "def integrate_zz(dnum, edges): # dN/dz\n", + " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", + " return num\n", + "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", + " num = dnum*np.diff(np.log(fobs_gw_edges))\n", + " return num " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def strain_amp_at_bin_centers_redz(edges, redz=None):\n", + " \"\"\" Calculate strain amplitude at bin centers, with final or initial redz.\n", + " \n", + " \"\"\"\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # redshifts are defined across 4D grid, shape (M, Q, Z, Fc)\n", + " # where M, Q, Z are edges and Fc is frequency centers\n", + " # find midpoints of redshifts in M, Q, Z dimensions, to end up with (M-1, Q-1, Z-1, Fc)\n", + " if redz is not None:\n", + " for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else:\n", + " redz = kale.utils.midpoints(edges[2])[np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", + "\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = kale.utils.midpoints(edges[0])\n", + " mr = kale.utils.midpoints(edges[1])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " \n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs = utils.gw_strain_source(mc, dc, fr)\n", + " return hs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=(15,20,25))\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "vals = sam_model(sam, hard)\n", + "\n", + "hs_init = strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", + "hs_final = strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def redz_allN(sam, hard, fobs_orb, steps=200, details=False):\n", + " \"\"\"Get correct redshifts for full binary-number calculation.\n", + "\n", + " Slower but more correct than old `dynamic_binary_number`.\n", + " Same as new cython implementation `holo.sam_cython.dynamic_binary_number_at_fobs`, which is\n", + " more than 10x faster.\n", + " LZK 2023-05-11\n", + "\n", + " # BUG doesn't work for Fixed_Time_2PL\n", + "\n", + " \"\"\"\n", + " fobs_orb = np.asarray(fobs_orb)\n", + " edges = sam.edges + [fobs_orb, ]\n", + "\n", + " # shape: (M, Q, Z)\n", + " dens = sam.static_binary_density # d3n/[dlog10(M) dq dz] units: [Mpc^-3]\n", + "\n", + "\n", + " # start from the hardening model's initial separation\n", + " rmax = hard._sepa_init\n", + " # (M,) end at the ISCO\n", + " rmin = utils.rad_isco(sam.mtot)\n", + " # Choose steps for each binary, log-spaced between rmin and rmax\n", + " extr = np.log10([rmax * np.ones_like(rmin), rmin]) # (2,M,)\n", + " rads = np.linspace(0.0, 1.0, steps)[np.newaxis, :] # (1,X)\n", + " # (M, S) = (M,1) * (1,S)\n", + " rads = extr[0][:, np.newaxis] + (extr[1] - extr[0])[:, np.newaxis] * rads\n", + " rads = 10.0 ** rads\n", + "\n", + " # (M, Q, S)\n", + " mt, mr, rads, norm = np.broadcast_arrays(\n", + " sam.mtot[:, np.newaxis, np.newaxis],\n", + " sam.mrat[np.newaxis, :, np.newaxis],\n", + " rads[:, np.newaxis, :],\n", + " hard._norm[:, :, np.newaxis],\n", + " )\n", + "\n", + " # these must all be 1darrays of matching size (X,) but they aren't\n", + " print(f\"{mt.shape=}, {mr.shape=}, {rads.shape=}, {norm.shape=}\") \n", + " # mt=mt.flatten()\n", + " # mr=mr.flatten()\n", + " # rads=rads.flatten()\n", + " # norm=norm.flatten()\n", + " # print(f\"{mt.shape=}, {mr.shape=}, {rads.shape=}, {norm.shape=}\") \n", + " dadt_evo = hard.dadt(mt, mr, rads, norm=norm)\n", + " # dadt_evo = hard.dadt(mt.flatten(), mr.flatten(), rads.flatten(), norm=norm.flatten())\n", + " print(f\"{utils.stats(dadt_evo*YR/PC)=}\")\n", + "\n", + " # (M, Q, S-1)\n", + " # Integrate (inverse) hardening rates to calculate total lifetime to each separation\n", + " times_evo = -utils.trapz_loglog(-1.0 / dadt_evo, rads, axis=-1, cumsum=True)\n", + " print(f\"{utils.stats(times_evo/GYR)=}\")\n", + " # Combine the binary-evolution time, with the galaxy-merger time\n", + " # (M, Q, Z, S-1)\n", + " rz = sam.redz[np.newaxis, np.newaxis, :, np.newaxis]\n", + " times_tot = times_evo[:, :, np.newaxis, :] + sam._gmt_time[:, :, :, np.newaxis]\n", + " redz_evo = utils.redz_after(times_tot, redz=rz)\n", + "\n", + " # convert from separations to rest-frame orbital frequencies\n", + " # (M, Q, S)\n", + " frst_orb_evo = utils.kepler_freq_from_sepa(mt, rads)\n", + " # (M, Q, Z, S)\n", + " fobs_orb_evo = frst_orb_evo[:, :, np.newaxis, :] / (1.0 + rz)\n", + "\n", + " # ---- interpolate to target frequencies\n", + " # `ndinterp` interpolates over 1th dimension\n", + "\n", + " # (M, Q, Z, S-1) ==> (M*Q*Z, S-1)\n", + " fobs_orb_evo, redz_evo = [mm.reshape(-1, steps-1) for mm in [fobs_orb_evo[:, :, :, 1:], redz_evo]]\n", + " # (M*Q*Z, X)\n", + " redz_final = utils.ndinterp(fobs_orb, fobs_orb_evo, redz_evo, xlog=True, ylog=False)\n", + " print(f\"{utils.stats(redz_final)=}\")\n", + "\n", + " # (M*Q*Z, X) ===> (M, Q, Z, X)\n", + " redz_final = redz_final.reshape(sam.shape + (fobs_orb.size,))\n", + "\n", + "\n", + " return redz_final\n", + "\n", + " # coal = (redz_final > 0.0)\n", + " # frst_orb = fobs_orb * (1.0 + redz_final)\n", + " # frst_orb[frst_orb < 0.0] = 0.0\n", + " # redz_final[~coal] = -1.0\n", + "\n", + " # # (M, Q, Z, X) comoving-distance in [Mpc]\n", + " # dc = np.zeros_like(redz_final)\n", + " # dc[coal] = holo.cosmo.comoving_distance(redz_final[coal]).to('Mpc').value\n", + "\n", + " # # (M, Q, Z, X) this is `(dVc/dz) * (dz/dt)` in units of [Mpc^3/s]\n", + " # cosmo_fact = np.zeros_like(redz_final)\n", + " # cosmo_fact[coal] = 4 * np.pi * (SPLC/MPC) * np.square(dc[coal]) * (1.0 + redz_final[coal])\n", + "\n", + " # # (M, Q) calculate chirp-mass\n", + " # mt = sam.mtot[:, np.newaxis, np.newaxis, np.newaxis]\n", + " # mr = sam.mrat[np.newaxis, :, np.newaxis, np.newaxis]\n", + "\n", + " # # Convert from observer-frame orbital freq, to rest-frame orbital freq\n", + " # sa = utils.kepler_sepa_from_freq(mt, frst_orb)\n", + " # print(f\"{utils.stats(sa/PC)=}\")\n", + " # mt, mr, sa, norm = np.broadcast_arrays(mt, mr, sa, hard._norm[:, :, np.newaxis, np.newaxis])\n", + " # # hardening rate, negative values, units of [cm/sec]\n", + " # dadt = hard.dadt(mt, mr, sa, norm=norm)\n", + " # print(f\"{utils.stats(dadt*YR/PC)=}\")\n", + " # # Calculate `tau = dt/dlnf_r = f_r / (df_r/dt)`\n", + " # # dfdt is positive (increasing frequency)\n", + " # dfdt, frst_orb = utils.dfdt_from_dadt(dadt, sa, frst_orb=frst_orb)\n", + " # tau = frst_orb / dfdt\n", + "\n", + " # # (M, Q, Z, X) units: [1/s] i.e. number per second\n", + " # dnum = dens[..., np.newaxis] * cosmo_fact * tau\n", + " # dnum[~coal] = 0.0\n", + "\n", + " # if details:\n", + " # tau[~coal] = 0.0\n", + " # dadt[~coal] = 0.0\n", + " # sa[~coal] = 0.0\n", + " # cosmo_fact[~coal] = 0.0\n", + " # # (M, Q, X) ==> (M, Q, Z, X)\n", + " # dets = dict(tau=tau, cosmo_fact=cosmo_fact, dadt=dadt, fobs=fobs_orb, sepa=sa)\n", + " # return edges, dnum, redz_final, dets\n", + "\n", + " # sam._redz_final = redz_final\n", + "\n", + " # return edges, dnum, redz_final" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_orb=vals['fobs_orb_cents']\n", + "redz_final=vals['redz_final']\n", + "redz_allN = redz_allN(sam,hard,fobs_orb)\n", + "\n", + "# plt.scatter(np.arange(redz_final.size), redz_final.flatten())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig,ax = plot.figax(xlabel='$h_s$', ylabel='N')\n", + "ax.hist(hs_init.flatten(), histtype='step', bins=500, ls='solid', label='hs_init')\n", + "ax.hist(hs_final.flatten(), histtype='step', bins=500, ls='solid', label='hs_final')\n", + "ax.legend()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 414d3e499060a9c0e06e580493e84cb7f15c754c Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 11 Jun 2023 00:50:16 -0700 Subject: [PATCH 040/291] Change all utils.midpoints to log=False --- .../anisotropy/an2B_weird_redz_final.ipynb | 26 +++++++++---------- .../anisotropy/an3A_z_init_vs_z_final.ipynb | 13 +++++++++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb b/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb index ccfbf8fc..3452fc29 100644 --- a/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb +++ b/ecg-notebooks/anisotropy/an2B_weird_redz_final.ipynb @@ -236,11 +236,11 @@ " diff_num = vals['diff_num']\n", " edges = vals['edges']\n", " edges_mm = vals['edges'][0]\n", - " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " cents_mm = utils.midpoints(edges_mm)\n", " edges_qq = vals['edges'][1]\n", - " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " cents_qq = utils.midpoints(edges_qq)\n", " edges_zz = vals['edges'][2]\n", - " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " cents_zz = utils.midpoints(edges_zz)\n", " fobs_gw_edges = vals['fobs_gw_edges']\n", "\n", " hs_cents = vals['hs_cents']\n", @@ -248,24 +248,24 @@ "\n", " dnum_mm = integrate_ff(integrate_zz(integrate_qq(diff_num, edges), edges), fobs_gw_edges)\n", " numh2_mm = integrate_mm(dnum_mm* \n", - " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**2, edges)\n", + " utils.midpoints_multiax(hs_edges, axis=(1,2))**2, edges)\n", " numh4_mm = integrate_mm(dnum_mm* \n", - " utils.midpoints_multiax(hs_edges, axis=(1,2), log=True)**4, edges)\n", + " utils.midpoints_multiax(hs_edges, axis=(1,2))**4, edges)\n", " # print('dnum_mm:', dnum_mm.shape, 'numh2_mm:', numh2_mm.shape)\n", "\n", " dnum_qq = integrate_ff(integrate_zz(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", " # print('dnum_qq:', dnum_qq.shape)\n", - " # print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2).shape)\n", + " # print((dnum_qq* utils.midpoints_multiax(hs_edges, axis=(0,2))**2).shape)\n", " numh2_qq = integrate_qq(dnum_qq*\n", - " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**2, edges)\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2))**2, edges)\n", " numh4_qq = integrate_qq(dnum_qq*\n", - " utils.midpoints_multiax(hs_edges, axis=(0,2), log=True)**4, edges)\n", + " utils.midpoints_multiax(hs_edges, axis=(0,2))**4, edges)\n", " \n", " dnum_zz = integrate_ff(integrate_qq(integrate_mm(diff_num, edges), edges), fobs_gw_edges)\n", " numh2_zz = integrate_zz(dnum_zz*\n", - " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**2, edges)\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1))**2, edges)\n", " numh4_zz = integrate_zz(dnum_zz*\n", - " utils.midpoints_multiax(hs_edges, axis=(0,1), log=True)**4, edges)\n", + " utils.midpoints_multiax(hs_edges, axis=(0,1))**4, edges)\n", " cynum = vals['number']\n", " numh2_cy = cynum*hs_cents**2\n", " numh4_cy = cynum*hs_cents**4\n", @@ -371,11 +371,11 @@ " # dnum = vals['diff_num']\n", " edges = vals['edges']\n", " edges_mm = vals['edges'][0]\n", - " cents_mm = utils.midpoints(edges_mm, log=True)\n", + " cents_mm = utils.midpoints(edges_mm)\n", " edges_qq = vals['edges'][1]\n", - " cents_qq = utils.midpoints(edges_qq, log=True)\n", + " cents_qq = utils.midpoints(edges_qq)\n", " edges_zz = vals['edges'][2]\n", - " cents_zz = utils.midpoints(edges_zz, log=True)\n", + " cents_zz = utils.midpoints(edges_zz)\n", "\n", "\n", " hs_final = strain_amp_at_bin_centers_redz(edges, vals['redz_final'])\n", diff --git a/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb b/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb index 5769d327..11f1b594 100644 --- a/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb +++ b/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb @@ -134,7 +134,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=(15,20,25))\n", + "sam = holo.sam.Semi_Analytic_Model(shape=(5,6,7))\n", "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", "vals = sam_model(sam, hard)\n", "\n", @@ -299,6 +299,17 @@ "ax.legend()" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_orb_cents=vals['fobs_orb_cents']\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)" + ] + }, { "cell_type": "code", "execution_count": null, From 40a0de1c2ea319659d127c8ac25bb612ce174bf9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 11 Jun 2023 01:28:55 -0700 Subject: [PATCH 041/291] Comparing hs(z_final) for cython and redz. They don't match, but both produce discontinuities. --- .../anisotropy/an3A_z_init_vs_z_final.ipynb | 212 ++++--- .../an3B_redz_cy_py_dont_match.ipynb | 522 ++++++++++++++++++ 2 files changed, 668 insertions(+), 66 deletions(-) create mode 100644 ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb diff --git a/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb b/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb index 11f1b594..1fff52a6 100644 --- a/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb +++ b/ecg-notebooks/anisotropy/an3A_z_init_vs_z_final.ipynb @@ -134,21 +134,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=(5,6,7))\n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", - "vals = sam_model(sam, hard)\n", - "\n", - "hs_init = strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", - "hs_final = strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def redz_allN(sam, hard, fobs_orb, steps=200, details=False):\n", + "def final_redz_allN(sam, hard, fobs_orb, steps=200, details=False):\n", " \"\"\"Get correct redshifts for full binary-number calculation.\n", "\n", " Slower but more correct than old `dynamic_binary_number`.\n", @@ -224,54 +210,82 @@ " # (M*Q*Z, X) ===> (M, Q, Z, X)\n", " redz_final = redz_final.reshape(sam.shape + (fobs_orb.size,))\n", "\n", + " redz_allN = np.copy(redz_final)\n", + "\n", + " coal = (redz_final > 0.0)\n", + " frst_orb = fobs_orb * (1.0 + redz_final)\n", + " frst_orb[frst_orb < 0.0] = 0.0\n", + " redz_final[~coal] = -1.0\n", + "\n", + " # (M, Q, Z, X) comoving-distance in [Mpc]\n", + " dc = np.zeros_like(redz_final)\n", + " dc[coal] = holo.cosmo.comoving_distance(redz_final[coal]).to('Mpc').value\n", + "\n", + " # (M, Q, Z, X) this is `(dVc/dz) * (dz/dt)` in units of [Mpc^3/s]\n", + " cosmo_fact = np.zeros_like(redz_final)\n", + " cosmo_fact[coal] = 4 * np.pi * (SPLC/MPC) * np.square(dc[coal]) * (1.0 + redz_final[coal])\n", + "\n", + " # (M, Q) calculate chirp-mass\n", + " mt = sam.mtot[:, np.newaxis, np.newaxis, np.newaxis]\n", + " mr = sam.mrat[np.newaxis, :, np.newaxis, np.newaxis]\n", + "\n", + " # Convert from observer-frame orbital freq, to rest-frame orbital freq\n", + " sa = utils.kepler_sepa_from_freq(mt, frst_orb)\n", + " print(f\"{utils.stats(sa/PC)=}\")\n", + " mt, mr, sa, norm = np.broadcast_arrays(mt, mr, sa, hard._norm[:, :, np.newaxis, np.newaxis])\n", + " # hardening rate, negative values, units of [cm/sec]\n", + " dadt = hard.dadt(mt, mr, sa, norm=norm)\n", + " print(f\"{utils.stats(dadt*YR/PC)=}\")\n", + " # Calculate `tau = dt/dlnf_r = f_r / (df_r/dt)`\n", + " # dfdt is positive (increasing frequency)\n", + " dfdt, frst_orb = utils.dfdt_from_dadt(dadt, sa, frst_orb=frst_orb)\n", + " tau = frst_orb / dfdt\n", + "\n", + " # (M, Q, Z, X) units: [1/s] i.e. number per second\n", + " dnum = dens[..., np.newaxis] * cosmo_fact * tau\n", + " dnum[~coal] = 0.0\n", + "\n", + " if details:\n", + " tau[~coal] = 0.0\n", + " dadt[~coal] = 0.0\n", + " sa[~coal] = 0.0\n", + " cosmo_fact[~coal] = 0.0\n", + " # (M, Q, X) ==> (M, Q, Z, X)\n", + " dets = dict(tau=tau, cosmo_fact=cosmo_fact, dadt=dadt, fobs=fobs_orb, sepa=sa)\n", + " return edges, dnum, redz_final, dets\n", + "\n", + " sam._redz_final = redz_final\n", + "\n", + " return edges, dnum, redz_final, redz_allN" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=(5,6,7))\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "vals = sam_model(sam, hard)\n", + "\n", + "fobs_orb_cents=vals['fobs_orb_cents']\n", + "temp1, temp2, redz_finN, redz_allN = final_redz_allN(sam,hard,fobs_orb_cents)\n", + "redz_final = vals['redz_final']\n", "\n", - " return redz_final\n", - "\n", - " # coal = (redz_final > 0.0)\n", - " # frst_orb = fobs_orb * (1.0 + redz_final)\n", - " # frst_orb[frst_orb < 0.0] = 0.0\n", - " # redz_final[~coal] = -1.0\n", - "\n", - " # # (M, Q, Z, X) comoving-distance in [Mpc]\n", - " # dc = np.zeros_like(redz_final)\n", - " # dc[coal] = holo.cosmo.comoving_distance(redz_final[coal]).to('Mpc').value\n", - "\n", - " # # (M, Q, Z, X) this is `(dVc/dz) * (dz/dt)` in units of [Mpc^3/s]\n", - " # cosmo_fact = np.zeros_like(redz_final)\n", - " # cosmo_fact[coal] = 4 * np.pi * (SPLC/MPC) * np.square(dc[coal]) * (1.0 + redz_final[coal])\n", - "\n", - " # # (M, Q) calculate chirp-mass\n", - " # mt = sam.mtot[:, np.newaxis, np.newaxis, np.newaxis]\n", - " # mr = sam.mrat[np.newaxis, :, np.newaxis, np.newaxis]\n", - "\n", - " # # Convert from observer-frame orbital freq, to rest-frame orbital freq\n", - " # sa = utils.kepler_sepa_from_freq(mt, frst_orb)\n", - " # print(f\"{utils.stats(sa/PC)=}\")\n", - " # mt, mr, sa, norm = np.broadcast_arrays(mt, mr, sa, hard._norm[:, :, np.newaxis, np.newaxis])\n", - " # # hardening rate, negative values, units of [cm/sec]\n", - " # dadt = hard.dadt(mt, mr, sa, norm=norm)\n", - " # print(f\"{utils.stats(dadt*YR/PC)=}\")\n", - " # # Calculate `tau = dt/dlnf_r = f_r / (df_r/dt)`\n", - " # # dfdt is positive (increasing frequency)\n", - " # dfdt, frst_orb = utils.dfdt_from_dadt(dadt, sa, frst_orb=frst_orb)\n", - " # tau = frst_orb / dfdt\n", - "\n", - " # # (M, Q, Z, X) units: [1/s] i.e. number per second\n", - " # dnum = dens[..., np.newaxis] * cosmo_fact * tau\n", - " # dnum[~coal] = 0.0\n", - "\n", - " # if details:\n", - " # tau[~coal] = 0.0\n", - " # dadt[~coal] = 0.0\n", - " # sa[~coal] = 0.0\n", - " # cosmo_fact[~coal] = 0.0\n", - " # # (M, Q, X) ==> (M, Q, Z, X)\n", - " # dets = dict(tau=tau, cosmo_fact=cosmo_fact, dadt=dadt, fobs=fobs_orb, sepa=sa)\n", - " # return edges, dnum, redz_final, dets\n", - "\n", - " # sam._redz_final = redz_final\n", - "\n", - " # return edges, dnum, redz_final" + "hs_init = strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", + "hs_final = strain_amp_at_bin_centers_redz(vals['edges'], redz=vals['redz_final'])\n", + "hs_allN = strain_amp_at_bin_centers_redz(vals['edges'], redz=redz_allN,)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(redz_final.shape)\n", + "print(redz_allN.shape)" ] }, { @@ -280,13 +294,64 @@ "metadata": {}, "outputs": [], "source": [ - "fobs_orb=vals['fobs_orb_cents']\n", + "dif_rz_final = redz_final[redz_final != redz_allN]\n", + "dif_rz_allN = redz_allN[redz_final != redz_allN]\n", + "fig, ax = plot.figax(xlabel='index', ylabel='redz', xscale='linear', yscale='linear')\n", + "ax.scatter(np.arange(dif_rz_allN.size), dif_rz_allN.flatten(), label='all N', alpha=0.5, marker='+')\n", + "ax.scatter(np.arange(dif_rz_final.size), dif_rz_final.flatten(), label='final', alpha=0.5, marker='*', s=5)\n", + "ax.legend()\n", + "\n", + "# there are some that are >0 when doing the full final calculation, not just the all N one\n", + "# so I guess this " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "coal = redz_allN>0\n", + "redz_posN = redz_allN\n", + "redz_posN[~coal] = -1.0\n", + "fig, ax = plot.figax(xlabel='index', ylabel='redz', xscale='linear', yscale='linear')\n", + "# ax.scatter(np.arange(redz_posN.size), redz_posN.flatten(), label='N>0', alpha=0.5, marker='x')\n", + "# ax.scatter(np.arange(redz_allN.size), redz_allN.flatten(), label='all N', alpha=0.5, marker='+')\n", + "ax.scatter(np.arange(redz_final.size), redz_final.flatten(), label='final', alpha=0.5, marker='*', s=5)\n", + "ax.scatter(np.arange(redz_finN.size), redz_finN.flatten(), label='fin N', alpha=0.5, marker='*', s=5)\n", + "ax.legend()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "redz_final=vals['redz_final']\n", - "redz_allN = redz_allN(sam,hard,fobs_orb)\n", "\n", "# plt.scatter(np.arange(redz_final.size), redz_final.flatten())" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -306,8 +371,23 @@ "outputs": [], "source": [ "fobs_orb_cents=vals['fobs_orb_cents']\n", - "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", - " fobs_orb_cents, sam, hard, holo.cosmo)" + "redz_final_cy, diff_num_cy = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "temp, diff_num_py, redz_final_py = sam.dynamic_binary_number_at_fobs(hard, fobs_orb_cents)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(utils.stats(redz_final_cy))\n", + "print(utils.stats(redz_final_py))\n", + "fig, ax = plot.figax(xlabel='index', ylabel='redz_final', xscale='linear', yscale='linear')\n", + "ax.scatter(np.arange(redz_final_py.size), redz_final_py.flatten(), label='python', marker='x', alpha=0.5)\n", + "ax.scatter(np.arange(redz_final_cy.size), redz_final_cy.flatten(), label='cython', marker='+', alpha=0.5)\n", + "ax.legend()" ] }, { diff --git a/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb b/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb new file mode 100644 index 00000000..39a63bd6 --- /dev/null +++ b/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb @@ -0,0 +1,522 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import kalepy as kale\n", + "\n", + "import holodeck as holo\n", + "# import holodeck.anisotropy as anis\n", + "from holodeck import detstats, plot, utils\n", + "from holodeck.constants import YR, MSOL, GYR, SPLC, PC, MPC" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def strain_amp_at_bin_centers_redz(edges, redz=None):\n", + " \"\"\" Calculate strain amplitude at bin centers, with final or initial redz.\n", + " \n", + " \"\"\"\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + " # redshifts are defined across 4D grid, shape (M, Q, Z, Fc)\n", + " # where M, Q, Z are edges and Fc is frequency centers\n", + " # find midpoints of redshifts in M, Q, Z dimensions, to end up with (M-1, Q-1, Z-1, Fc)\n", + " if redz is not None:\n", + " for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else:\n", + " redz = kale.utils.midpoints(edges[2])[np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", + "\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = kale.utils.midpoints(edges[0])\n", + " mr = kale.utils.midpoints(edges[1])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " \n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs = utils.gw_strain_source(mc, dc, fr)\n", + " return hs\n", + "\n", + "\n", + "def strain_amp_at_bin_edges_redz(edges, redz=None):\n", + " \"\"\" Calculate strain amplitude at bin edges, with final or initial redz.\n", + " \n", + " \"\"\"\n", + " assert len(edges) == 4\n", + " assert np.all([np.ndim(ee) == 1 for ee in edges])\n", + "\n", + " foo = edges[-1] #: should be observer-frame orbital-frequencies\n", + " # df = np.diff(foo) #: frequency bin widths\n", + " fc = kale.utils.midpoints(foo) #: use frequency-bin centers for strain (more accurate!)\n", + "\n", + "\n", + " if redz is not None:\n", + " dc = +np.inf * np.ones_like(redz)\n", + " sel = (redz > 0.0)\n", + " dc[sel] = holo.cosmo.comoving_distance(redz[sel]).cgs.value\n", + " else: \n", + " redz = edges[2][np.newaxis,np.newaxis,:,np.newaxis]\n", + " dc = holo.cosmo.comoving_distance(redz).cgs.value\n", + "\n", + " # ---- calculate GW strain ----\n", + " mt = (edges[0])\n", + " mr = (edges[1])\n", + " mc = utils.chirp_mass_mtmr(mt[:, np.newaxis], mr[np.newaxis, :])\n", + " mc = mc[:, :, np.newaxis, np.newaxis]\n", + " \n", + " # convert from observer-frame to rest-frame; still using frequency-bin centers\n", + " fr = utils.frst_from_fobs(fc[np.newaxis, np.newaxis, np.newaxis, :], redz)\n", + "\n", + " hs_edges = utils.gw_strain_source(mc, dc, fr)\n", + " return hs_edges\n", + "\n", + " \n", + "def sam_model(sam, hard,\n", + " dur=16.03*YR, cad=0.2*YR, use_redz=True):\n", + " fobs_gw_cents = utils.nyquist_freqs(dur,cad)\n", + " fobs_gw_edges = utils.nyquist_freqs_edges(dur,cad)\n", + " fobs_orb_cents = fobs_gw_cents/2.0\n", + " fobs_orb_edges = fobs_gw_edges/2.0\n", + "\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " else:\n", + " raise Exception(\"'hard' must be an instance of 'Fixed_Time_2PL_SAM' or 'Hard_GW'\")\n", + "\n", + " redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + " edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + " number = holo.sam_cython.integrate_differential_number_3dx1d(edges, diff_num)\n", + "\n", + " hsf_cents = strain_amp_at_bin_centers_redz(edges, redz_final)\n", + " hsf_edges = strain_amp_at_bin_edges_redz(edges, redz_final)\n", + " hsi_cents = strain_amp_at_bin_centers_redz(edges)\n", + " hsi_edges = strain_amp_at_bin_edges_redz(edges)\n", + "\n", + " vals = {\n", + " 'hard':hard, 'sam':sam, 'edges':edges, 'number': number, 'diff_num':diff_num, 'redz_final':redz_final,\n", + " 'hsi_cents':hsi_cents, 'hsi_edges':hsi_edges, 'hsf_cents':hsf_cents, 'hsf_edges':hsf_edges, \n", + " 'fobs_gw_cents':fobs_gw_cents, 'fobs_gw_edges':fobs_gw_edges, \n", + " 'fobs_orb_cents':fobs_orb_cents, 'fobs_orb_edges':fobs_orb_edges, 'hard_name':hard_name\n", + " }\n", + " return vals\n", + "\n", + "def integrate_mm(dnum, edges): # integrate dN/dlogM\n", + " num = utils.trapz(dnum, np.log10(edges[0]), axis=0, cumsum=False)\n", + " return num\n", + "def integrate_qq(dnum, edges): # integrate dN/dq\n", + " num = utils.trapz(dnum, edges[1], axis=1, cumsum=False)\n", + " return num\n", + "def integrate_zz(dnum, edges): # dN/dz\n", + " num = utils.trapz(dnum, edges[2], axis=2, cumsum=False)\n", + " return num\n", + "def integrate_ff(dnum, fobs_gw_edges): # dN/dlogn\n", + " num = dnum*np.diff(np.log(fobs_gw_edges))\n", + " return num " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Shape 5, 6, 7" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=(5,6,7))\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "vals = sam_model(sam, hard)\n", + "\n", + "fobs_orb_cents=vals['fobs_orb_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "redz_final_cy, diff_num_cy = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "temp, diff_num_py, redz_final_py = sam.dynamic_binary_number_at_fobs(hard, fobs_orb_cents)\n", + "print('cython:', utils.stats(redz_final_cy))\n", + "print('python:', utils.stats(redz_final_py))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Compare redz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "fig, ax = plot.figax(xlabel='index', ylabel='redz_final', xscale='linear', yscale='linear')\n", + "ax.scatter(np.arange(redz_final_py.size), redz_final_py.flatten(), label='python', marker='x', alpha=0.5)\n", + "ax.scatter(np.arange(redz_final_cy.size), redz_final_cy.flatten(), label='cython', marker='+', alpha=0.5)\n", + "ax.set_title('%s, %s' % (vals['hard_name'], str(sam.shape)))\n", + "ax.legend()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Compare diff_num" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('cython:', utils.stats(diff_num_cy))\n", + "print('python:', utils.stats(diff_num_py))\n", + "\n", + "fig, ax = plot.figax(xlabel='index', ylabel='diff_num', xscale='linear', yscale='log')\n", + "ax.scatter(np.arange(diff_num_py.size), diff_num_py.flatten(), label='python', marker='x', alpha=0.5)\n", + "ax.scatter(np.arange(diff_num_cy.size), diff_num_cy.flatten(), label='cython', marker='+', alpha=0.5)\n", + "ax.set_title('%s, %s' % (vals['hard_name'], str(sam.shape)))\n", + "ax.legend()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Shape 5, 6, 7" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sam.Semi_Analytic_Model(shape=20)\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "vals = sam_model(sam, hard)\n", + "\n", + "fobs_orb_cents=vals['fobs_orb_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "redz_final_cy, diff_num_cy = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "temp, diff_num_py, redz_final_py = sam.dynamic_binary_number_at_fobs(hard, fobs_orb_cents)\n", + "print('cython:', utils.stats(redz_final_cy))\n", + "print('python:', utils.stats(redz_final_py))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Compare redz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "fig, ax = plot.figax(xlabel='index', ylabel='redz_final', xscale='linear', yscale='linear')\n", + "ax.scatter(np.arange(redz_final_py.size), redz_final_py.flatten(), label='python', marker='x', alpha=0.5)\n", + "ax.scatter(np.arange(redz_final_cy.size), redz_final_cy.flatten(), label='cython', marker='+', alpha=0.5)\n", + "ax.set_title('%s, %s' % (vals['hard_name'], str(sam.shape)))\n", + "ax.legend()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## compare diff_num" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('cython:', utils.stats(diff_num_cy))\n", + "print('python:', utils.stats(diff_num_py))\n", + "\n", + "fig, ax = plot.figax(xlabel='index', ylabel='diff_num', xscale='linear', yscale='log')\n", + "ax.scatter(np.arange(diff_num_py.size), diff_num_py.flatten(), label='python', marker='x', alpha=0.5)\n", + "ax.scatter(np.arange(diff_num_cy.size), diff_num_cy.flatten(), label='cython', marker='+', alpha=0.5)\n", + "ax.set_title('%s, %s' % (vals['hard_name'], str(sam.shape)))\n", + "ax.legend()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Weird Spot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mm, qq, zz, ff = 15, 18, 15, 28 # weird spot\n", + "\n", + "fobs_orb_cents = vals['fobs_orb_cents']\n", + "fobs_gw_cents = vals['fobs_gw_cents']\n", + "redz_final, diff_num = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "\n", + "hs_final_cy = holo.gravwaves.strain_amp_from_bin_edges_redz(vals['edges'], redz_final_cy)\n", + "hs_final_py = holo.gravwaves.strain_amp_from_bin_edges_redz(vals['edges'], redz_final_py)\n", + "hs_init = strain_amp_at_bin_centers_redz(vals['edges'], redz=None)\n", + "\n", + "print('hs_init:', utils.stats(hs_init), f\", {hs_init.shape=}\")\n", + "print('hs_final_cy:', utils.stats(hs_final_cy), f\", {hs_init.shape=}\")\n", + "print('hs_final_py:', utils.stats(hs_final_py), f\", {hs_init.shape=}\")\n", + "\n", + "rz_init = kale.utils.midpoints(sam.redz, axis=0)\n", + "rzf_cy = redz_final_cy\n", + "rzf_py = redz_final_py\n", + "for dd in range(3):\n", + " rzf_cy = np.moveaxis(rzf_cy, dd, 0)\n", + " rzf_cy = kale.utils.midpoints(rzf_cy, axis=0)\n", + " rzf_cy = np.moveaxis(rzf_cy, 0, dd)\n", + "\n", + " rzf_py = np.moveaxis(rzf_py, dd, 0)\n", + " rzf_py = kale.utils.midpoints(rzf_py, axis=0)\n", + " rzf_py = np.moveaxis(rzf_py, 0, dd)\n", + "\n", + "print('M(mm=%d)=%.2e M_sol, q(qq=%d)=%.2e, f_obs,orb(ff=%d)=%.2f/yr, f_obs,gw(ff=%d)=%.2f/yr' \n", + " % (mm, utils.midpoints(vals['edges'][0])[mm]/MSOL, \n", + " qq, utils.midpoints(vals['edges'][1])[qq],\n", + " ff, fobs_orb_cents[ff]*YR,\n", + " ff, fobs_gw_cents[ff]*YR))\n", + "for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_fin,cy=%.2f, z_fin,py=%.2f, hs_init=%.2e, hs_fin,cy=%.2e, hs_fin,py=%.2e' \n", + " % (zz, rz_init[zz], rzf_cy[mm,qq,zz,ff], rzf_py[mm,qq,zz,ff], \n", + " hs_init[mm,qq,zz,ff], hs_final_cy[mm,qq,zz,ff], hs_final_py[mm,qq,zz,ff]))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Note that hs_fin cy and py do not match. There are places where cython gives nonzero but python gives 0." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mm, qq, zz, ff = 15, 18, 15, 25 # weird spot\n", + "for ff in [0,4,9,14,19,24,29,34,38]:\n", + " print('\\nM(mm=%d)=%.2e M_sol, q(qq=%d)=%.2e, f_obs,orb(ff=%d)=%.2f/yr, f_obs,gw(ff=%d)=%.2f/yr' \n", + " % (mm, utils.midpoints(vals['edges'][0])[mm]/MSOL, \n", + " qq, utils.midpoints(vals['edges'][1])[qq],\n", + " ff, fobs_orb_cents[ff]*YR,\n", + " ff, fobs_gw_cents[ff]*YR))\n", + " for zz in (14,15,16):\n", + " print('zz=%d, z_init=%.2f, z_fin,cy=%.2f, z_fin,py=%.2f, hs_init=%.2e, hs_fin,cy=%.2e, hs_fin,py=%.2e' \n", + " % (zz, rz_init[zz], rzf_cy[mm,qq,zz,ff], rzf_py[mm,qq,zz,ff], \n", + " hs_init[mm,qq,zz,ff], hs_final_cy[mm,qq,zz,ff], hs_final_py[mm,qq,zz,ff]))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Plot weird spot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_strain_vs_z(\n", + " vals, mm_arr=[mm,], qq_arr=[qq,], zz_arr=[zz,], ff_arr=[ff,],\n", + " all_hs=np.array([hs_init, hs_final_cy, hs_final_py]), \n", + " labels_hs=np.array(['init z', 'cython final z', 'python final z']), \n", + " linestyles = np.array(['--', '-', '-.'])):\n", + "\n", + " fobs_gw_cents = vals['fobs_gw_cents']\n", + " cents_mm = utils.midpoints(vals['edges'][0])\n", + " cents_qq = utils.midpoints(vals['edges'][1])\n", + " cents_zz = utils.midpoints(vals['edges'][2])\n", + " colors=cm.rainbow_r(np.linspace(0,1,len(ff_arr)))\n", + "\n", + " fig, ax = holo.plot.figax(\n", + " xlabel='$z$',\n", + " ylabel='$h_s$',\n", + " )\n", + "\n", + " xx = cents_zz # redshifts\n", + "\n", + " for mi,mm in enumerate(mm_arr):\n", + " for qi,qq in enumerate(qq_arr):\n", + " for zi,zz in enumerate(zz_arr):\n", + " for fi,ff in enumerate(ff_arr):\n", + " color=colors[fi]\n", + " for yi, yy in enumerate(all_hs):\n", + " if mi==0 and qi==0 and zi==0 and fi==0:\n", + " label_hs = labels_hs[yi]\n", + " else:\n", + " label_hs = ''\n", + " if yi==0:\n", + " label_hs = label_hs + (', $M=%.2e\\ M_\\odot$, $q=%.2f$, $f=%.2f$/yr' \n", + " % (cents_mm[mm]/MSOL, cents_qq[qq], fobs_gw_cents[ff]*YR))\n", + " ax.plot(xx, yy[mm,qq,:,ff], label=label_hs, linestyle=linestyles[yi], alpha=0.65, \n", + " color=color)\n", + "\n", + "\n", + " leg = fig.legend(ncols=1, bbox_to_anchor=(.9,.9), loc='upper left', fontsize=12)\n", + " title='%s, %s' % (str(vals['hard_name']), str(vals['sam'].shape))\n", + " fig.suptitle(title)\n", + " fig.tight_layout\n", + " return fig, title\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mm, qq, zz, ff = 15, 18, 15, 28 # weird spot\n", + "\n", + "fig,title = plot_strain_vs_z(\n", + " vals, mm_arr=[mm,], qq_arr=[qq,], zz_arr=[zz,], ff_arr=[0,4,9,14,19,24,29,34,38],\n", + " all_hs=np.array([ hs_final_cy, hs_final_py, hs_init,]), \n", + " labels_hs=np.array(['cython final z', 'python final z', 'init z', ]), \n", + " linestyles = np.array([ '--', '-', ':',]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig,title = plot_strain_vs_z(\n", + " vals, mm_arr=[mm,], qq_arr=[qq,], zz_arr=[zz,], ff_arr=[0,4,9,14,19,24,29,34,38],\n", + " all_hs=np.array([hs_init, hs_final_py]), \n", + " labels_hs=np.array(['init z', 'python final z']), \n", + " linestyles = np.array(['--', '-']))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig,title = plot_strain_vs_z(\n", + " vals, mm_arr=[mm,], qq_arr=[qq,], zz_arr=[zz,], ff_arr=[0,4,9,14,19,24,29,34,38],\n", + " all_hs=np.array([hs_final_cy, hs_final_py]), \n", + " labels_hs=np.array(['cython final z', 'python final z']), \n", + " linestyles = np.array(['--', '-']))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From e74d9de840ea5b348ba7f6ebcfe7dcafd940d8eb Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 11 Jun 2023 16:27:02 -0700 Subject: [PATCH 042/291] Corrected param naming for GWB anatomy plots. --- ...3_gwb_anatomy.ipynb => take3_gwb_anatomy_medshape.ipynb} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename ecg-notebooks/parameter_investigation/{take3_gwb_anatomy.ipynb => take3_gwb_anatomy_medshape.ipynb} (99%) diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb similarity index 99% rename from ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb rename to ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb index 05b47ac0..d6fa1730 100644 --- a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy.ipynb +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb @@ -634,10 +634,12 @@ " for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", - " _params = pspace.param_samples[0]*pars\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", " params.append(_params)\n", " # construct `sam` and `hard` instances based on these parameters\n", - " sam, hard = pspace.model_for_normalized_params(pars)\n", + " # sam, hard = pspace.model_for_normalized_params(pars)\n", + " sam, hard = pspace.model_for_params(_params)\n", " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", " hard_name = 'Fixed Time'\n", " elif isinstance(hard, holo.hardening.Hard_GW):\n", From 5c112c87044b116fdc46f95d3a277ed76f621087 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 11 Jun 2023 20:41:46 -0700 Subject: [PATCH 043/291] Troubleshooting variations in GWB anatomy plots for dif pspace.model_for_params or pspace.model_for_normalized_params --- .../take3_gwb_anatomy_medshape.ipynb | 52 +- .../take4A_old_bad_anatomy_fullshape.ipynb | 773 ++++++++++++++++ .../take4B_old_gwb_anatomy_fullshape.ipynb | 810 +++++++++++++++++ .../take4_gwb_anatomy_fullshape.ipynb | 131 ++- ...take5_gwb_anatomy_fullshape_normpars.ipynb | 823 ++++++++++++++++++ 5 files changed, 2531 insertions(+), 58 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb create mode 100644 ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb create mode 100644 ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb index d6fa1730..7190dc54 100644 --- a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb @@ -53,7 +53,8 @@ "\n", "# choose each parameter to be half-way across the range provided by the library\n", "pars = 0.5 * np.ones(num_pars)\n", - "params = pars * pspace.param_samples\n", + "params = pspace.normalized_params(pars)\n", + "# params = pars * pspace.param_samples\n", "print(f\"{pars=}\")\n", "print(f\"{params=}\")\n", "\n", @@ -129,9 +130,9 @@ " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", " text = ''\n", " for pp, name in enumerate(param_names):\n", - " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", - " if pp == int(len(param_names)/2):\n", - " text = text+'\\n'\n", + " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", "\n", "\n", @@ -181,7 +182,7 @@ " ax.set_xlabel(labels[ii])\n", " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", - " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", " fig.tight_layout()\n", " return fig\n", "\n", @@ -216,14 +217,16 @@ "outputs": [], "source": [ "\n", - "\n", - "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + "def detect_pspace_model(data, dur=DUR,\n", " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", " npsrs, sigma, nskies, thresh)\n", " return dsdata\n", "\n", - "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)\n", + "dsdata_mid= detect_pspace_model(data)\n", "print(f\"{dsdata_mid.keys()=}\")" ] }, @@ -369,7 +372,7 @@ " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", " nreals, nskies)\n", " \n", - " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", " fig.tight_layout()\n", " return fig\n", "\n", @@ -414,7 +417,8 @@ "for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", - " _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " # _params = pspace.param_samples[0]*pars\n", " params_hard_time.append(_params)\n", " # construct `sam` and `hard` instances based on these parameters\n", " sam, hard = pspace.model_for_normalized_params(pars)\n", @@ -501,7 +505,7 @@ " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", " datlw = np.array([3,4,5]),\n", - " dattext_yy = np.array([-0.05, -0.1, -0.15])):\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", " \n", " fobs_cents = data[0]['fobs_cents']\n", " fig, axs = holo.plot.figax(\n", @@ -520,14 +524,15 @@ "\n", " for ii, dat in enumerate(data):\n", " print(f'on dat {ii}')\n", - " dsdat = detect_pspace_model(fobs_cents, dat['hc_ss'], dat['hc_bg'])\n", + " dsdat = detect_pspace_model(dat)\n", " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", " dsdat['snr_ss'], dsdat['snr_bg'], \n", " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", " fig.tight_layout()\n", "\n", @@ -537,6 +542,15 @@ " hard_name=hard_name, shape=sam.shape, target_param=target_param)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(params_hard_time[0])" + ] + }, { "cell_type": "code", "execution_count": null, @@ -578,7 +592,7 @@ " hard_name, shape, target_param,\n", " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", - " dattext_yy = np.array([-0.05, -0.15, -0.25])):\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", " fobs_cents = data[0]['fobs_cents']\n", " \n", " fig, axs = holo.plot.figax(\n", @@ -590,7 +604,8 @@ " \n", " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", " fig.tight_layout()\n", "\n", @@ -773,13 +788,6 @@ "fig = draw_three_models(*rv_hard_gamma_inner)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb new file mode 100644 index 00000000..7f6bf31c --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb @@ -0,0 +1,773 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Choose a Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + " # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "params = pars * pspace.param_samples\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents = data['fobs_cents']\n", + "hc_ss_mid = data['hc_ss']\n", + "hc_bg_mid = data['hc_bg']\n", + "sspar_mid = sings.all_sspars(fobs_cents, data['sspar'])\n", + "bgpar_mid = data['bgpar']\n", + "binpar_names = sings.par_names\n", + "# params = pars*pspace.params\n", + "print(f\"{hc_ss_mid.shape=}\")\n", + "print(f\"{bgpar_mid.shape=}\")\n", + "print(f\"{sspar_mid.shape=}\")\n", + "print(f\"{param_names=}\")\n", + "print(f\"{params=}\")\n", + "print(f\"{binpar_names=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Mid of all params\n", + "## Plot hc vs. bin pars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", + " if pp == int(len(param_names)/2):\n", + " text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 60\n", + "SIGMA = 1e-7\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata\n", + "\n", + "dsdata_mid= detect_pspace_model(fobs_cents, hc_ss_mid, hc_bg_mid)\n", + "print(f\"{dsdata_mid.keys()=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Plot everything vs freqs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss_mid = dsdata_mid['dp_ss'] \n", + "dp_bg_mid = dsdata_mid['dp_bg']\n", + "snr_ss_mid = dsdata_mid['snr_ss']\n", + "snr_bg_mid = dsdata_mid['snr_bg']\n", + "print(f\"{dp_ss_mid.shape=}, {dp_bg_mid.shape=}, {snr_ss_mid.shape=}, {snr_bg_mid.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest):\n", + " if show_reals:\n", + " if fast:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " else:\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor='k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + " fast=False)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare Simulations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Choose a parameter that we're going to vary\n", + "target_param = 'hard_time' # the name of the parameter, has to exist in `param_names`\n", + "params_list = [0.0, 0.5, 1.0] # the values we'll check\n", + "param_idx = param_names.index(target_param)\n", + "\n", + "data_hard_time = []\n", + "params_hard_time = []\n", + "for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " _params = pspace.param_samples[0]*pars\n", + " params_hard_time.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data_hard_time.append(_data)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dat in data_hard_time:\n", + " plot_everything_vs_freqs_from_data(dat)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def draw_three_models(\n", + " data, params, hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.05, -0.1, -0.15])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(fobs_cents, dat['hc_ss'], dat['hc_bg'])\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + " hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data_hard_time[0].keys())\n", + "print(data['number'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def draw_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.05, -0.15, -0.25])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + " hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vary Parameters!!!!!!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " ):\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " _params = pspace.param_samples[0]*pars\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " return (data, params, hard_name, sam.shape, target_param)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# data, params = data_hard_time, params_hard_time\n", + "fig = draw_three_models(*rv_hard_time)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0') \n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### compare takes" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data, params, hard_name, shape, target_param = rv_gsmf_phi0\n", + "print(data[1].keys())\n", + "print(holo.utils.stats(data[1]['bin_params'][1]))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10') \n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex') \n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_gamma_inner'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner') \n", + "fig = draw_three_models(*rv_hard_gamma_inner)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb new file mode 100644 index 00000000..2246c7f6 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb @@ -0,0 +1,810 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1 Choose a Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "params = pars * pspace.param_samples\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 Mid of all params\n", + "## 2.1 Plot hc vs. bin pars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents = data['fobs_cents']\n", + "hc_ss_mid = data['hc_ss']\n", + "hc_bg_mid = data['hc_bg']\n", + "sspar_mid = sings.all_sspars(fobs_cents, data['sspar'])\n", + "bgpar_mid = data['bgpar']\n", + "binpar_names = sings.par_names\n", + "# params = pars*pspace.params\n", + "print(f\"{hc_ss_mid.shape=}\")\n", + "print(f\"{bgpar_mid.shape=}\")\n", + "print(f\"{sspar_mid.shape=}\")\n", + "print(f\"{param_names=}\")\n", + "print(f\"{params=}\")\n", + "print(f\"{binpar_names=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", + " if pp == int(len(param_names)/2):\n", + " text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "# fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 Calibrate PTA" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 50\n", + "SIGMA = 3.55e-6\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "def detect_pspace_model(data, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape = hc_ss_mid.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "debug=True\n", + "\n", + "# calculate dur, cad, dfobs\n", + "dur = DUR * YR\n", + "hifr = nfreqs/dur\n", + "cad = 1.0 / (2 * hifr)\n", + "fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad)\n", + "dfobs = np.diff(fobs_edges)\n", + "\n", + "# build PTA\n", + "if debug: print('Building pulsar timing array.')\n", + "phis = np.random.uniform(0, 2*np.pi, size = NPSRS)\n", + "thetas = np.random.uniform(np.pi/2, np.pi/2, size = NPSRS)\n", + "# sigmas = np.ones_like(phis)*sigma\n", + "psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=SIGMA,\n", + " phi=phis, theta=thetas)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, hc_bg_mid)\n", + "print(f\"{np.median(dp_bg)=}, {np.mean(dp_bg)=}, {np.std(dp_bg)=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dsdata_mid= detect_pspace_model(data)\n", + "print(f\"{dsdata_mid.keys()=}\")\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.3 Plot everything vs freqs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss_mid = dsdata_mid['dp_ss'] \n", + "dp_bg_mid = dsdata_mid['dp_bg']\n", + "snr_ss_mid = dsdata_mid['snr_ss']\n", + "snr_bg_mid = dsdata_mid['snr_bg']\n", + "print(f\"{dp_ss_mid.shape=}, {dp_bg_mid.shape=}, {snr_ss_mid.shape=}, {snr_bg_mid.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest):\n", + " if show_reals:\n", + " if fast:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " else:\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor='k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + " fast=False)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 Plot-Three Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def draw_three_models(\n", + " data, params, hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.05, -0.1, -0.15])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(dat)\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def draw_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.05, -0.15, -0.25])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 Vary Parameters!!!!!!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + "\n", + " ):\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " pars = 0.5 * np.ones(num_pars) \n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " return (data, params, hard_name, sam.shape, target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(param_names)\n", + "# print(rv_gsmf_mchar0_log10[1][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(pspace.param_samples[0])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", + "fig = draw_three_models(*rv_hard_time)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0') \n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(rv_gsmf_phi0[0]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# dsdat1 = detect_pspace_model(rv_gsmf_phi0[0][1])\n", + "# dsdat2 = detect_pspace_model(rv_gsmf_mchar0_log10[0][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(param_names)\n", + "# print(rv_gsmf_phi0[1][2])\n", + "# print(rv_gsmf_mchar0_log10[1][1]) # this is using the wrong gsmf_phi0\n", + "# print(rv_hard_time[1][1])\n", + "# print(rv_mmb_mamp_log10[1][1])\n", + "# print(rv_mmb_scatter_dex[1][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10') \n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex') \n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_gamma_inner'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner') \n", + "fig = draw_three_models(*rv_hard_gamma_inner)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb index 512fa8a8..056466c9 100644 --- a/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take4_gwb_anatomy_fullshape.ipynb @@ -60,7 +60,8 @@ "\n", "# choose each parameter to be half-way across the range provided by the library\n", "pars = 0.5 * np.ones(num_pars)\n", - "params = pars * pspace.param_samples\n", + "# params = pars * pspace.param_samples\n", + "params = pspace.normalized_params(pars)\n", "print(f\"{pars=}\")\n", "print(f\"{params=}\")\n", "\n", @@ -120,8 +121,8 @@ " text = ''\n", " for pp, name in enumerate(param_names):\n", " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", - " if pp == int(len(param_names)/2):\n", - " text = text+'\\n'\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", "\n", "\n", @@ -171,11 +172,11 @@ " ax.set_xlabel(labels[ii])\n", " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", - " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", " fig.tight_layout()\n", " return fig\n", "\n", - "fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + "# fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" ] }, { @@ -382,7 +383,7 @@ " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", " nreals, nskies)\n", " \n", - " draw_sample_text(fig, params[0], param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", " fig.tight_layout()\n", " return fig\n", "\n", @@ -390,9 +391,9 @@ "\n", "\n", "\n", - "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", - " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", - " fast=False)" + "# fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + "# dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + "# fast=False)" ] }, { @@ -470,7 +471,7 @@ " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", " datlw = np.array([3,4,5]),\n", - " dattext_yy = np.array([-0.05, -0.1, -0.15])):\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", " \n", " fobs_cents = data[0]['fobs_cents']\n", " fig, axs = holo.plot.figax(\n", @@ -496,7 +497,8 @@ " dsdat['snr_ss'], dsdat['snr_bg'], \n", " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", " fig.tight_layout()\n", "\n", @@ -537,7 +539,7 @@ " hard_name, shape, target_param,\n", " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", - " dattext_yy = np.array([-0.05, -0.15, -0.25])):\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", " fobs_cents = data[0]['fobs_cents']\n", " \n", " fig, axs = holo.plot.figax(\n", @@ -549,7 +551,8 @@ " \n", " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], yy=dattext_yy[ii], fontsize=12)\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", " fig.tight_layout()\n", "\n", @@ -576,12 +579,7 @@ "def vary_parameter(\n", " target_param, # the name of the parameter, has to exist in `param_names`\n", " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", - " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", - "\n", " ):\n", - " # choose each parameter to be half-way across the range provided by the library\n", - " pars = 0.5 * np.ones(num_pars) \n", - " # Choose parameter to vary\n", " param_idx = param_names.index(target_param)\n", "\n", " data = []\n", @@ -589,11 +587,10 @@ " for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", - " # _params = pspace.param_samples[0]*pars\n", - " _params = pspace.normalized_params(pars)\n", + " _params = pspace.param_samples[0]*pars\n", " params.append(_params)\n", " # construct `sam` and `hard` instances based on these parameters\n", - " sam, hard = pspace.model_for_params(_params)\n", + " sam, hard = pspace.model_for_normalized_params(pars)\n", " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", " hard_name = 'Fixed Time'\n", " elif isinstance(hard, holo.hardening.Hard_GW):\n", @@ -602,7 +599,40 @@ " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", - " return (data, params, hard_name, sam.shape, target_param)" + " return (data, params, hard_name, sam.shape, target_param)\n", + "\n", + "\n", + "\n", + "# def vary_parameter(\n", + "# target_param, # the name of the parameter, has to exist in `param_names`\n", + "# params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + "# pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + "\n", + "# ):\n", + "# # choose each parameter to be half-way across the range provided by the library\n", + "# pars = 0.5 * np.ones(num_pars) \n", + "# # Choose parameter to vary\n", + "# param_idx = param_names.index(target_param)\n", + "\n", + "# data = []\n", + "# params = []\n", + "# for ii, par in enumerate(params_list):\n", + "# pars[param_idx] = par\n", + "# print(f\"{ii=}, {pars=}\")\n", + "# _params = pspace.param_samples[0]*pars\n", + "# # _params = pspace.normalized_params(pars)\n", + "# params.append(_params)\n", + "# # construct `sam` and `hard` instances based on these parameters\n", + "# sam, hard = pspace.model_for_normalized_params(pars)\n", + "# if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + "# hard_name = 'Fixed Time'\n", + "# elif isinstance(hard, holo.hardening.Hard_GW):\n", + "# hard_name = 'GW Only'\n", + "# # run this model, retrieving binary parameters and the GWB\n", + "# _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + "# gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "# data.append(_data)\n", + "# return (data, params, hard_name, sam.shape, target_param)" ] }, { @@ -621,7 +651,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(pspace.param_samples[0])" + "print(pspace.param_samples[0])\n", + "# print(type(rv_hard_time[1][0].values()))" ] }, { @@ -638,9 +669,9 @@ "metadata": {}, "outputs": [], "source": [ - "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", + "# rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", "fig = draw_three_models(*rv_hard_time)\n", - "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + "fig = draw_three_hs_vs_binpars(*rv_hard_time)\n" ] }, { @@ -662,6 +693,34 @@ "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### compare takes" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data = rv_gsmf_phi0[0]\n", + "print(data[1].keys())\n", + "print(holo.utils.stats(data[1]['bin_params'][1]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -670,6 +729,17 @@ "## 'gsmf_mchar0_log10'" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -703,17 +773,6 @@ "# print(rv_mmb_scatter_dex[1][1])" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", - "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" - ] - }, { "attachments": {}, "cell_type": "markdown", diff --git a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb new file mode 100644 index 00000000..153f0926 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb @@ -0,0 +1,823 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1 Choose a Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "# params = pars * pspace.param_samples\n", + "params = pspace.normalized_params(pars)\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 Mid of all params\n", + "## 2.1 Plot hc vs. bin pars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents = data['fobs_cents']\n", + "hc_ss_mid = data['hc_ss']\n", + "hc_bg_mid = data['hc_bg']\n", + "sspar_mid = sings.all_sspars(fobs_cents, data['sspar'])\n", + "bgpar_mid = data['bgpar']\n", + "binpar_names = sings.par_names\n", + "# params = pars*pspace.params\n", + "print(f\"{hc_ss_mid.shape=}\")\n", + "print(f\"{bgpar_mid.shape=}\")\n", + "print(f\"{sspar_mid.shape=}\")\n", + "print(f\"{param_names=}\")\n", + "print(f\"{params=}\")\n", + "print(f\"{binpar_names=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 Calibrate PTA" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 50\n", + "SIGMA = 3.55e-6\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "def detect_pspace_model(data, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape = hc_ss_mid.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "debug=True\n", + "\n", + "# calculate dur, cad, dfobs\n", + "dur = DUR * YR\n", + "hifr = nfreqs/dur\n", + "cad = 1.0 / (2 * hifr)\n", + "fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad)\n", + "dfobs = np.diff(fobs_edges)\n", + "\n", + "# build PTA\n", + "if debug: print('Building pulsar timing array.')\n", + "phis = np.random.uniform(0, 2*np.pi, size = NPSRS)\n", + "thetas = np.random.uniform(np.pi/2, np.pi/2, size = NPSRS)\n", + "# sigmas = np.ones_like(phis)*sigma\n", + "psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=SIGMA,\n", + " phi=phis, theta=thetas)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, hc_bg_mid)\n", + "print(f\"{np.median(dp_bg)=}, {np.mean(dp_bg)=}, {np.std(dp_bg)=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dsdata_mid= detect_pspace_model(data)\n", + "print(f\"{dsdata_mid.keys()=}\")\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.3 Plot everything vs freqs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss_mid = dsdata_mid['dp_ss'] \n", + "dp_bg_mid = dsdata_mid['dp_bg']\n", + "snr_ss_mid = dsdata_mid['snr_ss']\n", + "snr_bg_mid = dsdata_mid['snr_bg']\n", + "print(f\"{dp_ss_mid.shape=}, {dp_bg_mid.shape=}, {snr_ss_mid.shape=}, {snr_bg_mid.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest):\n", + " if show_reals:\n", + " if fast:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " else:\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor='k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + " fast=False)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 Plot-Three Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def draw_three_models(\n", + " data, params, hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(dat)\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def draw_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 Vary Parameters!!!!!!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + "\n", + " ):\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " pars = 0.5 * np.ones(num_pars) \n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " return (data, params, hard_name, sam.shape, target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(param_names)\n", + "# print(rv_gsmf_mchar0_log10[1][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(pspace.param_samples[0])\n", + "# print(type(rv_hard_time[1][0].values()))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", + "fig = draw_three_models(*rv_hard_time)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0') \n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(rv_gsmf_phi0[0]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# dsdat1 = detect_pspace_model(rv_gsmf_phi0[0][1])\n", + "# dsdat2 = detect_pspace_model(rv_gsmf_mchar0_log10[0][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(param_names)\n", + "# print(rv_gsmf_phi0[1][2])\n", + "# print(rv_gsmf_mchar0_log10[1][1]) # this is using the wrong gsmf_phi0\n", + "# print(rv_hard_time[1][1])\n", + "# print(rv_mmb_mamp_log10[1][1])\n", + "# print(rv_mmb_scatter_dex[1][1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10') \n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex') \n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_gamma_inner'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner') \n", + "fig = draw_three_models(*rv_hard_gamma_inner)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 221355509c1f5c380bd9bef78cadd165a578ca1d Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 12 Jun 2023 11:23:58 -0700 Subject: [PATCH 044/291] Looking at how all parameters vary differently for longer hardening times. --- ...take5_gwb_anatomy_fullshape_normpars.ipynb | 131 ++++++++++++++++-- 1 file changed, 116 insertions(+), 15 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb index 153f0926..e71e5b05 100644 --- a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb +++ b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb @@ -580,10 +580,16 @@ " target_param, # the name of the parameter, has to exist in `param_names`\n", " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", - "\n", + " pars=None \n", " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", " # choose each parameter to be half-way across the range provided by the library\n", - " pars = 0.5 * np.ones(num_pars) \n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", " # Choose parameter to vary\n", " param_idx = param_names.index(target_param)\n", "\n", @@ -666,13 +672,26 @@ "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 0" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "print(rv_gsmf_phi0)" + "pars = 0.5 * np.ones(num_pars) \n", + "pars[0] = 0.0 \n", + "\n", + "rv_gsmf_phi0_hard0 = vary_parameter('gsmf_phi0', pars=pars) \n", + "fig = draw_three_models(*rv_gsmf_phi0_hard0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard0)" ] }, { @@ -680,7 +699,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 'gsmf_mchar0_log10'" + "hard_time 1" ] }, { @@ -689,7 +708,20 @@ "metadata": {}, "outputs": [], "source": [ - "print(len(rv_gsmf_phi0[0]))" + "pars = 0.5 * np.ones(num_pars) \n", + "pars[0] = 1.0 \n", + "\n", + "rv_gsmf_phi0_hard1 = vary_parameter('gsmf_phi0', pars=pars) \n", + "fig = draw_three_models(*rv_gsmf_phi0_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard1)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" ] }, { @@ -698,8 +730,17 @@ "metadata": {}, "outputs": [], "source": [ - "# dsdat1 = detect_pspace_model(rv_gsmf_phi0[0][1])\n", - "# dsdat2 = detect_pspace_model(rv_gsmf_mchar0_log10[0][1])" + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 0" ] }, { @@ -708,12 +749,18 @@ "metadata": {}, "outputs": [], "source": [ - "# print(param_names)\n", - "# print(rv_gsmf_phi0[1][2])\n", - "# print(rv_gsmf_mchar0_log10[1][1]) # this is using the wrong gsmf_phi0\n", - "# print(rv_hard_time[1][1])\n", - "# print(rv_mmb_mamp_log10[1][1])\n", - "# print(rv_mmb_scatter_dex[1][1])" + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', \n", + " pars=[0,0.5,0.5,0.5,0.5,0.5]) \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" ] }, { @@ -722,7 +769,8 @@ "metadata": {}, "outputs": [], "source": [ - "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', \n", + " pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" ] @@ -746,6 +794,26 @@ "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10_hard1 = vary_parameter('mmb_mamp_log10',\n", + " pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", + "fig = draw_three_models(*rv_mmb_mamp_log10_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -765,6 +833,26 @@ "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex_hard1 = vary_parameter('mmb_scatter_dex',\n", + " pars=[1.0, 0.5, 0.5, 0.5, 0.5, 0.5]) \n", + "fig = draw_three_models(*rv_mmb_scatter_dex_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -784,12 +872,25 @@ "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "rv_hard_gamma_inner_hard1 = vary_parameter('hard_gamma_inner',\n", + " pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", + "fig = draw_three_models(*rv_hard_gamma_inner_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" + ] }, { "cell_type": "code", From 2866f864c8042cf7f280dc1d8959afa4af88676b Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 12 Jun 2023 11:26:09 -0700 Subject: [PATCH 045/291] Found differences in plots due to pars, previously corrected. --- .../take4A_old_bad_anatomy_fullshape.ipynb | 17 +++++++++-------- .../take4B_old_gwb_anatomy_fullshape.ipynb | 9 ++++++++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb index 7f6bf31c..0998bb0c 100644 --- a/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take4A_old_bad_anatomy_fullshape.ipynb @@ -344,9 +344,9 @@ "\n", "\n", "\n", - "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", - " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", - " fast=False)" + "# fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + "# dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + "# fast=False)" ] }, { @@ -492,8 +492,8 @@ "\n", " return fig\n", "\n", - "fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", - " hard_name=hard_name, shape=sam.shape, target_param=target_param)" + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" ] }, { @@ -555,8 +555,8 @@ "\n", " return fig\n", "\n", - "fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", - " hard_name, sam.shape, target_param)\n" + "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" ] }, { @@ -576,7 +576,8 @@ "def vary_parameter(\n", " target_param, # the name of the parameter, has to exist in `param_names`\n", " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", - " ):\n", + " reset_pars=False,):\n", + " if reset_pars: pars = 0.5 * np.ones(num_pars)\n", " param_idx = param_names.index(target_param)\n", "\n", " data = []\n", diff --git a/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb b/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb index 2246c7f6..c3d24d08 100644 --- a/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take4B_old_gwb_anatomy_fullshape.ipynb @@ -119,7 +119,7 @@ " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", " text = ''\n", " for pp, name in enumerate(param_names):\n", - " text = text+\"'%s'=%.2e, \" % (name, params[pp])\n", + " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", " if pp == int(len(param_names)/2):\n", " text = text+'\\n'\n", " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", @@ -703,6 +703,13 @@ "# print(rv_mmb_scatter_dex[1][1])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, From 955d7aeec1064e214f7bdf6bfbc972c1b569f4a2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 12 Jun 2023 11:26:42 -0700 Subject: [PATCH 046/291] Plotting functions dadt(a) for diff gamma_inner and gamma_outer. --- .../take2_ss56_redz.ipynb | 114 +++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb index 4ddcce24..0aff0786 100644 --- a/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb +++ b/ecg-notebooks/parameter_investigation/take2_ss56_redz.ipynb @@ -17,7 +17,7 @@ "\n", "\n", "from holodeck import plot, detstats\n", - "from holodeck.constants import YR, MSOL, MPC\n", + "from holodeck.constants import YR, MSOL, MPC, PC, GYR\n", "import holodeck as holo" ] }, @@ -1143,9 +1143,119 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, - "source": [] + "source": [ + "## Hardening" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### dadt vs gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sepa_init=1.0e3*PC\n", + "rchar=10.0*PC\n", + "gamma_inner=-1.0\n", + "gamma_outer=+1.5\n", + "num_steps=300\n", + "norm = 3e5\n", + "\n", + "sam = holo.sam.Semi_Analytic_Model(shape=(20,25,30))\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "_norm = hard._norm\n", + "print(_norm.shape, holo.utils.stats(_norm)) # for each M and q\n", + "# norm = _norm[15,20]\n", + "# print(norm)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sepa_init/PC)\n", + "print('%e' % (holo.utils.kepler_sepa_from_freq(1e11, fobs[-1])/PC))\n", + "print('%e' % (holo.utils.kepler_sepa_from_freq(1e11, fobs[0])/PC))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def dadt(norm=norm, sepa=sepa_init, rchar=rchar, \n", + " gamma_inner=gamma_inner, gamma_outer=gamma_outer):\n", + " xx = sepa/rchar\n", + " dadt = -norm * xx**(1-gamma_inner) * (1+xx)**(gamma_inner - gamma_outer)\n", + " return dadt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "aa_arr = np.geomspace(sepa_init, 1e-14*PC, 1000)\n", + "num = 5\n", + "gam_in_arr = np.linspace(-1.5, 0, num)\n", + "print(gam_in_arr)\n", + "\n", + "dadt_arr = np.zeros_like(aa_arr)\n", + "\n", + "fig, ax = plot.figax(\n", + " xlabel= r'$a$ [pc]',\n", + " ylabel = r'$da/dt$', yscale='linear')\n", + "colors = cm.rainbow(np.linspace(0,1,num))\n", + "\n", + "for ii, gam_in in enumerate(gam_in_arr):\n", + " for aa, sepa in enumerate(aa_arr):\n", + " dadt_arr[aa] = dadt(sepa=sepa, gamma_inner=gam_in)\n", + " ax.plot(aa_arr/PC, dadt_arr, label=r'$\\gamma_\\mathrm{inner}=$'+'%.2e' % gam_in, color=colors[ii])\n", + "ax.legend()\n", + "ax.set_xlim(np.max(aa_arr/PC), np.min(aa_arr/PC))\n", + "print(holo.utils.stats(dadt_arr))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "aa_arr = np.geomspace(sepa_init, 1e-14*PC, 1000)\n", + "num = 5\n", + "gam_out_arr = np.linspace(0, 2.5, num)\n", + "print(gam_in_arr)\n", + "\n", + "dadt_arr = np.zeros_like(aa_arr)\n", + "\n", + "fig, ax = plot.figax(\n", + " xlabel= r'$a$ [pc]',\n", + " ylabel = r'$da/dt$', yscale='linear')\n", + "colors = cm.rainbow(np.linspace(0,1,num))\n", + "\n", + "for ii, gam_out in enumerate(gam_out_arr):\n", + " for aa, sepa in enumerate(aa_arr):\n", + " dadt_arr[aa] = dadt(sepa=sepa, gamma_outer=gam_out)\n", + " ax.plot(aa_arr/PC, dadt_arr, label=r'$\\gamma_\\mathrm{outer}=$'+'%.2e' % gam_out, color=colors[ii])\n", + "ax.legend()\n", + "ax.set_xlim(np.max(aa_arr/PC), np.min(aa_arr/PC))\n", + "print(holo.utils.stats(dadt_arr))" + ] }, { "cell_type": "markdown", From b355a490a38036783281fb6298e2a015984cd341 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 13 Jun 2023 10:23:50 -0700 Subject: [PATCH 047/291] Updated med shape code to nearly match full shape code --- .../take3_gwb_anatomy_medshape.ipynb | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb index 7190dc54..f36ec50e 100644 --- a/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb +++ b/ecg-notebooks/parameter_investigation/take3_gwb_anatomy_medshape.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "SHAPE = (30,25,35)\n", + "SHAPE = (20,15,25)\n", "NREALS = 30\n", "NFREQS = 40\n", "NLOUDEST = 10\n", @@ -435,7 +435,7 @@ "outputs": [], "source": [ "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", - " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " dsdata = detect_pspace_model(data)\n", " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", " fig=plot_everything_vs_freqs(\n", " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", @@ -641,7 +641,18 @@ "def vary_parameter(\n", " target_param, # the name of the parameter, has to exist in `param_names`\n", " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " pars=None \n", " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " # Choose parameter to vary\n", " param_idx = param_names.index(target_param)\n", "\n", " data = []\n", @@ -653,7 +664,6 @@ " _params = pspace.normalized_params(pars)\n", " params.append(_params)\n", " # construct `sam` and `hard` instances based on these parameters\n", - " # sam, hard = pspace.model_for_normalized_params(pars)\n", " sam, hard = pspace.model_for_params(_params)\n", " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", " hard_name = 'Fixed Time'\n", @@ -680,16 +690,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# data, params = data_hard_time, params_hard_time\n", + "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", "fig = draw_three_models(*rv_hard_time)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_time)" ] From fef7d7382ad2fe2553b9ca25a754a377fd45a0eb Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 13 Jun 2023 11:16:16 -0700 Subject: [PATCH 048/291] Small markdown improvements. --- ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb b/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb index 39a63bd6..38e74144 100644 --- a/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb +++ b/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb @@ -235,10 +235,11 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "# Shape 5, 6, 7" + "# Shape 20, 20, 20" ] }, { @@ -370,6 +371,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "## Print info\n", "Note that hs_fin cy and py do not match. There are places where cython gives nonzero but python gives 0." ] }, From 6f6022d0bee8ce2447c16369349031e81c35b105 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 13 Jun 2023 11:58:49 -0700 Subject: [PATCH 049/291] Saving vary_parameter rv data to npz arrays. --- ...take5_gwb_anatomy_fullshape_normpars.ipynb | 80 ++++++++++++++----- 1 file changed, 62 insertions(+), 18 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb index e71e5b05..1cdd1a07 100644 --- a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb +++ b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb @@ -467,7 +467,7 @@ "\n", "\n", "def draw_three_models(\n", - " data, params, hard_name, shape, target_param,\n", + " data, params, hard_name, shape, target_param, filename,\n", " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", " datlw = np.array([3,4,5]),\n", @@ -536,7 +536,7 @@ " return fig\n", "\n", "def draw_three_hs_vs_binpars(data, params,\n", - " hard_name, shape, target_param,\n", + " hard_name, shape, target_param, filename,\n", " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", @@ -570,6 +570,34 @@ "# 4 Vary Parameters!!!!!!!" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + "pars[2]=1.0\n", + "print(pars)\n", + "print(str(pars))\n", + "str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + "str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + "\n", + "print('pars%s' % str_pars)\n", + "\n", + "print(str_shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(pspace.sam_shape)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -580,7 +608,7 @@ " target_param, # the name of the parameter, has to exist in `param_names`\n", " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", - " pars=None \n", + " pars=None, save_dir=None \n", " ):\n", " # get the parameter names from this library-space\n", " param_names = pspace.param_names\n", @@ -589,7 +617,8 @@ "\n", " # choose each parameter to be half-way across the range provided by the library\n", " if pars is None:\n", - " pars = 0.5 * np.ones(num_pars) \n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", " # Choose parameter to vary\n", " param_idx = param_names.index(target_param)\n", "\n", @@ -611,7 +640,13 @@ " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", - " return (data, params, hard_name, sam.shape, target_param)" + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, hard_name, sam.shape, target_param, filename)" ] }, { @@ -648,7 +683,16 @@ "metadata": {}, "outputs": [], "source": [ - "rv_hard_time = vary_parameter('hard_time') # save for later so we don't have to recalculate, if \n", + "save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_rv_fullshape'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_time = vary_parameter('hard_time', save_dir=save_dir) # save for later so we don't have to recalculate, if \n", "fig = draw_three_models(*rv_hard_time)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_time)" ] @@ -667,7 +711,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_gsmf_phi0 = vary_parameter('gsmf_phi0') \n", + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0', save_dir=save_dir) \n", "fig = draw_three_models(*rv_gsmf_phi0)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" ] @@ -689,7 +733,7 @@ "pars = 0.5 * np.ones(num_pars) \n", "pars[0] = 0.0 \n", "\n", - "rv_gsmf_phi0_hard0 = vary_parameter('gsmf_phi0', pars=pars) \n", + "rv_gsmf_phi0_hard0 = vary_parameter('gsmf_phi0', pars=pars, save_dir=save_dir) \n", "fig = draw_three_models(*rv_gsmf_phi0_hard0)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard0)" ] @@ -711,7 +755,7 @@ "pars = 0.5 * np.ones(num_pars) \n", "pars[0] = 1.0 \n", "\n", - "rv_gsmf_phi0_hard1 = vary_parameter('gsmf_phi0', pars=pars) \n", + "rv_gsmf_phi0_hard1 = vary_parameter('gsmf_phi0', pars=pars, save_dir=save_dir) \n", "fig = draw_three_models(*rv_gsmf_phi0_hard1)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard1)" ] @@ -730,7 +774,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10') \n", + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', save_dir=save_dir) \n", "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" ] @@ -750,7 +794,7 @@ "outputs": [], "source": [ "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', \n", - " pars=[0,0.5,0.5,0.5,0.5,0.5]) \n", + " pars=[0,0.5,0.5,0.5,0.5,0.5], save_dir=save_dir) \n", "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" ] @@ -770,7 +814,7 @@ "outputs": [], "source": [ "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', \n", - " pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", + " pars=[1.0,0.5,0.5,0.5,0.5,0.5], save_dir=save_dir) \n", "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" ] @@ -789,7 +833,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10') \n", + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10', save_dir=save_dir) \n", "fig = draw_three_models(*rv_mmb_mamp_log10)\n", "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" ] @@ -809,7 +853,7 @@ "outputs": [], "source": [ "rv_mmb_mamp_log10_hard1 = vary_parameter('mmb_mamp_log10',\n", - " pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", + " pars=[1.0,0.5,0.5,0.5,0.5,0.5], save_dir=save_dir) \n", "fig = draw_three_models(*rv_mmb_mamp_log10_hard1)\n", "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1)" ] @@ -828,7 +872,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex') \n", + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex', save_dir=save_dir) \n", "fig = draw_three_models(*rv_mmb_scatter_dex)\n", "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" ] @@ -847,7 +891,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_mmb_scatter_dex_hard1 = vary_parameter('mmb_scatter_dex',\n", + "rv_mmb_scatter_dex_hard1 = vary_parameter('mmb_scatter_dex', save_dir=save_dir,\n", " pars=[1.0, 0.5, 0.5, 0.5, 0.5, 0.5]) \n", "fig = draw_three_models(*rv_mmb_scatter_dex_hard1)\n", "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1)" @@ -867,7 +911,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner') \n", + "rv_hard_gamma_inner = vary_parameter('hard_gamma_inner', save_dir=save_dir) \n", "fig = draw_three_models(*rv_hard_gamma_inner)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" ] @@ -886,7 +930,7 @@ "metadata": {}, "outputs": [], "source": [ - "rv_hard_gamma_inner_hard1 = vary_parameter('hard_gamma_inner',\n", + "rv_hard_gamma_inner_hard1 = vary_parameter('hard_gamma_inner', save_dir=save_dir,\n", " pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", "fig = draw_three_models(*rv_hard_gamma_inner_hard1)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" From 556e53f93faf0304710cfad4c5d77b36b8d61ae6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 13 Jun 2023 16:46:52 -0700 Subject: [PATCH 050/291] Compared gamma_inner effects for hard time 0. --- .../take5_gwb_anatomy_fullshape_normpars.ipynb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb index 1cdd1a07..5132ed16 100644 --- a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb +++ b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb @@ -936,6 +936,18 @@ "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_hard_gamma_inner_hard0 = vary_parameter('hard_gamma_inner', save_dir=save_dir,\n", + " pars=[0.0,0.5,0.5,0.5,0.5,0.5]) \n", + "fig = draw_three_models(*rv_hard_gamma_inner_hard0)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0)" + ] + }, { "cell_type": "code", "execution_count": null, From 5dee7cbf106bcd62c2d9cca929ee301851045b0f Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 13 Jun 2023 16:47:21 -0700 Subject: [PATCH 051/291] Plotted bg and ss medians to more clearly identify convergence/trends. --- .../take6_clearplots.ipynb | 340 ++++++++++++++++++ 1 file changed, 340 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/take6_clearplots.ipynb diff --git a/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb b/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb new file mode 100644 index 00000000..ca41fcdd --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb @@ -0,0 +1,340 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setup" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load vary param rv's" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz_hard_time = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "print(npz_hard_time.files)\n", + "\n", + "data = npz_hard_time['data']\n", + "params = npz_hard_time['params']\n", + "hard_name = npz_hard_time['hard_name']\n", + "shape = npz_hard_time['shape']\n", + "target_param = npz_hard_time['target_param']\n", + "\n", + "# npz_hard_time.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get pspace info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=shape, seed=None)\n", + "param_names = pspace.param_names\n", + "print(param_names)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "math_param_names = np.array([r'$t_\\mathrm{hard}$', r'$\\Phi_0$', r'$M_\\mathrm{char,0}$',\n", + " r'$\\log \\mu$', r'$\\epsilon_\\mu$', r'$\\gamma_\\mathrm{inner}'])\n", + "short_param_names = np.array(['t_hard', 'Phi0', 'Mchar0$',\n", + " 'Mamp', 'scatter', 'gam_in'])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# General Plotting Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+short_param_names[pp]+'=%.2e, ' % (params[name])\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75,\n", + " parse_math=True)\n", + "\n", + "# def draw_bg_par_vs_freq(ax, xx, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, \n", + "# color_ss='r', color_bg='k', colors=None,\n", + "# show_ss_medians=True, \n", + "# fast, show_reals):\n", + "# if show_ss_medians:\n", + "# ax.\n", + "\n", + " # if show_reals:\n", + " # if fast:\n", + " # ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " # ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " # else:\n", + " # for rr in range(nreals):\n", + " # for ll in range(nloudest):\n", + " # edgecolor='k' if ll==0 else None\n", + " # ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " # ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot mass and char strain" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_mass_hc_vs_freq(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '-', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,] # mass only\n", + " shape = hc_ss.shape\n", + " nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 1,F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(2, nfreqs, nreals, nloudest) # shape 2,F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 1,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(2, nfreqs, nreals) # shape 2,F,R\n", + "\n", + " for ii, ax in enumerate(axs[:,0]): # first column, bg only\n", + " ax.plot(xx, np.median(yy_bg[ii], axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", + " for pp in [50, 98]:\n", + " conf = np.percentile(yy_bg[ii], [50-pp/2, 50+pp/2], axis=-1)\n", + " ax.fill_between(xx, *conf, color=color_bg, alpha=0.1)\n", + " \n", + " for ii, ax in enumerate(axs[:,1]): # second columns, bg median and ss\n", + " ax.plot(xx, np.median(yy_bg[ii], axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", + " # all loudest, small and very transparent\n", + " ax.scatter(xx_ss.flatten(), yy_ss[ii].flatten(), color=color_ss, alpha=0.1, s=1)\n", + " # # single loudest of any realization\n", + " # ax.scatter(xx_ss[...,0].flatten(), yy_ss[ii,:,:,0].flatten(), color=color_ss, edgecolor='k', alpha=0.1, s=2)\n", + " # median loudest of all realizations, with errorbars\n", + " ax.errorbar(xx, np.median(yy_ss[ii,:,:,0], axis=-1), yerr=np.std(yy_ss[ii,:,:,0], axis=-1),\n", + " color=color_ss, alpha=0.25, markersize=15)\n", + " ax.sharey(axs[ii,0])\n", + "\n", + "\n", + " # # plot all pars and hs\n", + " # for ii,ax in enumerate(axs.flatten()):\n", + " # draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " # color_ss, color_bg, colors,\n", + " # fast, show_reals, nreals, nloudest)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def plot_mass_hc_vs_freq(\n", + " data, params, hard_name, shape, target_param, \n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=2, sharex=True, figsize=(10,6))\n", + "\n", + " idx = [0,]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN]))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs[:,0]):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " fig = draw_mass_hc_vs_freq(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " dat['sspar'], dat['bgpar'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = npz_hard_time\n", + "fig = plot_mass_hc_vs_freq(npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'],)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_phi0_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "fig = plot_mass_hc_vs_freq(npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'],)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_mchar0_log10_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "fig = plot_mass_hc_vs_freq(npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'],)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/mmb_mamp_log10_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "fig = plot_mass_hc_vs_freq(npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'],)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/mmb_scatter_dex_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "fig = plot_mass_hc_vs_freq(npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'],)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_gamma_inner_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "fig = plot_mass_hc_vs_freq(npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'],)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From e3afbabd47130644b84f090ce9a9a2c60e2ed0b4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 13 Jun 2023 17:13:28 -0700 Subject: [PATCH 052/291] Tried hc^2 for anisotropy map and calculations, made little difference. --- .../anisotropy/healpix/varying_nside.ipynb | 193 +++++++++++++++++- 1 file changed, 186 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb index c33c5e5d..c5428f40 100644 --- a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb +++ b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb @@ -42,6 +42,14 @@ "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hc Maps\n" + ] + }, { "cell_type": "code", "execution_count": null, @@ -143,14 +151,14 @@ "for ff in range(0,5):\n", " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", " plt.axes(axs[0])\n", - " hp.mollview(moll_tt08[ff,rr], title='f=%.2f yr$^{-1}$, nside=%d'\n", - " % (fobs[ff]*YR, 8), hold=True )\n", + " hp.mollview(moll_tt08[ff,rr], unit='$h_c$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", " plt.axes(axs[1])\n", - " hp.mollview(moll_tt16[ff,rr], title='f=%.2f yr$^{-1}$, nside=%d'\n", - " % (fobs[ff]*YR, 16), hold=True )\n", + " hp.mollview(moll_tt16[ff,rr], unit='$h_c$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", " plt.axes(axs[2])\n", - " hp.mollview(moll_tt32[ff,rr], title='f=%.2f yr$^{-1}$, nside=%d'\n", - " % (fobs[ff]*YR, 32), hold=True )\n", + " hp.mollview(moll_tt32[ff,rr],unit='$h_c$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", " fig.tight_layout()\n" ] }, @@ -192,7 +200,7 @@ "\n", "for ff in np.array([1,5,10]):\n", " yy = Cl_arrs\n", - " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$')\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", " for ii, nside in enumerate(nsides):\n", " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", " ax.legend()\n", @@ -248,6 +256,177 @@ " fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hc^2 maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hc2_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]**2/(npix)) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "nsides=np.array([8,16,32, 64, 128])\n", + "moll2_bg08 = make_hc2_bg_map(hc_bg, nside=8)\n", + "moll2_bg16 = make_hc2_bg_map(hc_bg, nside=16)\n", + "moll2_bg32 = make_hc2_bg_map(hc_bg, nside=32)\n", + "moll2_bg64 = make_hc2_bg_map(hc_bg, nside=64)\n", + "moll2_bg128 = make_bg_map(hc_bg, nside=128)\n", + "print(moll2_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hc2_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = moll_ss[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2\n", + " return moll_ss, pix_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll2_ss08, temp = make_hc2_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "moll2_ss16, temp = make_hc2_ss_map(hc_ss, 16, pix_ss16)\n", + "moll2_ss32, temp = make_hc2_ss_map(hc_ss, 32, pix_ss32)\n", + "moll2_ss64, temp = make_hc2_ss_map(hc_ss, 64, pix_ss64)\n", + "moll2_ss128, temp = make_hc2_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll2_tt08 = (moll2_ss08 + moll2_bg08)\n", + "moll2_tt16 = (moll2_ss16 + moll2_bg16)\n", + "moll2_tt32 = (moll2_ss32 + moll2_bg32)\n", + "moll2_tt64 = (moll2_ss64 + moll2_bg64)\n", + "moll2_tt128 = (moll2_ss128 + moll2_bg128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "rr=0\n", + "for ff in range(0,5):\n", + " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + " plt.axes(axs[0])\n", + " hp.mollview(moll2_tt08[ff,rr], unit='$h_c^2$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + " plt.axes(axs[1])\n", + " hp.mollview(moll2_tt16[ff,rr], unit='$h_c^2$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + " plt.axes(axs[2])\n", + " hp.mollview(moll2_tt32[ff,rr], unit='$h_c^2$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + " fig.tight_layout()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lmax=6\n", + "Cl2_08 = anis.sph_harm_from_map(moll2_tt08, lmax=6)\n", + "Cl2_16 = anis.sph_harm_from_map(moll2_tt16, lmax=6)\n", + "Cl2_32 = anis.sph_harm_from_map(moll2_tt32, lmax=6)\n", + "Cl2_64 = anis.sph_harm_from_map(moll2_tt64, lmax=6)\n", + "Cl2_128 = anis.sph_harm_from_map(moll2_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Cl2_arrs = np.array([Cl_08, Cl_16, Cl_32, Cl_64, Cl_128])\n", + "print(Cl2_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl2_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl2_arrs[...,ll]/Cl2_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $h_c^2$' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, { "cell_type": "code", "execution_count": null, From f22a38682c23ec855008d45922d9b5032d9296ac Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 07:30:01 -0700 Subject: [PATCH 053/291] Modified text size in the anisotropy paper plot. --- .../anisotropy/anisotropy_paper_plots.ipynb | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb index 8b3d6972..c0952397 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb +++ b/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb @@ -278,8 +278,9 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", - " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan,\n", + " figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$'):\n", + " fig, ax = plot.figax(figsize=figsize, xlabel=xlabel, ylabel=ylabel,)\n", "\n", " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", @@ -304,10 +305,11 @@ " # Add Nihan's data\n", " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", " label = '$l=%d$' % (ll+1), \n", - " color=colors[ll], marker='o', ms=8)\n", + " color=colors[ll], marker='o', ms=5)\n", " \n", " plot._twin_yr(ax, nano=False)\n", - " \n", + " ax.set_xlabel(xlabel, fontsize=11)\n", + " ax.set_ylabel(ylabel, fontsize=11)\n", " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", " # % (nbest, lmax))\n", " return fig\n", @@ -338,7 +340,8 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", "# Sato-Polito & Kamionkowski\n", @@ -346,13 +349,15 @@ "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", "\n", "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", - "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", "\n", "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", - "ax.legend(loc='lower right', ncols=3)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", "\n", "fig.tight_layout()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_bigfont.png', dpi=400)" ] }, { From 27e05db704db0c5c45d355cd6e1b0d115aa20075 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 14:41:30 -0700 Subject: [PATCH 054/291] Comparing nside anisotropy calculations using hc^2 and hc^2/dOmega. hc/dOmega looks weird. --- .../anisotropy/healpix/varying_nside.ipynb | 952 ++++++++++++++++-- 1 file changed, 863 insertions(+), 89 deletions(-) diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb index c5428f40..8035e12b 100644 --- a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb +++ b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb @@ -47,7 +47,41 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# hc Maps\n" + "# 1 hc\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "pix_ss08 = hcfile['pix_ss08']\n", + "pix_ss16 = hcfile['pix_ss16']\n", + "pix_ss32 = hcfile['pix_ss32']\n", + "pix_ss64 = hcfile['pix_ss64']\n", + "# pix_ss128 = hcfile['pix_ss128']\n", + "Cl_arrs = hcfile['Cl_arrs']\n", + "nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "lmax=6" ] }, { @@ -64,13 +98,21 @@ " * hc_bg[:,:,np.newaxis]/np.sqrt(npix)) # (frequency, realization, pixel)\n", " return moll_bg\n", "\n", - "nsides=np.array([8,16,32, 64, 128])\n", - "moll_bg08 = make_bg_map(hc_bg, nside=8)\n", - "moll_bg16 = make_bg_map(hc_bg, nside=16)\n", - "moll_bg32 = make_bg_map(hc_bg, nside=32)\n", - "moll_bg64 = make_bg_map(hc_bg, nside=64)\n", - "moll_bg128 = make_bg_map(hc_bg, nside=128)\n", - "print(moll_bg08.shape)\n" + "# nsides=np.array([8, 16, 32, 64]) #, 128])\n", + "# moll_bg08 = make_bg_map(hc_bg, nside=8)\n", + "# moll_bg16 = make_bg_map(hc_bg, nside=16)\n", + "# moll_bg32 = make_bg_map(hc_bg, nside=32)\n", + "# moll_bg64 = make_bg_map(hc_bg, nside=64)\n", + "# # moll_bg128 = make_bg_map(hc_bg, nside=128)\n", + "# print(moll_bg08.shape)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Place single sources at random pixels" ] }, { @@ -92,9 +134,9 @@ " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2\n", " + hc_ss[ff,rr,ll]**2)\n", " return moll_ss, pix_ss\n", - "moll_ss08, pix_ss08 = make_ss_map(hc_ss, 8)\n", - "print(f\"{moll_ss08.shape=}\")\n", - "print(f\"{pix_ss08.shape=}\")" + "# moll_ss08, pix_ss08 = make_ss_map(hc_ss, 8)\n", + "# print(f\"{moll_ss08.shape=}\")\n", + "# print(f\"{pix_ss08.shape=}\")" ] }, { @@ -109,10 +151,18 @@ " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", " return pix_ss2\n", "\n", - "pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", - "pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", - "pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "# pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "# # pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.1 Maps" ] }, { @@ -121,10 +171,10 @@ "metadata": {}, "outputs": [], "source": [ - "moll_ss16, temp = make_ss_map(hc_ss, 16, pix_ss16)\n", - "moll_ss32, temp = make_ss_map(hc_ss, 32, pix_ss32)\n", - "moll_ss64, temp = make_ss_map(hc_ss, 64, pix_ss64)\n", - "moll_ss128, temp = make_ss_map(hc_ss, 128, pix_ss128)" + "# moll_ss16, temp = make_ss_map(hc_ss, 16, pix_ss16)\n", + "# moll_ss32, temp = make_ss_map(hc_ss, 32, pix_ss32)\n", + "# moll_ss64, temp = make_ss_map(hc_ss, 64, pix_ss64)\n", + "# # moll_ss128, temp = make_ss_map(hc_ss, 128, pix_ss128)" ] }, { @@ -133,11 +183,11 @@ "metadata": {}, "outputs": [], "source": [ - "moll_tt08 = np.sqrt(moll_ss08**2 + moll_bg08**2)\n", - "moll_tt16 = np.sqrt(moll_ss16**2 + moll_bg16**2)\n", - "moll_tt32 = np.sqrt(moll_ss32**2 + moll_bg32**2)\n", - "moll_tt64 = np.sqrt(moll_ss64**2 + moll_bg64**2)\n", - "moll_tt128 = np.sqrt(moll_ss128**2 + moll_bg128**2)" + "# moll_tt08 = np.sqrt(moll_ss08**2 + moll_bg08**2)\n", + "# moll_tt16 = np.sqrt(moll_ss16**2 + moll_bg16**2)\n", + "# moll_tt32 = np.sqrt(moll_ss32**2 + moll_bg32**2)\n", + "# moll_tt64 = np.sqrt(moll_ss64**2 + moll_bg64**2)\n", + "# # moll_tt128 = np.sqrt(moll_ss128**2 + moll_bg128**2)" ] }, { @@ -147,19 +197,27 @@ "outputs": [], "source": [ "\n", - "rr=0\n", - "for ff in range(0,5):\n", - " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", - " plt.axes(axs[0])\n", - " hp.mollview(moll_tt08[ff,rr], unit='$h_c$',\n", - " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", - " plt.axes(axs[1])\n", - " hp.mollview(moll_tt16[ff,rr], unit='$h_c$',\n", - " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", - " plt.axes(axs[2])\n", - " hp.mollview(moll_tt32[ff,rr],unit='$h_c$',\n", - " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", - " fig.tight_layout()\n" + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(moll_tt08[ff,rr], unit='$h_c$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(moll_tt16[ff,rr], unit='$h_c$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(moll_tt32[ff,rr],unit='$h_c$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.2 sph harm" ] }, { @@ -168,12 +226,12 @@ "metadata": {}, "outputs": [], "source": [ - "lmax=6\n", - "Cl_08 = anis.sph_harm_from_map(moll_tt08, lmax=6)\n", - "Cl_16 = anis.sph_harm_from_map(moll_tt16, lmax=6)\n", - "Cl_32 = anis.sph_harm_from_map(moll_tt32, lmax=6)\n", - "Cl_64 = anis.sph_harm_from_map(moll_tt64, lmax=6)\n", - "Cl_128 = anis.sph_harm_from_map(moll_tt128, lmax=6)" + "# lmax=6\n", + "# Cl_08 = anis.sph_harm_from_map(moll_tt08, lmax=6)\n", + "# Cl_16 = anis.sph_harm_from_map(moll_tt16, lmax=6)\n", + "# Cl_32 = anis.sph_harm_from_map(moll_tt32, lmax=6)\n", + "# Cl_64 = anis.sph_harm_from_map(moll_tt64, lmax=6)\n", + "# # Cl_128 = anis.sph_harm_from_map(moll_tt128, lmax=6)" ] }, { @@ -182,10 +240,19 @@ "metadata": {}, "outputs": [], "source": [ - "Cl_arrs = np.array([Cl_08, Cl_16, Cl_32, Cl_64, Cl_128])\n", + "# Cl_arrs = np.array([Cl_08, Cl_16, Cl_32, Cl_64]) #, Cl_128])\n", "print(Cl_arrs.shape)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(fobs*YR)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -204,7 +271,7 @@ " for ii, nside in enumerate(nsides):\n", " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", " ax.legend()\n", - " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c$' % (nn, rr, fobs[ff]*YR,))\n", " fig.tight_layout()" ] }, @@ -226,7 +293,7 @@ " for ii, nside in enumerate(nsides):\n", " ax.plot(xx, yy[ii,:,rr], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", " ax.legend()\n", - " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " ax.set_title('Sample %d, Realization %d, $h_c$' % (nn, rr))\n", " fig.tight_layout()" ] }, @@ -252,7 +319,7 @@ " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", "\n", " ax.legend()\n", - " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " ax.set_title('Sample %d, $h_c$' % (nn))\n", " fig.tight_layout()" ] }, @@ -261,7 +328,73 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# hc^2 maps" + "## 1.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, #moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64,# moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, #moll_tt128=moll_tt128,\n", + "# Cl_arrs=Cl_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 hc^2 \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc2_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "Cl2_arrs = hcfile['Cl2_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.1 Maps" ] }, { @@ -278,13 +411,13 @@ " * hc_bg[:,:,np.newaxis]**2/(npix)) # (frequency, realization, pixel)\n", " return moll_bg\n", "\n", - "nsides=np.array([8,16,32, 64, 128])\n", - "moll2_bg08 = make_hc2_bg_map(hc_bg, nside=8)\n", - "moll2_bg16 = make_hc2_bg_map(hc_bg, nside=16)\n", - "moll2_bg32 = make_hc2_bg_map(hc_bg, nside=32)\n", - "moll2_bg64 = make_hc2_bg_map(hc_bg, nside=64)\n", - "moll2_bg128 = make_bg_map(hc_bg, nside=128)\n", - "print(moll2_bg08.shape)\n" + "# nsides=np.array([8,16,32, 64, 128])\n", + "# moll2_bg08 = make_hc2_bg_map(hc_bg, nside=8)\n", + "# moll2_bg16 = make_hc2_bg_map(hc_bg, nside=16)\n", + "# moll2_bg32 = make_hc2_bg_map(hc_bg, nside=32)\n", + "# moll2_bg64 = make_hc2_bg_map(hc_bg, nside=64)\n", + "# # moll2_bg128 = make_hc2_bg_map(hc_bg, nside=128)\n", + "# print(moll2_bg08.shape)\n" ] }, { @@ -313,11 +446,17 @@ "metadata": {}, "outputs": [], "source": [ - "moll2_ss08, temp = make_hc2_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", - "moll2_ss16, temp = make_hc2_ss_map(hc_ss, 16, pix_ss16)\n", - "moll2_ss32, temp = make_hc2_ss_map(hc_ss, 32, pix_ss32)\n", - "moll2_ss64, temp = make_hc2_ss_map(hc_ss, 64, pix_ss64)\n", - "moll2_ss128, temp = make_hc2_ss_map(hc_ss, 128, pix_ss128)" + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "\n", + "# moll2_ss08, temp = make_hc2_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# moll2_ss16, temp = make_hc2_ss_map(hc_ss, 16, pix_ss16)\n", + "# moll2_ss32, temp = make_hc2_ss_map(hc_ss, 32, pix_ss32)\n", + "# moll2_ss64, temp = make_hc2_ss_map(hc_ss, 64, pix_ss64)\n", + "# # moll2_ss128, temp = make_hc2_ss_map(hc_ss, 128, pix_ss128)" ] }, { @@ -326,11 +465,11 @@ "metadata": {}, "outputs": [], "source": [ - "moll2_tt08 = (moll2_ss08 + moll2_bg08)\n", - "moll2_tt16 = (moll2_ss16 + moll2_bg16)\n", - "moll2_tt32 = (moll2_ss32 + moll2_bg32)\n", - "moll2_tt64 = (moll2_ss64 + moll2_bg64)\n", - "moll2_tt128 = (moll2_ss128 + moll2_bg128)" + "# moll2_tt08 = (moll2_ss08 + moll2_bg08)\n", + "# moll2_tt16 = (moll2_ss16 + moll2_bg16)\n", + "# moll2_tt32 = (moll2_ss32 + moll2_bg32)\n", + "# moll2_tt64 = (moll2_ss64 + moll2_bg64)\n", + "# # moll2_tt128 = (moll2_ss128 + moll2_bg128)" ] }, { @@ -340,19 +479,27 @@ "outputs": [], "source": [ "\n", - "rr=0\n", - "for ff in range(0,5):\n", - " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", - " plt.axes(axs[0])\n", - " hp.mollview(moll2_tt08[ff,rr], unit='$h_c^2$',\n", - " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", - " plt.axes(axs[1])\n", - " hp.mollview(moll2_tt16[ff,rr], unit='$h_c^2$',\n", - " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", - " plt.axes(axs[2])\n", - " hp.mollview(moll2_tt32[ff,rr], unit='$h_c^2$',\n", - " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", - " fig.tight_layout()\n" + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(moll2_tt08[ff,rr], unit='$h_c^2$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(moll2_tt16[ff,rr], unit='$h_c^2$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(moll2_tt32[ff,rr], unit='$h_c^2$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 sph harm" ] }, { @@ -361,12 +508,12 @@ "metadata": {}, "outputs": [], "source": [ - "lmax=6\n", - "Cl2_08 = anis.sph_harm_from_map(moll2_tt08, lmax=6)\n", - "Cl2_16 = anis.sph_harm_from_map(moll2_tt16, lmax=6)\n", - "Cl2_32 = anis.sph_harm_from_map(moll2_tt32, lmax=6)\n", - "Cl2_64 = anis.sph_harm_from_map(moll2_tt64, lmax=6)\n", - "Cl2_128 = anis.sph_harm_from_map(moll2_tt128, lmax=6)" + "# lmax=6\n", + "# Cl2_08 = anis.sph_harm_from_map(moll2_tt08, lmax=6)\n", + "# Cl2_16 = anis.sph_harm_from_map(moll2_tt16, lmax=6)\n", + "# Cl2_32 = anis.sph_harm_from_map(moll2_tt32, lmax=6)\n", + "# Cl2_64 = anis.sph_harm_from_map(moll2_tt64, lmax=6)\n", + "# # Cl2_128 = anis.sph_harm_from_map(moll2_tt128, lmax=6)" ] }, { @@ -375,7 +522,7 @@ "metadata": {}, "outputs": [], "source": [ - "Cl2_arrs = np.array([Cl_08, Cl_16, Cl_32, Cl_64, Cl_128])\n", + "# Cl2_arrs = np.array([Cl2_08, Cl2_16, Cl2_32, Cl2_64]) #, Cl2_128])\n", "print(Cl2_arrs.shape)" ] }, @@ -389,7 +536,7 @@ "ll=1\n", "\n", "xx = np.arange(lmax+1)\n", - "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2_arrs)))\n", "\n", "for ff in np.array([1,5,10]):\n", " yy = Cl2_arrs\n", @@ -397,7 +544,7 @@ " for ii, nside in enumerate(nsides):\n", " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", " ax.legend()\n", - " ax.set_title('Sample %d, Realization %d' % (nn, rr))\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2$' % (nn, rr, fobs[ff]*YR))\n", " fig.tight_layout()" ] }, @@ -410,7 +557,7 @@ "ll=1\n", "\n", "xx = fobs*YR\n", - "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2_arrs)))\n", "\n", "for ll in range(1,7):\n", " yy = Cl2_arrs[...,ll]/Cl2_arrs[...,0]\n", @@ -423,16 +570,643 @@ " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", "\n", " ax.legend()\n", - " ax.set_title('Sample %d, Realization %d, $h_c^2$' % (nn, rr))\n", + " ax.set_title('Sample %d, $h_c^2$' % (nn,))\n", " fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc2_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll2_ss08=moll2_ss08, moll2_ss16=moll2_ss16, moll2_ss32=moll2_ss32, moll2_ss64=moll2_ss64, #moll_ss128=moll_ss128,\n", + "# moll2_bg08=moll2_bg08, moll2_bg16=moll2_bg16, moll2_bg32=moll2_bg32, moll2_bg64=moll2_bg64,# moll_bg128=moll_bg128,\n", + "# moll2_tt08=moll2_tt08, moll2_tt16=moll2_tt16, moll2_tt32=moll2_tt32, moll2_tt64=moll2_tt64, #moll_tt128=moll_tt128,\n", + "# Cl2_arrs=Cl2_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 hc^2/dOmega \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc2dOm_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "Cl2dOm_arrs = hcfile['Cl2dOm_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.1 Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hc2dOm_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]**2/npix/area) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "# nsides=np.array([8,16,32, 64, 128])\n", + "# moll2dOm_bg08 = make_hc2dOm_bg_map(hc_bg, nside=8)\n", + "# moll2dOm_bg16 = make_hc2dOm_bg_map(hc_bg, nside=16)\n", + "# moll2dOm_bg32 = make_hc2dOm_bg_map(hc_bg, nside=32)\n", + "# moll2dOm_bg64 = make_hc2dOm_bg_map(hc_bg, nside=64)\n", + "# # moll2dOm_bg128 = make_hc2dOm_bg_map(hc_bg, nside=128)\n", + "# print(moll2dOm_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hc2dOm_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = (moll_ss[ff,rr,pix_ss[ff,rr,ll]] \n", + " + hc_ss[ff,rr,ll]**2 /area)\n", + " return moll_ss, pix_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll2dOm_ss08, temp = make_hc2dOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# moll2dOm_ss16, temp = make_hc2dOm_ss_map(hc_ss, 16, pix_ss16)\n", + "# moll2dOm_ss32, temp = make_hc2dOm_ss_map(hc_ss, 32, pix_ss32)\n", + "# moll2dOm_ss64, temp = make_hc2dOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# # moll2dOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll2dOm_tt08 = (moll2dOm_ss08 + moll2dOm_bg08)\n", + "# moll2dOm_tt16 = (moll2dOm_ss16 + moll2dOm_bg16)\n", + "# moll2dOm_tt32 = (moll2dOm_ss32 + moll2dOm_bg32)\n", + "# moll2dOm_tt64 = (moll2dOm_ss64 + moll2dOm_bg64)\n", + "# # moll2dOm_tt128 = (moll2dOm_ss128 + moll2dOm_bg128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(moll2dOm_tt08[ff,rr], unit='$h_c^2/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(moll2dOm_tt16[ff,rr], unit='$h_c^2/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(moll2dOm_tt32[ff,rr], unit='$h_c^2/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# lmax=6\n", + "# Cl2dOm_08 = anis.sph_harm_from_map(moll2dOm_tt08, lmax=6)\n", + "# Cl2dOm_16 = anis.sph_harm_from_map(moll2dOm_tt16, lmax=6)\n", + "# Cl2dOm_32 = anis.sph_harm_from_map(moll2dOm_tt32, lmax=6)\n", + "# Cl2dOm_64 = anis.sph_harm_from_map(moll2dOm_tt64, lmax=6)\n", + "# # Cl2dOm_128 = anis.sph_harm_from_map(moll2dOm_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cl2dOm_arrs = np.array([Cl2dOm_08, Cl2dOm_16, Cl2dOm_32, Cl2dOm_64]) #, Cl2dOm_128])\n", + "print(Cl2dOm_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2dOm_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl2dOm_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2dOm_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl2dOm_arrs[...,ll]/Cl2dOm_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, $h_c^2/d\\Omega$' % (nn))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc2dOm_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll2dOm_ss08=moll2dOm_ss08, moll2dOm_ss16=moll2dOm_ss16, moll2dOm_ss32=moll2dOm_ss32, moll2dOm_ss64=moll2dOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# moll2dOm_bg08=moll2dOm_bg08, moll2dOm_bg16=moll2dOm_bg16, moll2dOm_bg32=moll2dOm_bg32, moll2dOm_bg64=moll2dOm_bg64,# moll_bg128=moll_bg128,\n", + "# moll2dOm_tt08=moll2dOm_tt08, moll2dOm_tt16=moll2dOm_tt16, moll2dOm_tt32=moll2dOm_tt32, moll2dOm_tt64=moll2dOm_tt64, #moll_tt128=moll_tt128,\n", + "# Cl2dOm_arrs=Cl2dOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 hc / dOmega\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hcdOm_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "CldOm_arrs = hcfile['CldOm_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hcdOm_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]/np.sqrt(npix)/area) # (frequency, realization, pixel)\n", + " return moll_bg\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# nsides=np.array([8,16,32, 64]) #, 128])\n", + "# molldOm_bg08 = make_hcdOm_bg_map(hc_bg, nside=8)\n", + "# molldOm_bg16 = make_hcdOm_bg_map(hc_bg, nside=16)\n", + "# molldOm_bg32 = make_hcdOm_bg_map(hc_bg, nside=32)\n", + "# molldOm_bg64 = make_hcdOm_bg_map(hc_bg, nside=64)\n", + "# # molldOm_bg128 = make_hcdOm_bg_map(hc_bg, nside=128)\n", + "# print(molldOm_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hcdOm_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]**2] \n", + " + hc_ss[ff,rr,ll]**2) /area\n", + " return moll_ss, pix_ss\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# molldOm_ss08, temp = make_hc2dOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# molldOm_ss16, temp = make_hc2dOm_ss_map(hc_ss, 16, pix_ss16)\n", + "# molldOm_ss32, temp = make_hc2dOm_ss_map(hc_ss, 32, pix_ss32)\n", + "# molldOm_ss64, temp = make_hc2dOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# # molldOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", + "# molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", + "# molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", + "# molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n", + "# # molldOm_tt128 = np.sqrt(molldOm_ss128**2 + molldOm_bg128**2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(molldOm_tt08[ff,rr], unit='$h_c/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(molldOm_tt16[ff,rr], unit='$h_c/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(molldOm_tt32[ff,rr], unit='$h_c/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# lmax=6\n", + "# CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", + "# CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", + "# CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", + "# CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)\n", + "# # CldOm_128 = anis.sph_harm_from_map(molldOm_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", + "print(CldOm_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(CldOm_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = CldOm_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c/d\\Omega$' % (nn, rr, fobs[ff]*YR))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(CldOm_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = CldOm_arrs[...,ll]/CldOm_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $h_c/d\\Omega$' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hcdOm_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", + "# molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", + "# CldOm_arrs=CldOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Simple Function" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$ a_{\\ell m} = \\int d\\Omega_n \\Delta T (\\vec{n}) Y^*_{\\ell m} (\\vec{n}) $$\n", + "$$ C_{\\ell m} = \\frac{1}{2\\ell + 1} \\sum_{m=-\\ell}^\\ell |a_{\\ell m}|^2 $$\n", + "\n", + "$$ C_0 = (1) \\int d\\Omega \\cdot \\frac{h_c^2}{d\\Omega} \\cdot \\mathrm {constant} $$" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def solid_angle(nside):\n", + " area = hp.nside2pixarea(nside, degrees=False) # \n", + " return area\n", + "\n", + "def C0_integral(moll2_ss, nside, Y00star=1):\n", + " sum=0\n", + " dOm = solid_angle(nside)\n", + " for ii, hc2 in enumerate(moll2_ss):\n", + " sum += Y00star * hc2 * dOm\n", + " return sum\n", + "\n", + "ff = 1\n", + "rr = 0\n", + "dOmega =solid_angle(nside=8)\n", + "print(dOmega)\n", + "C0ss_08 = C0_integral(moll2dOm_ss08[ff,rr], 8)\n", + "C0ss_16 = C0_integral(moll2dOm_ss16[ff,rr], 16)\n", + "C0ss_32 = C0_integral(moll2dOm_ss32[ff,rr], 32)\n", + "C0ss_64 = C0_integral(moll2dOm_ss64[ff,rr], 64)\n", + "C0ss_128 = C0_integral(moll2dOm_ss128[ff,rr], 125)\n", + "\n", + "\n", + "C0tt_08 = C0_integral(moll2dOm_tt08[ff,rr], 8)\n", + "C0tt_16 = C0_integral(moll2dOm_tt16[ff,rr], 16)\n", + "C0tt_32 = C0_integral(moll2dOm_tt32[ff,rr], 32)\n", + "C0tt_64 = C0_integral(moll2dOm_tt64[ff,rr], 64)\n", + "C0tt_128 = C0_integral(moll2dOm_tt128[ff,rr], 125)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(moll_ss08.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsides = np.array([8, 16, 32, 64, 128])\n", + "C0ss = np.array([C0ss_08, C0ss_16, C0ss_32, C0ss_64, C0ss_128])\n", + "C0tt = np.array([C0tt_08, C0tt_16, C0tt_32, C0tt_64, C0tt_128])\n", + "\n", + "fig, ax = plot.figax(xlabel='nside', ylabel=r'$\\int d\\Omega \\frac{h_c^2}{d\\Omega}$')\n", + "ax.plot(nsides, C0ss, marker='o', label='ss only')\n", + "ax.plot(nsides, C0tt, marker='o', label='total map')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "l/ 2 pi r = theta / 2 pi \n", + "l = theta r\n", + "l^2 = theta^2 r^2 = area\n", + "omega = area / r^2 = theta ^2 r^2 / r^2 = theta^2" + ] } ], "metadata": { From 204a5d7418d9971b7ca0465be8ec991868ffea6b Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 15:38:47 -0700 Subject: [PATCH 055/291] Found bug in h/dOmega Cl calculations. --- .../anisotropy/healpix/varying_nside.ipynb | 77 +-- .../healpix/varying_nside_hcdOm.ipynb | 499 ++++++++++++++++++ 2 files changed, 541 insertions(+), 35 deletions(-) create mode 100644 ecg-notebooks/anisotropy/healpix/varying_nside_hcdOm.ipynb diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb index 8035e12b..cb3cd9d8 100644 --- a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb +++ b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb @@ -878,15 +878,22 @@ "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", "hcfile = np.load(save_loc+'/hcdOm_A.npz')\n", "\n", - "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", - "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", - "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", - "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", - "# pix_ss08 = hcfile['pix_ss08']\n", - "# pix_ss16 = hcfile['pix_ss16']\n", - "# pix_ss32 = hcfile['pix_ss32']\n", - "# pix_ss64 = hcfile['pix_ss64']\n", - "# # pix_ss128 = hcfile['pix_ss128']\n", + "pix_ss08=hcfile['pix_ss08']\n", + "pix_ss16=hcfile['pix_ss16']\n", + "pix_ss32=hcfile['pix_ss32']\n", + "pix_ss64=hcfile['pix_ss64']\n", + "# moll_ss08=hcfile['moll_ss08']\n", + "# moll_ss16=hcfile['moll_ss16']\n", + "# moll_ss32=hcfile['moll_ss32']\n", + "# moll_ss64=hcfile['moll_ss64']\n", + "# moll_bg08=hcfile['moll_bg08']\n", + "# moll_bg16=hcfile['moll_bg16']\n", + "# moll_bg32=hcfile['moll_bg32']\n", + "# moll_bg64=hcfile['moll_bg64']\n", + "# moll_tt08=hcfile['moll_tt08']\n", + "# moll_tt16=hcfile['moll_tt16']\n", + "# moll_tt32=hcfile['moll_tt32']\n", + "# moll_tt64=hcfile['moll_tt64']\n", "CldOm_arrs = hcfile['CldOm_arrs']\n", "# nsides=hcfile['nsides']\n", "\n", @@ -953,7 +960,7 @@ " for ff in range(hc_ss.shape[-3]):\n", " for rr in range(hc_ss.shape[-2]):\n", " for ll in range(hc_ss.shape[-1]):\n", - " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]**2] \n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2\n", " + hc_ss[ff,rr,ll]**2) /area\n", " return moll_ss, pix_ss\n" ] @@ -965,11 +972,11 @@ "outputs": [], "source": [ "\n", - "# molldOm_ss08, temp = make_hc2dOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", - "# molldOm_ss16, temp = make_hc2dOm_ss_map(hc_ss, 16, pix_ss16)\n", - "# molldOm_ss32, temp = make_hc2dOm_ss_map(hc_ss, 32, pix_ss32)\n", - "# molldOm_ss64, temp = make_hc2dOm_ss_map(hc_ss, 64, pix_ss64)\n", - "# # molldOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)\n" + "molldOm_ss08, temp = make_hcdOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "molldOm_ss16, temp = make_hcdOm_ss_map(hc_ss, 16, pix_ss16)\n", + "molldOm_ss32, temp = make_hcdOm_ss_map(hc_ss, 32, pix_ss32)\n", + "molldOm_ss64, temp = make_hcdOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# molldOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)\n" ] }, { @@ -978,11 +985,11 @@ "metadata": {}, "outputs": [], "source": [ - "# molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", - "# molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", - "# molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", - "# molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n", - "# # molldOm_tt128 = np.sqrt(molldOm_ss128**2 + molldOm_bg128**2)\n" + "molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", + "molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", + "molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", + "molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n", + "# molldOm_tt128 = np.sqrt(molldOm_ss128**2 + molldOm_bg128**2)\n" ] }, { @@ -1021,12 +1028,12 @@ "metadata": {}, "outputs": [], "source": [ - "# lmax=6\n", - "# CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", - "# CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", - "# CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", - "# CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)\n", - "# # CldOm_128 = anis.sph_harm_from_map(molldOm_tt128, lmax=6)" + "lmax=6\n", + "CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", + "CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", + "CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", + "CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)\n", + "# CldOm_128 = anis.sph_harm_from_map(molldOm_tt128, lmax=6)" ] }, { @@ -1035,7 +1042,7 @@ "metadata": {}, "outputs": [], "source": [ - "# CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", + "CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", "print(CldOm_arrs.shape)" ] }, @@ -1099,14 +1106,14 @@ "metadata": {}, "outputs": [], "source": [ - "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", - "# np.savez(save_loc+'/hcdOm_A.npz', \n", - "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", - "# molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", - "# molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", - "# molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", - "# CldOm_arrs=CldOm_arrs, nsides=nsides)\n", - "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "np.savez(save_loc+'/hcdOm_A.npz', \n", + " pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + " molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + " molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", + " molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", + " CldOm_arrs=CldOm_arrs, nsides=nsides)\n", + " # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" ] }, { diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside_hcdOm.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside_hcdOm.ipynb new file mode 100644 index 00000000..65ed1e17 --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/varying_nside_hcdOm.ipynb @@ -0,0 +1,499 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=346\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", + "fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape=hc_ss.shape\n", + "nfreqs = shape[-3]\n", + "nreals = shape[-2]\n", + "nloudest = shape[-1]\n", + "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1 hc\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Place single sources at random pixels" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def convert_pix_ss(pix_ss1, nside1, nside2):\n", + " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", + " print(f\"{theta.shape=}, {phi.shape=}\")\n", + " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", + " return pix_ss2" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 hc / dOmega\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hcdOm_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "CldOm_arrs = hcfile['CldOm_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hcdOm_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]/np.sqrt(npix)/area) # (frequency, realization, pixel)\n", + " return moll_bg\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "nsides=np.array([8,16,32, 64]) #, 128])\n", + "molldOm_bg08 = make_hcdOm_bg_map(hc_bg, nside=8)\n", + "molldOm_bg16 = make_hcdOm_bg_map(hc_bg, nside=16)\n", + "molldOm_bg32 = make_hcdOm_bg_map(hc_bg, nside=32)\n", + "molldOm_bg64 = make_hcdOm_bg_map(hc_bg, nside=64)\n", + "# molldOm_bg128 = make_hcdOm_bg_map(hc_bg, nside=128)\n", + "print(molldOm_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hcdOm_ss_map(hc_ss, nside, pix_ss=None):\n", + " print(hc_ss.shape)\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " print(pix_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " print(f\"{npix=}, {moll_ss.shape=}\")\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = (np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2 \n", + " + hc_ss[ff,rr,ll]**2) /area)\n", + " return moll_ss, pix_ss\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "molldOm_ss08, pix_ss08 = make_hcdOm_ss_map(hc_ss, 8)\n", + "pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "\n", + "molldOm_ss16, temp = make_hcdOm_ss_map(hc_ss, 16, pix_ss16)\n", + "molldOm_ss32, temp = make_hcdOm_ss_map(hc_ss, 32, pix_ss32)\n", + "molldOm_ss64, temp = make_hcdOm_ss_map(hc_ss, 64, pix_ss64)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", + "molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", + "molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", + "molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "rr=0\n", + "for ff in range(0,5):\n", + " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + " plt.axes(axs[0])\n", + " hp.mollview(molldOm_tt08[ff,rr], unit='$h_c/d\\Omega$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + " plt.axes(axs[1])\n", + " hp.mollview(molldOm_tt16[ff,rr], unit='$h_c/d\\Omega$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + " plt.axes(axs[2])\n", + " hp.mollview(molldOm_tt32[ff,rr], unit='$h_c/d\\Omega$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + " fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lmax=6\n", + "CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", + "CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", + "CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", + "CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", + "print(CldOm_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(CldOm_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = CldOm_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c/d\\Omega$' % (nn, rr, fobs[ff]*YR))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(CldOm_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = CldOm_arrs[...,ll]/CldOm_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $h_c/d\\Omega$' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hcdOm_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", + "# molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", + "# CldOm_arrs=CldOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Simple Function" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$ a_{\\ell m} = \\int d\\Omega_n \\Delta T (\\vec{n}) Y^*_{\\ell m} (\\vec{n}) $$\n", + "$$ C_{\\ell m} = \\frac{1}{2\\ell + 1} \\sum_{m=-\\ell}^\\ell |a_{\\ell m}|^2 $$\n", + "\n", + "$$ C_0 = (1) \\int d\\Omega \\cdot \\frac{h_c^2}{d\\Omega} \\cdot \\mathrm {constant} $$" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def solid_angle(nside):\n", + " area = hp.nside2pixarea(nside, degrees=False) # \n", + " return area\n", + "\n", + "def C0_integral(moll2_ss, nside, Y00star=1):\n", + " sum=0\n", + " dOm = solid_angle(nside)\n", + " for ii, hc2 in enumerate(moll2_ss):\n", + " sum += Y00star * hc2 * dOm\n", + " return sum\n", + "\n", + "ff = 1\n", + "rr = 0\n", + "dOmega =solid_angle(nside=8)\n", + "print(dOmega)\n", + "C0ss_08 = C0_integral(moll2dOm_ss08[ff,rr], 8)\n", + "C0ss_16 = C0_integral(moll2dOm_ss16[ff,rr], 16)\n", + "C0ss_32 = C0_integral(moll2dOm_ss32[ff,rr], 32)\n", + "C0ss_64 = C0_integral(moll2dOm_ss64[ff,rr], 64)\n", + "C0ss_128 = C0_integral(moll2dOm_ss128[ff,rr], 125)\n", + "\n", + "\n", + "C0tt_08 = C0_integral(moll2dOm_tt08[ff,rr], 8)\n", + "C0tt_16 = C0_integral(moll2dOm_tt16[ff,rr], 16)\n", + "C0tt_32 = C0_integral(moll2dOm_tt32[ff,rr], 32)\n", + "C0tt_64 = C0_integral(moll2dOm_tt64[ff,rr], 64)\n", + "C0tt_128 = C0_integral(moll2dOm_tt128[ff,rr], 125)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(moll_ss08.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsides = np.array([8, 16, 32, 64, 128])\n", + "C0ss = np.array([C0ss_08, C0ss_16, C0ss_32, C0ss_64, C0ss_128])\n", + "C0tt = np.array([C0tt_08, C0tt_16, C0tt_32, C0tt_64, C0tt_128])\n", + "\n", + "fig, ax = plot.figax(xlabel='nside', ylabel=r'$\\int d\\Omega \\frac{h_c^2}{d\\Omega}$')\n", + "ax.plot(nsides, C0ss, marker='o', label='ss only')\n", + "ax.plot(nsides, C0tt, marker='o', label='total map')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "l/ 2 pi r = theta / 2 pi \n", + "l = theta r\n", + "l^2 = theta^2 r^2 = area\n", + "omega = area / r^2 = theta ^2 r^2 / r^2 = theta^2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rat = 0.1\n", + "print(rat, rat**2)\n", + "rat = 10\n", + "print(rat, rat**2)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Scratch" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nbest=100\n", + "split=2\n", + "for ss in range(split):\n", + " bestrange = (np.array([ss, (ss+1)])*(nbest)/split).astype(int)\n", + " bestrange[1] = np.min([bestrange[1], nbest])\n", + " print(bestrange)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b015e68f15166b559e0966968282d8f2dd47e587 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 15:41:14 -0700 Subject: [PATCH 056/291] added anis.lib_anisotropy_split function that will calculate the nbest samples Cl's in 'split' chunks. --- holodeck/anisotropy.py | 144 ++++++++++++++++++++++++++++++++++++- scripts/anis_lib_script.py | 7 +- 2 files changed, 147 insertions(+), 4 deletions(-) diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 2d35ba3d..6f370a1f 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -20,6 +20,43 @@ HC_REF15_10YR = 11.2*10**-15 def healpix_map(hc_ss, hc_bg, nside=NSIDE): + """ Build mollview array of hc^2/dOmega for a healpix map + + Parameters + ---------- + hc_ss : (F,R,L) NDarray + Characteristic strain of single sources. + hc_bg : (F,R) NDarray + Characteristic strain of the background. + nside : integer + number of sides for healpix map. + + Returns + ------- + moll_hc : (NPIX,) 1Darray + Array of h_c^2/dOmega at every pixel for a mollview healpix map. + + NOTE: Could speed up the for-loops, but it's ok for now. + """ + + npix = hp.nside2npix(nside) + nfreqs = len(hc_ss) + nreals = len(hc_ss[0]) + nloudest = len(hc_ss[0,0]) + + # spread background evenly across pixels in moll_hc + moll_hc = np.ones((nfreqs,nreals,npix)) * hc_bg[:,:,np.newaxis]**2/(npix) # (frequency, realization, pixel) + + # choose random pixels to place the single sources + pix_ss = np.random.randint(0, npix-1, size=nfreqs*nreals*nloudest).reshape(nfreqs, nreals, nloudest) + for ff in range(nfreqs): + for rr in range(nreals): + for ll in range(nloudest): + moll_hc[ff,rr,pix_ss[ff,rr,ll]] = (moll_hc[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2) + + return moll_hc + +def healpix_map_oldhc(hc_ss, hc_bg, nside=NSIDE): """ Build mollview array of strains for a healpix map Parameters @@ -57,6 +94,44 @@ def healpix_map(hc_ss, hc_bg, nside=NSIDE): return moll_hc + +def healpix_hcsq_map(hc_ss, hc_bg, nside=NSIDE): + """ Build mollview array of strains for a healpix map + + Parameters + ---------- + hc_ss : (F,R,L) NDarray + Characteristic strain of single sources. + hc_bg : (F,R) NDarray + Characteristic strain of the background. + nside : integer + number of sides for healpix map. + + Returns + ------- + moll_hc : (NPIX,) 1Darray + Array of strain at every pixel for a mollview healpix map. + + NOTE: Could speed up the for-loops, but it's ok for now. + """ + + npix = hp.nside2npix(nside) + nfreqs = len(hc_ss) + nreals = len(hc_ss[0]) + nloudest = len(hc_ss[0,0]) + + # spread background evenly across pixels in moll_hc + moll_hc2 = np.ones((nfreqs,nreals,npix)) * hc_bg[:,:,np.newaxis]**2/(npix) # (frequency, realization, pixel) + + # choose random pixels to place the single sources + pix_ss = np.random.randint(0, npix-1, size=nfreqs*nreals*nloudest).reshape(nfreqs, nreals, nloudest) + for ff in range(nfreqs): + for rr in range(nreals): + for ll in range(nloudest): + moll_hc2[ff,rr,pix_ss[ff,rr,ll]] = moll_hc2[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2 + + return moll_hc2 + def sph_harm_from_map(moll_hc, lmax=LMAX): """ Calculate spherical harmonics from strains at every pixel of a healpix mollview map. @@ -100,7 +175,7 @@ def sph_harm_from_hc(hc_ss, hc_bg, nside = NSIDE, lmax = LMAX): Returns ------- moll_hc : (F,R,NPIX,) 2Darray - Array of strain at every pixel for a mollview healpix map. + Array of hc^2/dOmega at every pixel for a mollview healpix map. Cl : (F,R,lmax+1) NDarray Spherical harmonic coefficients @@ -192,7 +267,7 @@ def lib_anisotropy(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lm else: print('Writing to an existing directory.') - output_name = output_dir+'/sph_harm_lmax%d_nside%d_nbest%d_nreals%d.npz' % (lmax, nside, nbest, nreals) + output_name = output_dir+'/sph_harm_hc2dOm_lmax%d_nside%d_nbest%d_nreals%d.npz' % (lmax, nside, nbest, nreals) print('Saving npz file: ', output_name) np.savez(output_name, nsort=nsort, fidx=fidx, hc_ref=hc_ref, ss_shape=shape, @@ -207,6 +282,71 @@ def lib_anisotropy(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lm fig.savefig(fig_name, dpi=300) +def lib_anisotropy_split(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals=50, lmax=LMAX, nside=NSIDE, split=2): + + # ---- read in file + hdf_name = lib_path+'/sam_lib.hdf5' + print('Hdf file:', hdf_name) + + ss_file = h5py.File(hdf_name, 'r') + print('Loaded file, with keys:', list(ss_file.keys())) + hc_ss = ss_file['hc_ss'][:,:,:nreals,:] + hc_bg = ss_file['hc_bg'][:,:,:nreals] + fobs = ss_file['fobs'][:] + ss_file.close() + + shape = hc_ss.shape + nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3] + print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest) + + + # ---- rank samples + nsort, fidx, hc_ref = detstats.rank_samples(hc_ss, hc_bg, fobs, fidx=1, hc_ref=hc_ref_10yr, ret_all=True) + + print('Ranked samples by hc_ref = %.2e at fobs = %.2f/yr' % (hc_ref, fobs[fidx]*YR)) + + + for ss in range(split): + bestrange = (np.array([ss, (ss+1)])*(nbest)/split).astype(int) + bestrange[1] = np.min([bestrange[1], nbest]) + print(f"{bestrange=}") + # ---- calculate spherical harmonics + + npix = hp.nside2npix(nside) + Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 )) + moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix)) + for nn in range(bestrange[0], bestrange[1]): + print('on nn=%d out of nbest=%d' % (nn,nbest)) + moll_hc_best[nn,...], Cl_best[nn,...] = sph_harm_from_hc( + hc_ss[nsort[nn]], hc_bg[nsort[nn]], nside=nside, lmax=lmax, ) + + + # ---- save to npz file + + output_dir = lib_path+'/anisotropy' + # Assign output folder + import os + if (os.path.exists(output_dir) is False): + print('Making output directory.') + os.makedirs(output_dir) + else: + print('Writing to an existing directory.') + + output_name =(output_dir+'/sph_harm_hc2dOm_lmax%d_ns%02d_r%d_b%02d-%-02d.npz' + % (lmax, nside, nreals, bestrange[0], bestrange[1]-1)) + print('Saving npz file: ', output_name) + np.savez(output_name, + nsort=nsort, fidx=fidx, hc_ref=hc_ref, ss_shape=shape, + moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs) + + + # ---- plot median Cl/C0 + + print('Plotting Cl/C0 for median realizations') + fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=nbest) + fig_name = (output_dir+'/sph_harm_hc2dOm_lmax%d_ns%02d_r%d_b%02d-%-02d.png' + % (lmax, nside, nreals, bestrange[0], bestrange[1]-1)) + fig.savefig(fig_name, dpi=300) diff --git a/scripts/anis_lib_script.py b/scripts/anis_lib_script.py index 2a614b14..0f96bddb 100644 --- a/scripts/anis_lib_script.py +++ b/scripts/anis_lib_script.py @@ -15,6 +15,7 @@ DEF_LMAX = anisotropy.LMAX DEF_NBEST = 100 DEF_NREALS = 50 +DEF_SPLIT = 1 def _setup_argparse(): parser = argparse.ArgumentParser() @@ -28,14 +29,16 @@ def _setup_argparse(): help='number of best ranked samples to calculate spherical harmonics for') parser.add_argument('-r', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, help='number of realizations to use ranking and harmonics, must be less than or equal to nreals of library') + parser.add_argument('--split', action='store', dest='split', type=int, default=DEF_SPLIT, + help='number of sections to split nbest calculations into') args = parser.parse_args() return args def main(): args = _setup_argparse() - anisotropy.lib_anisotropy(args.lib_path, hc_ref_10yr=HC_REF_10YR, nbest=args.nbest, - nreals=args.nreals, lmax=args.lmax, nside=args.nside) + anisotropy.lib_anisotropy_split(args.lib_path, hc_ref_10yr=HC_REF_10YR, nbest=args.nbest, + nreals=args.nreals, lmax=args.lmax, nside=args.nside, split=args.split) if __name__ == "__main__": main() \ No newline at end of file From e71c60e4020c495a09fa1ef7a71fab490a77a3f9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 15:44:31 -0700 Subject: [PATCH 057/291] Renamed old paper plots that use hc instead of hc^2/dOmega --- .../oldhc_anisotropy_paper_plots.ipynb | 585 ++++++++++++++++++ .../anisotropy/oldhc_paper_plots_nside8.ipynb | 580 +++++++++++++++++ 2 files changed, 1165 insertions(+) create mode 100644 ecg-notebooks/anisotropy/oldhc_anisotropy_paper_plots.ipynb create mode 100644 ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb diff --git a/ecg-notebooks/anisotropy/oldhc_anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/oldhc_anisotropy_paper_plots.ipynb new file mode 100644 index 00000000..c0952397 --- /dev/null +++ b/ecg-notebooks/anisotropy/oldhc_anisotropy_paper_plots.ipynb @@ -0,0 +1,585 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up\n", + "\n", + "## Read in library\n", + "\n", + "ss16 has 10 loudest, definitely will replace this with a better library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "# hdfname = sspath+'/sam_lib.hdf5'\n", + "# ssfile = h5py.File(hdfname, 'r')\n", + "# print(list(ssfile.keys()))\n", + "# hc_ss = ssfile['hc_ss'][...]\n", + "# hc_bg = ssfile['hc_bg'][...]\n", + "# fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "# ssfile.close()\n", + "\n", + "# shape = hc_ss.shape\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Find Best Samples" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# hc_ref15_10yr = 11.2*10**-15 \n", + "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# nbest = 100\n", + "# print(hc_ref15)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load/Calculate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# np.savez(sspath+'sph_harmonics.npz', nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref15=hc_ref15, ss_shape=shape,\n", + "# moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs)\n", + "\n", + "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", + "\n", + "# load ss info\n", + "shape = sph_harm_file['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = sph_harm_file['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = sph_harm_file['nsort']\n", + "fidx = sph_harm_file['fidx']\n", + "hc_tt = sph_harm_file['hc_tt']\n", + "hc_ref15 = sph_harm_file['hc_ref15']\n", + "\n", + "# load harmonics info\n", + "nside = sph_harm_file['nside']\n", + "lmax = sph_harm_file['lmax']\n", + "moll_hc_best = sph_harm_file['moll_hc_best']\n", + "Cl_best = sph_harm_file['Cl_best']\n", + "nbest = len(moll_hc_best)\n", + "\n", + "sph_harm_file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = cm.gist_rainbow(np.linspace(0, 1, lmax))\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll], label='$l=%d$' % (ll+1))\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1) \n", + " ax.legend(ncols=2)\n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def plot_Clg0_llp1_medians(xx, Cl_best, lmax, nshow):\n", + "# fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + "# yy = np.sum(Cl_best[:,:,:,1:], axis=-1)/Cl_best[:,:,:,0,] # (B,F,R)\n", + "# yy = np.median(yy, axis=-1) # (B,F) median over realizations\n", + "\n", + "# ax.plot(xx, np.median(yy, axis=0), color='k', label='median of samples, $l_\\mathrm{max}=%d$' % lmax)\n", + "# for pp in [50, 98]:\n", + "# percs = pp/2\n", + "# percs = [50-percs, 50+percs]\n", + "# ax.fill_between(xx, *np.percentile(yy, percs, axis=0), alpha=0.1, color='k')\n", + "\n", + "# colors = cm.rainbow(np.linspace(1, 0, nshow))\n", + "# bb=0\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1, label=\"individual best samples, median of realizations\")\n", + "# for bb in range(1,nshow):\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1)\n", + "# ax.legend()\n", + "# plot._twin_hz(ax, nano=False)\n", + " \n", + "# # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + "# # % (nbest, lmax))\n", + "# return fig\n", + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan,\n", + " figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$'):\n", + " fig, ax = plot.figax(figsize=figsize, xlabel=xlabel, ylabel=ylabel,)\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=5)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " ax.set_xlabel(xlabel, fontsize=11)\n", + " ax.set_ylabel(ylabel, fontsize=11)\n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_bigfont.png', dpi=400)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=100)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# for ll in range(len(Cl_nihan[0])):\n", + " \n", + "\n", + "# ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# # ax.set_xscale('linear')\n", + "# fig.legend(loc='lower right')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# # ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# ax.legend(loc='lower right')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Sato-Polito & Kamionkowski" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "ax = fig.axes[0]\n", + "\n", + "xx = freq_bins_Hz * YR \n", + "ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='tab:orange')\n", + "ax.set_xlim(0, np.max(fobs_yrs))\n", + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "hdfname = sspath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "print('Best sample:', nsort[0])\n", + "hc_ss = ssfile['hc_ss'][nsort[0],...]\n", + "hc_bg = ssfile['hc_bg'][nsort[0],...]\n", + "fobs = ssfile['fobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape = hc_ss.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "print('F,R,L =', nfreqs, nreals, nloudest)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb b/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb new file mode 100644 index 00000000..3b11122e --- /dev/null +++ b/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb @@ -0,0 +1,580 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up\n", + "\n", + "## Read in library\n", + "\n", + "ss16 has 10 loudest, definitely will replace this with a better library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "# hdfname = sspath+'/sam_lib.hdf5'\n", + "# ssfile = h5py.File(hdfname, 'r')\n", + "# print(list(ssfile.keys()))\n", + "# hc_ss = ssfile['hc_ss'][...]\n", + "# hc_bg = ssfile['hc_bg'][...]\n", + "# fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "# ssfile.close()\n", + "\n", + "# shape = hc_ss.shape\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Find Best Samples" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# hc_ref15_10yr = 11.2*10**-15 \n", + "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# nbest = 100\n", + "# print(hc_ref15)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load/Calculate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# np.savez(sspath+'sph_harmonics.npz', nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref15=hc_ref15, ss_shape=shape,\n", + "# moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs)\n", + "\n", + "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside8_nbest100_nreals50.npz')\n", + "print(sph_harm_file.files)\n", + "\n", + "# load ss info\n", + "shape = sph_harm_file['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = sph_harm_file['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = sph_harm_file['nsort']\n", + "fidx = sph_harm_file['fidx']\n", + "hc_ref = sph_harm_file['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = sph_harm_file['nside']\n", + "lmax = sph_harm_file['lmax']\n", + "moll_hc_best = sph_harm_file['moll_hc_best']\n", + "Cl_best = sph_harm_file['Cl_best']\n", + "nbest = len(moll_hc_best)\n", + "\n", + "sph_harm_file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = cm.gist_rainbow(np.linspace(0, 1, lmax))\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll], label='$l=%d$' % (ll+1))\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1) \n", + " ax.legend(ncols=2)\n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def plot_Clg0_llp1_medians(xx, Cl_best, lmax, nshow):\n", + "# fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + "# yy = np.sum(Cl_best[:,:,:,1:], axis=-1)/Cl_best[:,:,:,0,] # (B,F,R)\n", + "# yy = np.median(yy, axis=-1) # (B,F) median over realizations\n", + "\n", + "# ax.plot(xx, np.median(yy, axis=0), color='k', label='median of samples, $l_\\mathrm{max}=%d$' % lmax)\n", + "# for pp in [50, 98]:\n", + "# percs = pp/2\n", + "# percs = [50-percs, 50+percs]\n", + "# ax.fill_between(xx, *np.percentile(yy, percs, axis=0), alpha=0.1, color='k')\n", + "\n", + "# colors = cm.rainbow(np.linspace(1, 0, nshow))\n", + "# bb=0\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1, label=\"individual best samples, median of realizations\")\n", + "# for bb in range(1,nshow):\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1)\n", + "# ax.legend()\n", + "# plot._twin_hz(ax, nano=False)\n", + " \n", + "# # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + "# # % (nbest, lmax))\n", + "# return fig\n", + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=100)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# for ll in range(len(Cl_nihan[0])):\n", + " \n", + "\n", + "# ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# # ax.set_xscale('linear')\n", + "# fig.legend(loc='lower right')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# # ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# ax.legend(loc='lower right')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Sato-Polito & Kamionkowski" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "ax = fig.axes[0]\n", + "\n", + "xx = freq_bins_Hz * YR \n", + "ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='tab:orange')\n", + "ax.set_xlim(0, np.max(fobs_yrs))\n", + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "hdfname = sspath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "print('Best sample:', nsort[0])\n", + "hc_ss = ssfile['hc_ss'][nsort[0],...]\n", + "hc_bg = ssfile['hc_bg'][nsort[0],...]\n", + "fobs = ssfile['fobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape = hc_ss.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "print('F,R,L =', nfreqs, nreals, nloudest)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From e848e2053f23bd4ef8ba56a51d95529169827210 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 15:47:50 -0700 Subject: [PATCH 058/291] Added split to saved npz array for lib anisotropy. --- holodeck/anisotropy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 6f370a1f..0eb93a69 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -337,7 +337,7 @@ def lib_anisotropy_split(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals= print('Saving npz file: ', output_name) np.savez(output_name, nsort=nsort, fidx=fidx, hc_ref=hc_ref, ss_shape=shape, - moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs) + moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs, split=split) # ---- plot median Cl/C0 From 8b492430c8a53c6bac4fd09f9fefbd12bef2d81e Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 17:02:50 -0700 Subject: [PATCH 059/291] New anisotropy paper plots using hc^2/dOmega with split library function. --- ...e8.ipynb => hc2dOm_paper_plots_ns08.ipynb} | 155 +++++++++++++++--- ...ts.ipynb => hc2dOm_paper_plots_ns32.ipynb} | 104 ++++++++---- .../anisotropy/oldhc_paper_plots_nside8.ipynb | 14 +- holodeck/anisotropy.py | 20 +-- 4 files changed, 221 insertions(+), 72 deletions(-) rename ecg-notebooks/anisotropy/{anisotropy_paper_plots_nside8.ipynb => hc2dOm_paper_plots_ns08.ipynb} (83%) rename ecg-notebooks/anisotropy/{anisotropy_paper_plots.ipynb => hc2dOm_paper_plots_ns32.ipynb} (89%) diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb b/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns08.ipynb similarity index 83% rename from ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb rename to ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns08.ipynb index 3b11122e..9dafaac6 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots_nside8.ipynb +++ b/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns08.ipynb @@ -78,7 +78,71 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Load/Calculate pixel strains and harmonic coefficients" + "## Load and concatenate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = file1['nsort']\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best'][:49]\n", + "Cl_best1 = file1['Cl_best'][:49]\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n", + "# load map and harmonics from 2nd split chunk\n", + "file2 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz')\n", + "moll_hc_best2 = file2['moll_hc_best'][49:]\n", + "Cl_best2 = file2['Cl_best'][49:]\n", + "nbest2 = len(moll_hc_best2)\n", + "file2.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")\n", + "print(f\"{Cl_best.shape=}, {moll_hc_best.shape=}\")" ] }, { @@ -104,30 +168,30 @@ "metadata": {}, "outputs": [], "source": [ - "# np.savez(sspath+'sph_harmonics.npz', nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref15=hc_ref15, ss_shape=shape,\n", - "# moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs)\n", - "\n", - "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside8_nbest100_nreals50.npz')\n", - "print(sph_harm_file.files)\n", - "\n", - "# load ss info\n", - "shape = sph_harm_file['ss_shape']\n", - "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - "fobs = sph_harm_file['fobs']\n", - "\n", - "# load ranking info\n", - "nsort = sph_harm_file['nsort']\n", - "fidx = sph_harm_file['fidx']\n", - "hc_ref = sph_harm_file['hc_ref']\n", - "\n", - "# load harmonics info\n", - "nside = sph_harm_file['nside']\n", - "lmax = sph_harm_file['lmax']\n", - "moll_hc_best = sph_harm_file['moll_hc_best']\n", - "Cl_best = sph_harm_file['Cl_best']\n", - "nbest = len(moll_hc_best)\n", + "print(np.where(Cl_best[:,0,0,0]==0))\n", + "print(np.where(Cl_best1[:,0,0,0]==0))\n", + "print(np.where(Cl_best2[:,0,0,0]==0))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(np.arange(len(Cl_best)), Cl_best[:,0,0,0])\n", + "plt.ylim(0,0.1e-58)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "\n", - "sph_harm_file.close()" + "print(holo.utils.stats(Cl_best1))\n", + "print(holo.utils.stats(Cl_best2))" ] }, { @@ -136,7 +200,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(Cl_best.shape)" + "print(Cl_best.shape)\n", + "print(holo.utils.stats(Cl_best))" ] }, { @@ -189,7 +254,9 @@ " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", " # % (nbest, lmax))\n", " return fig\n", - "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)" + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" ] }, { @@ -352,7 +419,9 @@ "ax.legend(loc='lower right', ncols=3)\n", "\n", "fig.tight_layout()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_newcolors.png', dpi=300)" + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" ] }, { @@ -548,6 +617,38 @@ "print('F,R,L =', nfreqs, nreals, nloudest)\n" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Scratch" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "split=7\n", + "nbest=100\n", + "for ss in range(split):\n", + " bestrange = (np.array([ss, (ss+1)])*(nbest)/split).astype(int)\n", + " bestrange[1] = np.min([bestrange[1], nbest])\n", + " print(f\"{bestrange=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, nn in enumerate(range(bestrange[0], bestrange[1])):\n", + " print('on nn=%d out of nbest=%d, index=%d' % (nn,nbest, ii))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns32.ipynb similarity index 89% rename from ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb rename to ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns32.ipynb index c0952397..4208cba0 100644 --- a/ecg-notebooks/anisotropy/anisotropy_paper_plots.ipynb +++ b/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns32.ipynb @@ -78,7 +78,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Load/Calculate pixel strains and harmonic coefficients" + "## Load and concatenate pixel strains and harmonic coefficients" ] }, { @@ -87,15 +87,46 @@ "metadata": {}, "outputs": [], "source": [ - "# npix = anisotropy.NPIX\n", - "# lmax = anisotropy.LMAX\n", + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", "\n", - "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", - "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", - "# for nn in range(nbest):\n", - "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", - "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", - "# hc_bg[nsort[nn]])" + "# load ranking info\n", + "nsort = file1['nsort']\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best']\n", + "Cl_best1 = file1['Cl_best']\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n", + "# load map and harmonics from 2nd split chunk\n", + "file2 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b50-99.npz')\n", + "moll_hc_best2 = file2['moll_hc_best']\n", + "Cl_best2 = file2['Cl_best']\n", + "nbest2 = len(moll_hc_best2)\n", + "file2.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")" ] }, { @@ -104,30 +135,13 @@ "metadata": {}, "outputs": [], "source": [ - "# np.savez(sspath+'sph_harmonics.npz', nsort=nsort, fidx=fidx, hc_tt=hc_tt, hc_ref15=hc_ref15, ss_shape=shape,\n", - "# moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs)\n", - "\n", - "sph_harm_file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_lmax6_nside32_nbest100.npz')\n", - "\n", - "# load ss info\n", - "shape = sph_harm_file['ss_shape']\n", - "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - "fobs = sph_harm_file['fobs']\n", - "\n", - "# load ranking info\n", - "nsort = sph_harm_file['nsort']\n", - "fidx = sph_harm_file['fidx']\n", - "hc_tt = sph_harm_file['hc_tt']\n", - "hc_ref15 = sph_harm_file['hc_ref15']\n", - "\n", - "# load harmonics info\n", - "nside = sph_harm_file['nside']\n", - "lmax = sph_harm_file['lmax']\n", - "moll_hc_best = sph_harm_file['moll_hc_best']\n", - "Cl_best = sph_harm_file['Cl_best']\n", - "nbest = len(moll_hc_best)\n", "\n", - "sph_harm_file.close()" + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" ] }, { @@ -136,7 +150,27 @@ "metadata": {}, "outputs": [], "source": [ - "print(Cl_best.shape)" + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")\n", + "print(f\"{Cl_best.shape=}, {moll_hc_best.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" ] }, { @@ -357,7 +391,9 @@ "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", "\n", "fig.tight_layout()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_bigfont.png', dpi=400)" + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" ] }, { diff --git a/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb b/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb index 3b11122e..eb7f93a9 100644 --- a/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb +++ b/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb @@ -136,7 +136,19 @@ "metadata": {}, "outputs": [], "source": [ - "print(Cl_best.shape)" + "\n", + "print(holo.utils.stats(Cl_best[:49]))\n", + "print(holo.utils.stats(Cl_best[49:]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)\n", + "print(holo.utils.stats(Cl_best))" ] }, { diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 0eb93a69..291a5b84 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -313,11 +313,11 @@ def lib_anisotropy_split(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals= # ---- calculate spherical harmonics npix = hp.nside2npix(nside) - Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 )) - moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix)) - for nn in range(bestrange[0], bestrange[1]): + Cl_best = np.zeros((bestrange[1]-bestrange[0], nfreqs, nreals, lmax+1 )) + moll_hc_best = np.zeros((bestrange[1]-bestrange[0], nfreqs, nreals, npix)) + for ii, nn in enumerate(range(bestrange[0], bestrange[1])): print('on nn=%d out of nbest=%d' % (nn,nbest)) - moll_hc_best[nn,...], Cl_best[nn,...] = sph_harm_from_hc( + moll_hc_best[ii,...], Cl_best[ii,...] = sph_harm_from_hc( hc_ss[nsort[nn]], hc_bg[nsort[nn]], nside=nside, lmax=lmax, ) @@ -340,13 +340,13 @@ def lib_anisotropy_split(lib_path, hc_ref_10yr=HC_REF15_10YR, nbest=100, nreals= moll_hc_best=moll_hc_best, Cl_best=Cl_best, nside=nside, lmax=lmax, fobs=fobs, split=split) - # ---- plot median Cl/C0 + # # ---- plot median Cl/C0 - print('Plotting Cl/C0 for median realizations') - fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=nbest) - fig_name = (output_dir+'/sph_harm_hc2dOm_lmax%d_ns%02d_r%d_b%02d-%-02d.png' - % (lmax, nside, nreals, bestrange[0], bestrange[1]-1)) - fig.savefig(fig_name, dpi=300) + # print('Plotting Cl/C0 for median realizations') + # fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=(bestrange[1]-bestrange[0])) + # fig_name = (output_dir+'/sph_harm_hc2dOm_lmax%d_ns%02d_r%d_b%02d-%-02d.png' + # % (lmax, nside, nreals, bestrange[0], bestrange[1]-1)) + # fig.savefig(fig_name, dpi=300) From ec45bbd1a94a97f65a0156df3fc253381665f71e Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 17:06:01 -0700 Subject: [PATCH 060/291] Deleted DS_Store file. --- ecg-notebooks/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 ecg-notebooks/.DS_Store diff --git a/ecg-notebooks/.DS_Store b/ecg-notebooks/.DS_Store deleted file mode 100644 index 7d06b5c08f02aa64eacb9fd1a67486bd63ca9e9a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKL2KJE6n<*5)=4RZu|kf9T}zh*$`*F<()O_HJhsDDGCNK?GfxV!voJ!y=k3Sz zx?j@2(|u1;#+sy%OU4%T;OTqP(sK#R}s*`;zV0mR+FG zV<;+UM2d#=ZK=0wa0)mD{xt=7@75_INh#&nxxe@Ct4#IdOvT9a;qVfEe5(!7J)C%w z4=v|sJj~L(Xti#{PNn)_chB4N_PvYnlbVD@RE+a(G0r`pJUUgf zh*CKiX+oL|(B;FsR3>WDRb!dtnj4ygSMzGUMsqqn>9mggcB?%*@~53P;%A-bvsukM zeEj6a>)z+=i&WqB*OS0`rR~7t9DX2JsmIrFBr_$ikZ0~gN@xJJa(JY%N0&5)j(yZp zC@Cpl(C`|(KQ&xyj4jc0t+g&_47r?bPyxFKy!{Q%;f8h!I0gPs1^9gM;f#UB(x5&% zQ0ONBu!?4Fi1~McIljffVrdW=m@rhJp$hxN5QdI+-}VbEmIe)-gnfJnJF~Da6rpFw z_`dE=A~5Jmr+`!7t^yTPZSehne*gRbF3HuL0#1RgQb1JC!m}=xWbf9c#qnM1!#~2= oxL;{dQ&8CJSO<6ErTnZ0)JJ3UlruGEC2ui From ecc22256c338271d8b27fbbb214719c304ee9ea0 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 18:35:20 -0700 Subject: [PATCH 061/291] Trying other varying_nside methods in separate methods, to make sure they aren't using old variables. --- .../anisotropy/healpix/varying_nside.ipynb | 132 +++--- .../healpix/varying_nside_hc2.ipynb | 330 +++++++++++++++ .../healpix/varying_nside_hc2dOm.ipynb | 385 ++++++++++++++++++ 3 files changed, 775 insertions(+), 72 deletions(-) create mode 100644 ecg-notebooks/anisotropy/healpix/varying_nside_hc2.ipynb create mode 100644 ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb index cb3cd9d8..17635660 100644 --- a/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb +++ b/ecg-notebooks/anisotropy/healpix/varying_nside.ipynb @@ -446,12 +446,6 @@ "metadata": {}, "outputs": [], "source": [ - "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "\n", "# moll2_ss08, temp = make_hc2_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", "# moll2_ss16, temp = make_hc2_ss_map(hc_ss, 16, pix_ss16)\n", "# moll2_ss32, temp = make_hc2_ss_map(hc_ss, 32, pix_ss32)\n", @@ -825,7 +819,7 @@ " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", "\n", " ax.legend()\n", - " ax.set_title('Sample %d, $h_c^2/d\\Omega$' % (nn))\n", + " ax.set_title('Sample %d, $\\ell$=%d, $h_c^2/d\\Omega$' % (nn,ll))\n", " fig.tight_layout()" ] }, @@ -878,10 +872,10 @@ "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", "hcfile = np.load(save_loc+'/hcdOm_A.npz')\n", "\n", - "pix_ss08=hcfile['pix_ss08']\n", - "pix_ss16=hcfile['pix_ss16']\n", - "pix_ss32=hcfile['pix_ss32']\n", - "pix_ss64=hcfile['pix_ss64']\n", + "# pix_ss08=hcfile['pix_ss08']\n", + "# pix_ss16=hcfile['pix_ss16']\n", + "# pix_ss32=hcfile['pix_ss32']\n", + "# pix_ss64=hcfile['pix_ss64']\n", "# moll_ss08=hcfile['moll_ss08']\n", "# moll_ss16=hcfile['moll_ss16']\n", "# moll_ss32=hcfile['moll_ss32']\n", @@ -972,10 +966,10 @@ "outputs": [], "source": [ "\n", - "molldOm_ss08, temp = make_hcdOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", - "molldOm_ss16, temp = make_hcdOm_ss_map(hc_ss, 16, pix_ss16)\n", - "molldOm_ss32, temp = make_hcdOm_ss_map(hc_ss, 32, pix_ss32)\n", - "molldOm_ss64, temp = make_hcdOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# molldOm_ss08, temp = make_hcdOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# molldOm_ss16, temp = make_hcdOm_ss_map(hc_ss, 16, pix_ss16)\n", + "# molldOm_ss32, temp = make_hcdOm_ss_map(hc_ss, 32, pix_ss32)\n", + "# molldOm_ss64, temp = make_hcdOm_ss_map(hc_ss, 64, pix_ss64)\n", "# molldOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)\n" ] }, @@ -985,10 +979,10 @@ "metadata": {}, "outputs": [], "source": [ - "molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", - "molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", - "molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", - "molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n", + "# molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", + "# molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", + "# molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", + "# molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n", "# molldOm_tt128 = np.sqrt(molldOm_ss128**2 + molldOm_bg128**2)\n" ] }, @@ -1028,11 +1022,11 @@ "metadata": {}, "outputs": [], "source": [ - "lmax=6\n", - "CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", - "CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", - "CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", - "CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)\n", + "# lmax=6\n", + "# CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", + "# CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", + "# CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", + "# CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)\n", "# CldOm_128 = anis.sph_harm_from_map(molldOm_tt128, lmax=6)" ] }, @@ -1042,7 +1036,7 @@ "metadata": {}, "outputs": [], "source": [ - "CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", + "# CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", "print(CldOm_arrs.shape)" ] }, @@ -1088,7 +1082,7 @@ " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", "\n", " ax.legend()\n", - " ax.set_title('Sample %d, Realization %d, $h_c/d\\Omega$' % (nn, rr))\n", + " ax.set_title('Sample %d, Realization %d, $\\ell$=%d, $h_c/d\\Omega$' % (nn, rr, ll))\n", " fig.tight_layout()" ] }, @@ -1106,14 +1100,14 @@ "metadata": {}, "outputs": [], "source": [ - "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", - "np.savez(save_loc+'/hcdOm_A.npz', \n", - " pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", - " molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", - " molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", - " molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", - " CldOm_arrs=CldOm_arrs, nsides=nsides)\n", - " # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hcdOm_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", + "# molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", + "# CldOm_arrs=CldOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" ] }, { @@ -1124,6 +1118,7 @@ "source": [] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -1142,6 +1137,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [] @@ -1152,33 +1148,33 @@ "metadata": {}, "outputs": [], "source": [ - "def solid_angle(nside):\n", - " area = hp.nside2pixarea(nside, degrees=False) # \n", - " return area\n", + "# def solid_angle(nside):\n", + "# area = hp.nside2pixarea(nside, degrees=False) # \n", + "# return area\n", "\n", - "def C0_integral(moll2_ss, nside, Y00star=1):\n", - " sum=0\n", - " dOm = solid_angle(nside)\n", - " for ii, hc2 in enumerate(moll2_ss):\n", - " sum += Y00star * hc2 * dOm\n", - " return sum\n", + "# def C0_integral(moll2_ss, nside, Y00star=1):\n", + "# sum=0\n", + "# dOm = solid_angle(nside)\n", + "# for ii, hc2 in enumerate(moll2_ss):\n", + "# sum += Y00star * hc2 * dOm\n", + "# return sum\n", "\n", - "ff = 1\n", - "rr = 0\n", - "dOmega =solid_angle(nside=8)\n", - "print(dOmega)\n", - "C0ss_08 = C0_integral(moll2dOm_ss08[ff,rr], 8)\n", - "C0ss_16 = C0_integral(moll2dOm_ss16[ff,rr], 16)\n", - "C0ss_32 = C0_integral(moll2dOm_ss32[ff,rr], 32)\n", - "C0ss_64 = C0_integral(moll2dOm_ss64[ff,rr], 64)\n", - "C0ss_128 = C0_integral(moll2dOm_ss128[ff,rr], 125)\n", + "# ff = 1\n", + "# rr = 0\n", + "# dOmega =solid_angle(nside=8)\n", + "# print(dOmega)\n", + "# C0ss_08 = C0_integral(moll2dOm_ss08[ff,rr], 8)\n", + "# C0ss_16 = C0_integral(moll2dOm_ss16[ff,rr], 16)\n", + "# C0ss_32 = C0_integral(moll2dOm_ss32[ff,rr], 32)\n", + "# C0ss_64 = C0_integral(moll2dOm_ss64[ff,rr], 64)\n", + "# C0ss_128 = C0_integral(moll2dOm_ss128[ff,rr], 125)\n", "\n", "\n", - "C0tt_08 = C0_integral(moll2dOm_tt08[ff,rr], 8)\n", - "C0tt_16 = C0_integral(moll2dOm_tt16[ff,rr], 16)\n", - "C0tt_32 = C0_integral(moll2dOm_tt32[ff,rr], 32)\n", - "C0tt_64 = C0_integral(moll2dOm_tt64[ff,rr], 64)\n", - "C0tt_128 = C0_integral(moll2dOm_tt128[ff,rr], 125)" + "# C0tt_08 = C0_integral(moll2dOm_tt08[ff,rr], 8)\n", + "# C0tt_16 = C0_integral(moll2dOm_tt16[ff,rr], 16)\n", + "# C0tt_32 = C0_integral(moll2dOm_tt32[ff,rr], 32)\n", + "# C0tt_64 = C0_integral(moll2dOm_tt64[ff,rr], 64)\n", + "# C0tt_128 = C0_integral(moll2dOm_tt128[ff,rr], 125)" ] }, { @@ -1187,25 +1183,17 @@ "metadata": {}, "outputs": [], "source": [ - "print(moll_ss08.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "nsides = np.array([8, 16, 32, 64, 128])\n", - "C0ss = np.array([C0ss_08, C0ss_16, C0ss_32, C0ss_64, C0ss_128])\n", - "C0tt = np.array([C0tt_08, C0tt_16, C0tt_32, C0tt_64, C0tt_128])\n", + "# nsides = np.array([8, 16, 32, 64, 128])\n", + "# C0ss = np.array([C0ss_08, C0ss_16, C0ss_32, C0ss_64, C0ss_128])\n", + "# C0tt = np.array([C0tt_08, C0tt_16, C0tt_32, C0tt_64, C0tt_128])\n", "\n", - "fig, ax = plot.figax(xlabel='nside', ylabel=r'$\\int d\\Omega \\frac{h_c^2}{d\\Omega}$')\n", - "ax.plot(nsides, C0ss, marker='o', label='ss only')\n", - "ax.plot(nsides, C0tt, marker='o', label='total map')" + "# fig, ax = plot.figax(xlabel='nside', ylabel=r'$\\int d\\Omega \\frac{h_c^2}{d\\Omega}$')\n", + "# ax.plot(nsides, C0ss, marker='o', label='ss only')\n", + "# ax.plot(nsides, C0tt, marker='o', label='total map')" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside_hc2.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside_hc2.ipynb new file mode 100644 index 00000000..9c2b6add --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/varying_nside_hc2.ipynb @@ -0,0 +1,330 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=346\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", + "fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape=hc_ss.shape\n", + "nfreqs = shape[-3]\n", + "nreals = shape[-2]\n", + "nloudest = shape[-1]\n", + "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def convert_pix_ss(pix_ss1, nside1, nside2):\n", + " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", + " print(f\"{theta.shape=}, {phi.shape=}\")\n", + " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", + " return pix_ss2" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 hc^2 \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc2_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "# Cl2_arrs = hcfile['Cl2_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.1 Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hc2_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]**2/(npix)) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "nsides=np.array([8,16,32, 64]) #, 128])\n", + "moll2_bg08 = make_hc2_bg_map(hc_bg, nside=8)\n", + "moll2_bg16 = make_hc2_bg_map(hc_bg, nside=16)\n", + "moll2_bg32 = make_hc2_bg_map(hc_bg, nside=32)\n", + "moll2_bg64 = make_hc2_bg_map(hc_bg, nside=64)\n", + "# moll2_bg128 = make_hc2_bg_map(hc_bg, nside=128)\n", + "print(moll2_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hc2_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = moll_ss[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2\n", + " return moll_ss, pix_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "# pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)\n", + "\n", + "moll2_ss08, temp = make_hc2_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "moll2_ss16, temp = make_hc2_ss_map(hc_ss, 16, pix_ss16)\n", + "moll2_ss32, temp = make_hc2_ss_map(hc_ss, 32, pix_ss32)\n", + "moll2_ss64, temp = make_hc2_ss_map(hc_ss, 64, pix_ss64)\n", + "# moll2_ss128, temp = make_hc2_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll2_tt08 = (moll2_ss08 + moll2_bg08)\n", + "moll2_tt16 = (moll2_ss16 + moll2_bg16)\n", + "moll2_tt32 = (moll2_ss32 + moll2_bg32)\n", + "moll2_tt64 = (moll2_ss64 + moll2_bg64)\n", + "# moll2_tt128 = (moll2_ss128 + moll2_bg128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "rr=0\n", + "for ff in range(0,5):\n", + " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + " plt.axes(axs[0])\n", + " hp.mollview(moll2_tt08[ff,rr], unit='$h_c^2$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + " plt.axes(axs[1])\n", + " hp.mollview(moll2_tt16[ff,rr], unit='$h_c^2$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + " plt.axes(axs[2])\n", + " hp.mollview(moll2_tt32[ff,rr], unit='$h_c^2$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + " fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lmax=6\n", + "Cl2_08 = anis.sph_harm_from_map(moll2_tt08, lmax=6)\n", + "Cl2_16 = anis.sph_harm_from_map(moll2_tt16, lmax=6)\n", + "Cl2_32 = anis.sph_harm_from_map(moll2_tt32, lmax=6)\n", + "Cl2_64 = anis.sph_harm_from_map(moll2_tt64, lmax=6)\n", + "# Cl2_128 = anis.sph_harm_from_map(moll2_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Cl2_arrs = np.array([Cl2_08, Cl2_16, Cl2_32, Cl2_64]) #, Cl2_128])\n", + "print(Cl2_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl2_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2$' % (nn, rr, fobs[ff]*YR))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl2_arrs[...,ll]/Cl2_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, $h_c^2$, $\\ell$=%d' % (nn, ll))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc2_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll2_ss08=moll2_ss08, moll2_ss16=moll2_ss16, moll2_ss32=moll2_ss32, moll2_ss64=moll2_ss64, #moll_ss128=moll_ss128,\n", + "# moll2_bg08=moll2_bg08, moll2_bg16=moll2_bg16, moll2_bg32=moll2_bg32, moll2_bg64=moll2_bg64,# moll_bg128=moll_bg128,\n", + "# moll2_tt08=moll2_tt08, moll2_tt16=moll2_tt16, moll2_tt32=moll2_tt32, moll2_tt64=moll2_tt64, #moll_tt128=moll_tt128,\n", + "# Cl2_arrs=Cl2_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb new file mode 100644 index 00000000..b33af17e --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb @@ -0,0 +1,385 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=346\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", + "fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape=hc_ss.shape\n", + "nfreqs = shape[-3]\n", + "nreals = shape[-2]\n", + "nloudest = shape[-1]\n", + "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1 hc\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc_A.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "pix_ss08 = hcfile['pix_ss08']\n", + "pix_ss16 = hcfile['pix_ss16']\n", + "pix_ss32 = hcfile['pix_ss32']\n", + "pix_ss64 = hcfile['pix_ss64']\n", + "# pix_ss128 = hcfile['pix_ss128']\n", + "# Cl_arrs = hcfile['Cl_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "lmax=6\n", + "nsides=np.array([8,16,32,64])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def convert_pix_ss(pix_ss1, nside1, nside2):\n", + " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", + " print(f\"{theta.shape=}, {phi.shape=}\")\n", + " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", + " return pix_ss2\n", + "\n", + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "# pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "# # pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 hc^2/dOmega \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# hcfile = np.load(save_loc+'/hc2dOm_A.npz')\n", + "\n", + "# # pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# # moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# # moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# # moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# # pix_ss08 = hcfile['pix_ss08']\n", + "# # pix_ss16 = hcfile['pix_ss16']\n", + "# # pix_ss32 = hcfile['pix_ss32']\n", + "# # pix_ss64 = hcfile['pix_ss64']\n", + "# # # pix_ss128 = hcfile['pix_ss128']\n", + "# Cl2dOm_arrs = hcfile['Cl2dOm_arrs']\n", + "# # nsides=hcfile['nsides']\n", + "\n", + "# hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.1 Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hc2dOm_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]**2/npix/area) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "nsides=np.array([8,16,32, 64]) #, 128])\n", + "moll2dOm_bg08 = make_hc2dOm_bg_map(hc_bg, nside=8)\n", + "moll2dOm_bg16 = make_hc2dOm_bg_map(hc_bg, nside=16)\n", + "moll2dOm_bg32 = make_hc2dOm_bg_map(hc_bg, nside=32)\n", + "moll2dOm_bg64 = make_hc2dOm_bg_map(hc_bg, nside=64)\n", + "# moll2dOm_bg128 = make_hc2dOm_bg_map(hc_bg, nside=128)\n", + "print(moll2dOm_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hc2dOm_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = (moll_ss[ff,rr,pix_ss[ff,rr,ll]] \n", + " + hc_ss[ff,rr,ll]**2 /area)\n", + " return moll_ss, pix_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll2dOm_ss08, temp = make_hc2dOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "moll2dOm_ss16, temp = make_hc2dOm_ss_map(hc_ss, 16, pix_ss16)\n", + "moll2dOm_ss32, temp = make_hc2dOm_ss_map(hc_ss, 32, pix_ss32)\n", + "moll2dOm_ss64, temp = make_hc2dOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# moll2dOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll2dOm_tt08 = (moll2dOm_ss08 + moll2dOm_bg08)\n", + "moll2dOm_tt16 = (moll2dOm_ss16 + moll2dOm_bg16)\n", + "moll2dOm_tt32 = (moll2dOm_ss32 + moll2dOm_bg32)\n", + "moll2dOm_tt64 = (moll2dOm_ss64 + moll2dOm_bg64)\n", + "# moll2dOm_tt128 = (moll2dOm_ss128 + moll2dOm_bg128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "rr=0\n", + "for ff in range(0,5):\n", + " fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + " plt.axes(axs[0])\n", + " hp.mollview(moll2dOm_tt08[ff,rr], unit='$h_c^2/d\\Omega$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + " plt.axes(axs[1])\n", + " hp.mollview(moll2dOm_tt16[ff,rr], unit='$h_c^2/d\\Omega$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + " plt.axes(axs[2])\n", + " hp.mollview(moll2dOm_tt32[ff,rr], unit='$h_c^2/d\\Omega$',\n", + " title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + " fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lmax=6\n", + "Cl2dOm_08 = anis.sph_harm_from_map(moll2dOm_tt08, lmax=6)\n", + "Cl2dOm_16 = anis.sph_harm_from_map(moll2dOm_tt16, lmax=6)\n", + "Cl2dOm_32 = anis.sph_harm_from_map(moll2dOm_tt32, lmax=6)\n", + "Cl2dOm_64 = anis.sph_harm_from_map(moll2dOm_tt64, lmax=6)\n", + "# Cl2dOm_128 = anis.sph_harm_from_map(moll2dOm_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Cl2dOm_arrs = np.array([Cl2dOm_08, Cl2dOm_16, Cl2dOm_32, Cl2dOm_64]) #, Cl2dOm_128])\n", + "print(Cl2dOm_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsides)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2dOm_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl2dOm_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2dOm_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl2dOm_arrs[...,ll]/Cl2dOm_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, $\\ell$=%d, $h_c^2/d\\Omega$' % (nn,ll))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc2dOm_A.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll2dOm_ss08=moll2dOm_ss08, moll2dOm_ss16=moll2dOm_ss16, moll2dOm_ss32=moll2dOm_ss32, moll2dOm_ss64=moll2dOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# moll2dOm_bg08=moll2dOm_bg08, moll2dOm_bg16=moll2dOm_bg16, moll2dOm_bg32=moll2dOm_bg32, moll2dOm_bg64=moll2dOm_bg64,# moll_bg128=moll_bg128,\n", + "# moll2dOm_tt08=moll2dOm_tt08, moll2dOm_tt16=moll2dOm_tt16, moll2dOm_tt32=moll2dOm_tt32, moll2dOm_tt64=moll2dOm_tt64, #moll_tt128=moll_tt128,\n", + "# Cl2dOm_arrs=Cl2dOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 3bd84dca9404b3bfe2e6580f182e0a11d2be60e2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 21:02:39 -0700 Subject: [PATCH 062/291] Improved clear single source plot in take6_clearplot.ipynb. --- .../take6_clearplots.ipynb | 50 +++++++++++++++++-- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb b/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb index ca41fcdd..e67d9153 100644 --- a/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb +++ b/ecg-notebooks/parameter_investigation/take6_clearplots.ipynb @@ -168,17 +168,17 @@ " ax.plot(xx, np.median(yy_bg[ii], axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", " for pp in [50, 98]:\n", " conf = np.percentile(yy_bg[ii], [50-pp/2, 50+pp/2], axis=-1)\n", - " ax.fill_between(xx, *conf, color=color_bg, alpha=0.1)\n", + " ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", " \n", " for ii, ax in enumerate(axs[:,1]): # second columns, bg median and ss\n", " ax.plot(xx, np.median(yy_bg[ii], axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", " # all loudest, small and very transparent\n", - " ax.scatter(xx_ss.flatten(), yy_ss[ii].flatten(), color=color_ss, alpha=0.1, s=1)\n", - " # # single loudest of any realization\n", - " # ax.scatter(xx_ss[...,0].flatten(), yy_ss[ii,:,:,0].flatten(), color=color_ss, edgecolor='k', alpha=0.1, s=2)\n", + " # ax.scatter(xx_ss.flatten(), yy_ss[ii].flatten(), color=color_ss, alpha=0.1, s=5)\n", + " # single loudest of any realization\n", + " ax.scatter(xx_ss[...,0].flatten(), yy_ss[ii,:,:,0].flatten(), color=color_ss, alpha=0.1, s=15)\n", " # median loudest of all realizations, with errorbars\n", " ax.errorbar(xx, np.median(yy_ss[ii,:,:,0], axis=-1), yerr=np.std(yy_ss[ii,:,:,0], axis=-1),\n", - " color=color_ss, alpha=0.25, markersize=15)\n", + " color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", " ax.sharey(axs[ii,0])\n", "\n", "\n", @@ -248,6 +248,14 @@ " npz['target_param'],)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "'gsmf_phi0'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -260,6 +268,14 @@ " npz['target_param'],)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "'gsmf_mchar0_log10'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -272,6 +288,14 @@ " npz['target_param'],)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "'mmb_mamp_log10'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -284,6 +308,14 @@ " npz['target_param'],)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "'mmb_scatter_dex'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -296,6 +328,14 @@ " npz['target_param'],)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "'hard_gamma_inner'" + ] + }, { "cell_type": "code", "execution_count": null, From 11ba0364637fc823ec78f8453f16a052b69be61a Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 14 Jun 2023 22:36:00 -0700 Subject: [PATCH 063/291] Made cleaner param plots for all varying astro params in take7_gwb_anatomy_from_saved.ipynb. --- ...take5_gwb_anatomy_fullshape_normpars.ipynb | 13 +- .../take7_gwb_anatomy_fromsaved.ipynb | 825 ++++++++++++++++++ 2 files changed, 836 insertions(+), 2 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/take7_gwb_anatomy_fromsaved.ipynb diff --git a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb index 5132ed16..8ee5b46b 100644 --- a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb +++ b/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb @@ -683,7 +683,7 @@ "metadata": {}, "outputs": [], "source": [ - "save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_rv_fullshape'" + "save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape'" ] }, { @@ -936,14 +936,23 @@ "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 0" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ + "pars = np.array([0.0,0.5,0.5,0.5,0.5,0.5])\n", "rv_hard_gamma_inner_hard0 = vary_parameter('hard_gamma_inner', save_dir=save_dir,\n", - " pars=[0.0,0.5,0.5,0.5,0.5,0.5]) \n", + " pars=pars) \n", "fig = draw_three_models(*rv_hard_gamma_inner_hard0)\n", "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0)" ] diff --git a/ecg-notebooks/parameter_investigation/take7_gwb_anatomy_fromsaved.ipynb b/ecg-notebooks/parameter_investigation/take7_gwb_anatomy_fromsaved.ipynb new file mode 100644 index 00000000..40e5c0e2 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take7_gwb_anatomy_fromsaved.ipynb @@ -0,0 +1,825 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get PSpace Info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz_hard_time = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "print(npz_hard_time.files)\n", + "SHAPE = npz_hard_time['shape']\n", + "\n", + "npz_hard_time.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "print(param_names)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Detstats Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 50\n", + "SIGMA = 3.55e-6\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "def detect_pspace_model(data, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plotting Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "draw_par_vs_freq" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(\n", + " ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, ls_bg='-',\n", + " show_bg_median=True, show_bg_ci=True, \n", + " show_ss_err=True, show_ss_reals=True):\n", + "\n", + " if show_bg_median:\n", + " ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", + " if show_bg_ci:\n", + " for pp in [50, 98]:\n", + " conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1)\n", + " ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", + " if show_ss_err:\n", + " ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1),\n", + " color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", + " if show_ss_reals:\n", + " ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20)\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 Plot-Three Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg,)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def plot_three_models(\n", + " data, params, hard_name, shape, target_param, filename,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(dat)\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def plot_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param, filename,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(9,4)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 Vary Parameters!!!!!!!" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_time'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_rv_fullshape'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_hard_time = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "# rv_hard_time = vary_parameter('hard_time', save_dir=save_dir) # save for later so we don't have to recalculate, if \n", + "fig = draw_three_models(*rv_hard_time)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_gsmf_phi0 = vary_parameter('gsmf_phi0', save_dir=save_dir)\n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_phi0_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_phi0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# pars = 0.5 * np.ones(num_pars) \n", + "# pars[0] = 0.0 \n", + "# rv_gsmf_phi0_hard0 = vary_parameter('gsmf_phi0', pars=pars, save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_phi0_p0.__0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_phi0_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_gsmf_phi0_hard0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# pars = 0.5 * np.ones(num_pars) \n", + "# pars[0] = 1.0 \n", + "# rv_gsmf_phi0_hard1 = vary_parameter('gsmf_phi0', pars=pars, save_dir=save_dir) \n", + "\n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_phi0_p1.__0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_phi0_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_gsmf_phi0_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard1)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_mchar0_log10_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_mchar0_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', \n", + "# pars=[0,0.5,0.5,0.5,0.5,0.5], save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_mchar0_log10_p0,_0.5,_0.5,_0.5,_0.5,_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_mchar0_log10_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10_hard0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', \n", + "# pars=[1.0,0.5,0.5,0.5,0.5,0.5], save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/gsmf_mchar0_log10_p1.0,_0.5,_0.5,_0.5,_0.5,_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_mchar0_log10_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard1)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/mmb_mamp_log10_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_mmb_mamp_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_mmb_mamp_log10_hard1 = vary_parameter('mmb_mamp_log10',\n", + " # pars=[1.0,0.5,0.5,0.5,0.5,0.5], save_dir=save_dir)\n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/mmb_mamp_log10_p1.0,_0.5,_0.5,_0.5,_0.5,_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_mmb_mamp_log10_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + " \n", + "fig = draw_three_models(*rv_mmb_mamp_log10_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/mmb_scatter_dex_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_mmb_scatter_dex = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_mmb_scatter_dex_hard1 = vary_parameter('mmb_scatter_dex', save_dir=save_dir,\n", + "# pars=[1.0, 0.5, 0.5, 0.5, 0.5, 0.5]) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/mmb_scatter_dex_p1.0,_0.5,_0.5,_0.5,_0.5,_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_mmb_scatter_dex_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_mmb_scatter_dex_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'hard_gamma_inner'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_hard_gamma_inner = vary_parameter('hard_gamma_inner', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_gamma_inner_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_hard_gamma_inner = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_hard_gamma_inner)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "hard_time 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_hard_gamma_inner_hard1 = vary_parameter('hard_gamma_inner', save_dir=save_dir,\n", + "# pars=[1.0,0.5,0.5,0.5,0.5,0.5]) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_gamma_inner_p1.0,_0.5,_0.5,_0.5,_0.5,_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_hard_gamma_inner_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_hard_gamma_inner_hard1)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_hard_gamma_inner_hard0 = vary_parameter('hard_gamma_inner', save_dir=save_dir,\n", + "# pars=[0.0,0.5,0.5,0.5,0.5,0.5]) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_gamma_inner_p0.__0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_hard_gamma_inner_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = draw_three_models(*rv_hard_gamma_inner_hard0)\n", + "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 36cd455dbaebd9975ce6219f798a4ba5265a4bff Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 15 Jun 2023 16:44:47 -0700 Subject: [PATCH 064/291] Corrected healpix_map function in anisotropy.py and moved old function to healpix_map_oldhc2. --- holodeck/anisotropy.py | 56 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index 291a5b84..d6b992c6 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -19,6 +19,7 @@ LMAX = 8 HC_REF15_10YR = 11.2*10**-15 + def healpix_map(hc_ss, hc_bg, nside=NSIDE): """ Build mollview array of hc^2/dOmega for a healpix map @@ -40,6 +41,45 @@ def healpix_map(hc_ss, hc_bg, nside=NSIDE): """ npix = hp.nside2npix(nside) + area = hp.nside2pixarea(nside) + nfreqs = len(hc_ss) + nreals = len(hc_ss[0]) + nloudest = len(hc_ss[0,0]) + + # spread background evenly across pixels in moll_hc + moll_hc = np.ones((nfreqs,nreals,npix)) * hc_bg[:,:,np.newaxis]**2/(npix/area) # (frequency, realization, pixel) + + # choose random pixels to place the single sources + pix_ss = np.random.randint(0, npix-1, size=nfreqs*nreals*nloudest).reshape(nfreqs, nreals, nloudest) + for ff in range(nfreqs): + for rr in range(nreals): + for ll in range(nloudest): + moll_hc[ff,rr,pix_ss[ff,rr,ll]] = (moll_hc[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2/area) + + return moll_hc + +def healpix_map_oldhc2(hc_ss, hc_bg, nside=NSIDE): + """ Build mollview array of hc^2/dOmega for a healpix map + + Parameters + ---------- + hc_ss : (F,R,L) NDarray + Characteristic strain of single sources. + hc_bg : (F,R) NDarray + Characteristic strain of the background. + nside : integer + number of sides for healpix map. + + Returns + ------- + moll_hc : (NPIX,) 1Darray + Array of h_c^2 at every pixel for a mollview healpix map. + + NOTE: Could speed up the for-loops, but it's ok for now. + """ + + npix = hp.nside2npix(nside) + area = hp.nside2pixarea(nside) nfreqs = len(hc_ss) nreals = len(hc_ss[0]) nloudest = len(hc_ss[0,0]) @@ -563,22 +603,22 @@ def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 a ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle='dashdot', alpha=alpha) def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization', - show_ci=False, show_reals=True, show_median=False, nshow=10): + show_ci=False, show_reals=True, show_median=False, nshow=10, lw_median=2, ls_reals = ':'): xx = fobs_gw_cents yy = Cl_many/C0_many # (F,R) if show_median: - ax.plot(xx, np.median(yy[:,:], axis=-1), color=color) #, label='median of samples, $l=%d$' % ll) + ax.plot(xx, np.median(yy[:,:], axis=-1), color=color, lw=lw_median, alpha=0.75) #, label='median of samples, $l=%d$' % ll) if show_ci: for pp in [50, 98]: percs = pp/2 percs = [50-percs, 50+percs] - ax.fill_between(xx, *np.percentile(yy[:,:], percs, axis=-1), color=color, alpha=0.1) + ax.fill_between(xx, *np.percentile(yy[:,:], percs, axis=-1), color=color, alpha=0.15) if show_reals: rr = 0 - ax.plot(xx, yy[:,rr], color=color, alpha=0.15, linestyle='-', + ax.plot(xx, yy[:,rr], color=color, alpha=0.15, linestyle=ls_reals, label = label) for rr in range(1, np.min([nshow, len(Cl_many[0])])): - ax.plot(xx, yy[:,rr], color=color, alpha=0.25, linestyle='-') + ax.plot(xx, yy[:,rr], color=color, alpha=0.15, linestyle=ls_reals) def draw_spk(ax, label='SP & K Rough Estimate'): spk_xx= np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7]) /YR @@ -586,16 +626,16 @@ def draw_spk(ax, label='SP & K Rough Estimate'): ax.plot(spk_xx * YR, spk_yy, label=label, color='limegreen', ls='--') def draw_bayes(ax, lmax, colors = ['k', 'b', 'r', 'g', 'c', 'm']): - xx_Nihan = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz + xx_nihan = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz - Cl_nihan = np.array([ + ClC0_nihan = np.array([ [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427], [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662], [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785], [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331], [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]]) for ll in range(lmax): - ax.plot(xx_Nihan, Cl_nihan[:,ll]/Cl_nihan[:,0], + ax.plot(xx_nihan, ClC0_nihan[:,ll], label = '$l=%d$' % (ll+1), color=colors[ll], marker='o', ms=8) From 80f307038cf20611546f533c4febd5cc21d9c034 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 15 Jun 2023 16:46:43 -0700 Subject: [PATCH 065/291] Anisotropy using hc^2/dOmega and compared to analytic healpy calculation in vn2_ClC0_eqs.ipynb. --- .../anisotropy/an3_anisotropy_methods.ipynb | 291 ++++++- .../anisotropy/healpix/vn2_ClC0_eqs.ipynb | 468 ++++++++++++ .../hc2dOm_awg_07B_l5_plots_ns08.ipynb | 682 +++++++++++++++++ .../hc2dOm_paper_plots_ns08.ipynb | 10 +- .../hc2dOm_paper_plots_ns32.ipynb | 109 ++- .../hc2dOm_ss18_02B_l1000_plots_ns08.ipynb | 650 ++++++++++++++++ ...c2dOm_ss19_05A_l2000_plots_ns08 copy.ipynb | 708 ++++++++++++++++++ .../oldhc_anisotropy_paper_plots.ipynb | 0 .../oldhc_paper_plots_nside8.ipynb | 0 9 files changed, 2886 insertions(+), 32 deletions(-) create mode 100644 ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb create mode 100644 ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_awg_07B_l5_plots_ns08.ipynb rename ecg-notebooks/anisotropy/{ => plot-notebooks}/hc2dOm_paper_plots_ns08.ipynb (99%) rename ecg-notebooks/anisotropy/{ => plot-notebooks}/hc2dOm_paper_plots_ns32.ipynb (85%) create mode 100644 ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss18_02B_l1000_plots_ns08.ipynb create mode 100644 ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss19_05A_l2000_plots_ns08 copy.ipynb rename ecg-notebooks/anisotropy/{ => plot-notebooks}/oldhc_anisotropy_paper_plots.ipynb (100%) rename ecg-notebooks/anisotropy/{ => plot-notebooks}/oldhc_paper_plots_nside8.ipynb (100%) diff --git a/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb index a4a4906a..24daa107 100644 --- a/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb @@ -619,6 +619,44 @@ " C0_priz, Cl_priz = anis.Cl_analytic_from_dnum(edges, diff_num, sam._redz_prime[...,np.newaxis])\n", " C0_pzreals, Cl_pzreals = anis.Cl_analytic_from_dnum(edges, diff_num, sam._redz_prime[...,np.newaxis], realize=10)\n", "\n", + " vals = {\n", + " 'sam':sam, 'hard':hard, 'edges':edges, 'redz_final':redz_final, 'diff_num':diff_num, 'hs':hs, 'hard_name':hard_name,\n", + " 'cynum':cynum, 'C0_cynum':C0_cynum, 'Cl_cynum':Cl_cynum, 'C0_cyreals':C0_cyreals, 'Cl_cyreals':Cl_cyreals, \n", + " 'flnum':flnum, 'C0_flnum':C0_flnum, 'Cl_flnum':Cl_flnum,\n", + " 'C0_init':C0_init, 'Cl_init':Cl_init, 'C0_inreals':C0_inreals, 'Cl_inreals':Cl_inreals,\n", + " 'C0_redz':C0_redz, 'Cl_redz':Cl_redz, 'C0_rzreals':C0_rzreals, 'Cl_rzreals':Cl_rzreals,\n", + " 'C0_priz':C0_priz, 'Cl_priz':Cl_priz, 'C0_pzreals':C0_pzreals, 'Cl_pzreals':Cl_pzreals,\n", + "\n", + " }\n", + " fig = plot_all_analytic_anis(vals)\n", + " return fig, vals\n", + "\n", + "def plot_all_analytic_anis(vals, show_leg=True):\n", + " Cl_cynum=vals['Cl_cynum']\n", + " C0_cynum=vals['C0_cynum']\n", + " Cl_cyreals=vals['Cl_cyreals']\n", + " C0_cyreals=vals['C0_cyreals']\n", + "\n", + " Cl_flnum=vals['Cl_flnum']\n", + " C0_flnum=vals['C0_flnum']\n", + " \n", + " Cl_init=vals['Cl_init']\n", + " C0_init=vals['C0_init']\n", + " Cl_inreals=vals['Cl_inreals']\n", + " C0_inreals=vals['C0_inreals']\n", + "\n", + " Cl_redz=vals['Cl_redz']\n", + " C0_redz=vals['C0_redz']\n", + " Cl_rzreals=vals['Cl_rzreals']\n", + " C0_rzreals=vals['C0_rzreals']\n", + "\n", + " Cl_priz=vals['Cl_priz']\n", + " C0_priz=vals['C0_priz']\n", + " Cl_pzreals=vals['Cl_pzreals']\n", + " C0_pzreals=vals['C0_pzreals']\n", + "\n", + " hard_name = vals['hard_name']\n", + "\n", " # plot everything\n", " print('plotting')\n", " fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", @@ -641,22 +679,13 @@ " anis.draw_analytic(ax, Cl_priz, C0_priz, fobs_gw_cents, label='dnum, z_prime', color='darkmagenta', lw=4)\n", " anis.draw_reals(ax, Cl_pzreals, C0_pzreals, fobs_gw_cents, label=None, color='darkmagenta')\n", "\n", - " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", + " if show_leg:\n", + " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", " ax.set_title('%s, %s' % ( str(hard_name), str(sam.shape)), fontsize=12)\n", "\n", " fig.tight_layout()\n", "\n", - "\n", - " vals = {\n", - " 'sam':sam, 'hard':hard, 'edges':edges, 'redz_final':redz_final, 'diff_num':diff_num, 'hs':hs,\n", - " 'cynum':cynum, 'C0_cynum':C0_cynum, 'Cl_cynum':Cl_cynum, 'C0_cyreals':C0_cyreals, 'Cl_cyreals':Cl_cyreals, \n", - " 'flnum':flnum, 'C0_flnum':C0_flnum, 'Cl_flnum':Cl_flnum,\n", - " 'C0_init':C0_init, 'Cl_init':Cl_init, 'C0_inreals':C0_inreals, 'Cl_inreals':Cl_inreals,\n", - " 'C0_redz':C0_redz, 'Cl_redz':Cl_redz, 'C0_rzreals':C0_rzreals, 'Cl_rzreals':Cl_rzreals,\n", - " 'C0_priz':C0_priz, 'Cl_priz':Cl_priz, 'C0_pzreals':C0_pzreals, 'Cl_pzreals':Cl_pzreals,\n", - "\n", - " }\n", - " return fig, vals" + " return fig" ] }, { @@ -1161,26 +1190,258 @@ "Because, in Cl_analytic_from_num we take np.random after multiplying by d/dlnf, whereas in Cl_analytic_from_dnum, we are doing an extra *dif(log(fobs)) that we shouldn't be doing!! Note: both actually do use the cython number because it's faster than integrating dnum inside the function, so they are literally the exact same and should give the same results." ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add simulation results" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = file1['nsort']\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best']\n", + "Cl_best1 = file1['Cl_best']\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n", + "# load map and harmonics from 2nd split chunk\n", + "file2 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz')\n", + "moll_hc_best2 = file2['moll_hc_best']\n", + "Cl_best2 = file2['Cl_best']\n", + "nbest2 = len(moll_hc_best2)\n", + "file2.close()\n", + "\n", + "\n", + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" + ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")\n", + "print(f\"{Cl_best.shape=}, {moll_hc_best.shape=}\")" + ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "print(Cl_best.shape)\n", + "print(vals['C0_cyreals'].shape)\n", + "C0_hp = np.median(Cl_best[...,0], axis=-1)\n", + "C0_hp = np.swapaxes(C0_hp, 0,1)\n", + "\n", + "Cl_hp = np.median(Cl_best[...,1], axis=-1)\n", + "Cl_hp = np.swapaxes(Cl_hp, 0,1)\n", + "print(Cl_hp.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_all_analytic_anis(vals, show_leg=True):\n", + " Cl_cynum=vals['Cl_cynum']\n", + " C0_cynum=vals['C0_cynum']\n", + " Cl_cyreals=vals['Cl_cyreals']\n", + " C0_cyreals=vals['C0_cyreals']\n", + "\n", + " Cl_flnum=vals['Cl_flnum']\n", + " C0_flnum=vals['C0_flnum']\n", + " \n", + " Cl_init=vals['Cl_init']\n", + " C0_init=vals['C0_init']\n", + " Cl_inreals=vals['Cl_inreals']\n", + " C0_inreals=vals['C0_inreals']\n", + "\n", + " Cl_redz=vals['Cl_redz']\n", + " C0_redz=vals['C0_redz']\n", + " Cl_rzreals=vals['Cl_rzreals']\n", + " C0_rzreals=vals['C0_rzreals']\n", + "\n", + " Cl_priz=vals['Cl_priz']\n", + " C0_priz=vals['C0_priz']\n", + " Cl_pzreals=vals['Cl_pzreals']\n", + " C0_pzreals=vals['C0_pzreals']\n", + "\n", + " hard_name = vals['hard_name']\n", + "\n", + " # plot everything\n", + " print('plotting')\n", + " fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + " ax = fig.axes[0]\n", + "\n", + "\n", + " anis.draw_reals(ax, Cl_hp, C0_hp, fobs, color='k',\n", + " show_reals=True, show_median=True, show_ci=True, lw_median=3, ls_reals=':',\n", + " nshow=40)\n", + "\n", + " anis.draw_analytic(ax, Cl_cynum, C0_cynum, fobs_gw_cents, color='tab:orange', label='cython number', lw=4)\n", + " # anis.draw_reals(ax, Cl_cyreals, C0_cyreals, fobs_gw_cents, color='tab:orange', label=None,\n", + " # show_reals=True, show_median=True, show_ci=True, lw_median=3)\n", + "\n", + " anis.draw_analytic(ax, Cl_flnum, C0_flnum, fobs_gw_cents, color='tab:red', label='rounded number', lw=4)\n", + " # anis.draw_reals(ax, Cl_utreals, C0_utreals, fobs_gw_cents, color='tab:red', label=None,\n", + " # show_reals=True, show_median=True, show_ci=True)\n", + "\n", + " anis.draw_analytic(ax, Cl_init, C0_init, fobs_gw_cents, label='dnum, z_init', color='deeppink', lw=4)\n", + " anis.draw_reals(ax, Cl_inreals, C0_inreals, fobs_gw_cents, label=None, color='deeppink',\n", + " show_reals=True, show_median=True, show_ci=True, lw_median=3)\n", + "\n", + " anis.draw_analytic(ax, Cl_redz, C0_redz, fobs_gw_cents, label='dnum, z_final', color='indigo', lw=4)\n", + " anis.draw_reals(ax, Cl_rzreals, C0_rzreals, fobs_gw_cents, label=None, color='indigo',\n", + " show_reals=True, show_median=True, show_ci=True, lw_median=3)\n", + "\n", + " # anis.draw_analytic(ax, Cl_priz, C0_priz, fobs_gw_cents, label='dnum, z_prime', color='darkmagenta', lw=4)\n", + " # anis.draw_reals(ax, Cl_pzreals, C0_pzreals, fobs_gw_cents, label=None, color='darkmagenta',\n", + " # show_reals=True, show_median=True, show_ci=True, lw_median=3)\n", + "\n", + " if show_leg:\n", + " fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", + " ax.set_title('%s, %s' % ( str(hard_name), str(sam.shape)), fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + "\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sim(ax, xx, Cl_best, lmax, nshow=20):\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(0,1):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color='k', label='healpy', lw=3, alpha=0.5) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [68]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.2, color='k')\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color='k', linestyle=':', alpha=0.2,\n", + " linewidth=1, label=label)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_all_analytic_anis(vals_FT9181100, show_leg=False)\n", + "ax = fig.axes[0]\n", + "ax.set_ylim(10**-5, 10**0.1)\n", + "draw_sim(ax, xx=fobs, Cl_best=Cl_best, lmax=6, nshow=10)\n", + "fig.legend(bbox_to_anchor=(0,-0.15), loc='upper left', bbox_transform = ax.transAxes, ncols=4)\n", + "fig.tight_layout()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nshow=10\n", + "\n", + "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + "ax = fig.axes[0]\n", + "ax.set_ylim(10**-5, 10**0.1)\n", + "draw_sim(ax, xx=fobs, Cl_best=Cl_best, lmax=6, nshow=nshow)\n", + "fig.text(0,0.95, 'nshow=%d' % nshow)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nshow=25\n", + "\n", + "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + "ax = fig.axes[0]\n", + "ax.set_ylim(10**-5, 10**0.1)\n", + "draw_sim(ax, xx=fobs, Cl_best=Cl_best, lmax=6, nshow=nshow)\n", + "fig.text(0,0.95, 'nshow=%d' % nshow)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nshow=50\n", + "\n", + "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + "ax = fig.axes[0]\n", + "ax.set_ylim(10**-5, 10**0.1)\n", + "draw_sim(ax, xx=fobs, Cl_best=Cl_best, lmax=6, nshow=nshow)\n", + "fig.text(0,0.95, 'nshow=%d' % nshow)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nshow=100\n", + "\n", + "fig = anis.plot_ClC0_versions(fobs_gw_cents)\n", + "ax = fig.axes[0]\n", + "ax.set_ylim(10**-5, 10**0.1)\n", + "draw_sim(ax, xx=fobs, Cl_best=Cl_best, lmax=6, nshow=nshow)\n", + "fig.text(0,0.95, 'nshow=%d' % nshow)\n" + ] }, { "cell_type": "code", diff --git a/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb b/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb new file mode 100644 index 00000000..d1970ac3 --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb @@ -0,0 +1,468 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import scipy as sp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import cmath" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Read in sam data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=346\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", + "fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape=hc_ss.shape\n", + "nfreqs = shape[-3]\n", + "nreals = shape[-2]\n", + "nloudest = shape[-1]\n", + "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Spherical Harmonic Functions\n", + "$$ a_\\ell^m = \\frac{4\\pi}{N} \\sum_{i=1}^N \\bar{Y_\\ell}^m (\\lambda_i, \\theta_i)f(\\lambda_i, \\theta_i) $$\n", + "$0 \\leq \\ell \\leq \\ell_\\mathrm{max}$, $-\\ell \\leq m \\leq \\ell $\n", + "For real harmonics only, $m=0$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def calc_alm(ell, emm, func, nside):\n", + " \"\"\" \n", + " \n", + " func : \n", + " function of ipix or theta,phi\n", + " \"\"\"\n", + " npix = hp.nside2npix(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " Ylm = sp.special.sph_harm(emm, ell, theta, phi)\n", + " integrand = np.sum(np.conjugate(Ylm) * func)\n", + " alm = 4*np.pi/npix * integrand\n", + " return alm\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$C_\\ell = \\frac{1}{2\\ell+1} \\sum_m |a_\\ell^m|^2$$" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def calc_Cl(ell, func, nside):\n", + " sum = 0\n", + " for emm in range(-ell, ell+1):\n", + " # print('l=%d, m=%d' % (ell, emm))\n", + " alm = calc_alm(ell, emm, func, nside)\n", + " sum += alm*np.conjugate(alm)\n", + " Cl = 1/(2*ell + 1) * sum\n", + " if Cl.imag != 0:\n", + " print(f\"warning! {Cl=} contains imaginary numbers\")\n", + " print(f\"{alm=}\")\n", + " return Cl\n", + " return Cl.real" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nside = 2\n", + "npix = hp.nside2npix(nside)\n", + "theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + "moll = anis.healpix_map(hc_ss[0:1,0:1], hc_bg[0:1,0:1], nside)\n", + "moll = np.squeeze(moll)\n", + "print(theta.shape)\n", + "print(phi.shape)\n", + "# print(theta,phi)\n", + "print(moll.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lmax = 6\n", + "Cl_arr = np.zeros(lmax+1)\n", + "for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside).real\n", + " print('C_%d = %.2e' % (ll, Cl_arr[ll]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "yy = Cl_arr\n", + "\n", + "# colors = cm.rainbow(np.linspace(0,1,yy))\n", + "\n", + "fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + "ax.plot(xx, yy)\n", + "ax.set_title('Analytic' )\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff = 1\n", + "rr = 0\n", + "\n", + "\n", + "nsides = np.array([4, 8, 16, 32, 64])\n", + "colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + "fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + "\n", + "for ii, nside in enumerate(nsides):\n", + " npix = hp.nside2npix(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " moll = anis.healpix_map(hc_ss[ff:ff+1,rr:rr+1], hc_bg[ff:ff+1,rr:rr+1], nside)\n", + " moll = np.squeeze(moll)\n", + "\n", + " lmax = 8\n", + " Cl_arr = np.zeros(lmax+1)\n", + " for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside).real\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + " xx = np.arange(lmax+1)\n", + " yy = Cl_arr\n", + " ax.plot(xx, yy, label = 'Drake Eqs. (1) & (3), nside=%d' % nside,\n", + " color=colors[ii])\n", + "\n", + "ax.legend()\n", + "ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + "fig.tight_layout()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "nsides = np.array([8, 16, 32, 64])\n", + "colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + "fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + "\n", + "for ii, nside in enumerate(nsides):\n", + " print('\\n nside=%d' % nside)\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " moll = anis.healpix_map_oldhc2(hc_ss[ff:ff+1,rr:rr+1], hc_bg[ff:ff+1,rr:rr+1], nside)\n", + " moll = moll/area\n", + "\n", + " lmax = 8\n", + " Cl_arr = np.zeros(lmax+1)\n", + " for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside).real\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + " xx = np.arange(lmax+1)\n", + " yy = Cl_arr\n", + " ax.plot(xx, yy, label = 'From Eq. (3), nside=%d' % nside,\n", + " color=colors[ii])\n", + "ax.legend()\n", + "ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + "fig.tight_layout()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Compare to healpy results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc2dOm_A.npz')\n", + "print(hcfile.files)\n", + "Cl2dOm_arrs = hcfile['Cl2dOm_arrs']\n", + "moll_arrs = [hcfile['moll2dOm_ss08'], hcfile['moll2dOm_tt16'], \n", + " hcfile['moll2dOm_tt32'], hcfile['moll2dOm_tt64']]\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "print(Cl2dOm_arrs.shape)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(moll_arrs[0].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff = 1\n", + "rr = 0\n", + "lmax=6\n", + "xx = np.arange(lmax+1)\n", + "\n", + "nsides = np.array([8, 16, 32, 64])\n", + "colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + "fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + "\n", + "for ii, nside in enumerate(nsides):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " # moll = anis.healpix_map(hc_ss[ff:ff+1,rr:rr+1], hc_bg[ff:ff+1,rr:rr+1], nside)\n", + " # moll = np.squeeze(moll)\n", + " moll = moll_arrs[ii][ff,rr]\n", + "\n", + " Cl_arr = np.zeros(lmax+1)\n", + " Cl_hpy = hp.anafast(moll, lmax=lmax)\n", + " for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside)\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + "\n", + " yy = Cl_arr\n", + " ax.plot(xx, yy, label = 'From Eq. (3), nside=%d' % nside,\n", + " color=colors[ii])\n", + " # ax.plot(xx, Cl2dOm_arrs[ii,ff,rr,:], color=colors[ii], linestyle=':',\n", + " # label=('hp.anafast, nside=%d' % (nside)))\n", + " ax.plot(xx, Cl_hpy[:], color=colors[ii], linestyle=':',\n", + " label=('hp.anafast, nside=%d' % (nside)))\n", + "\n", + "ax.legend()\n", + "ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + "fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# ClC0 Comparison" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff = 1\n", + "rr = 0\n", + "lmax=6\n", + "xx = np.arange(1,lmax+1)\n", + "\n", + "nsides = np.array([8, 16, 32, 64])\n", + "colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + "fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell/C_0$', xscale='linear')\n", + "\n", + "for ii, nside in enumerate(nsides):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " moll = moll_arrs[ii][ff,rr]\n", + "\n", + " Cl_arr = np.zeros(lmax+1)\n", + " Cl_hpy = hp.anafast(moll, lmax=lmax)\n", + " for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside)\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + "\n", + " y1 = Cl_arr[1:]/Cl_arr[0]\n", + " y2 = Cl_hpy[1:]/Cl_hpy[0]\n", + " ax.plot(xx, y1, label = 'From Eq. (3), nside=%d' % nside,\n", + " color=colors[ii])\n", + " # ax.plot(xx, Cl2dOm_arrs[ii,ff,rr,:], color=colors[ii], linestyle=':',\n", + " # label=('hp.anafast, nside=%d' % (nside)))\n", + " ax.plot(xx, y2, color=colors[ii], linestyle=':',\n", + " label=('hp.anafast, nside=%d' % (nside)))\n", + "\n", + "ax.legend()\n", + "ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + "fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "alm values" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff = 1\n", + "rr = 0\n", + "mm = 0\n", + "lmax=6\n", + "\n", + "nsides = np.array([8, 16, 32, 64])\n", + "colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + "fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + "\n", + "for ii, nside in enumerate(nsides):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " moll = anis.healpix_map(hc_ss[ff:ff+1,rr:rr+1], hc_bg[ff:ff+1,rr:rr+1], nside)\n", + " moll = np.squeeze(moll)**2/area\n", + "\n", + " lmax = 6\n", + " xx = np.arange(lmax+1)\n", + "\n", + " for ll in range(lmax+1):\n", + " emm_arr = np.arange(-lmax, lmax+1)\n", + " print(f\"{emm_arr}\")\n", + " for mm, emm in enumerate(emm_arr):\n", + " alm_arr = np.zeros(len(emm_arr))\n", + " alm_arr[mm] = calc_alm(ll, emm, moll, nside)\n", + " ax.scatter(xx[ll], alm_arr[mm])\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + " # yy = alm_arr\n", + " # ax.scatter(xx, yy, label = '$a_\\ell^m$, nside=%d, $m$=%d' % (nside,mm),\n", + " # color=colors[ii])\n", + "for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, Cl2dOm_arrs[ii,ff,rr,:], color=colors[ii], linestyle=':',\n", + " label=('hp.anafast, nside=%d' % (nside)))\n", + "\n", + "ax.legend()\n", + "ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + "fig.tight_layout()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_awg_07B_l5_plots_ns08.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_awg_07B_l5_plots_ns08.ipynb new file mode 100644 index 00000000..b193a60a --- /dev/null +++ b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_awg_07B_l5_plots_ns08.ipynb @@ -0,0 +1,682 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up\n", + "\n", + "## Read in library\n", + "\n", + "ss16 has 10 loudest, definitely will replace this with a better library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "# hdfname = sspath+'/sam_lib.hdf5'\n", + "# ssfile = h5py.File(hdfname, 'r')\n", + "# print(list(ssfile.keys()))\n", + "# hc_ss = ssfile['hc_ss'][...]\n", + "# hc_bg = ssfile['hc_bg'][...]\n", + "# fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "# ssfile.close()\n", + "\n", + "# shape = hc_ss.shape\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Find Best Samples" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# hc_ref15_10yr = 11.2*10**-15 \n", + "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# nbest = 100\n", + "# print(hc_ref15)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load and concatenate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/awg_output/2023-05-18-awg-sam01_uniform07B_n1000_r1000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = file1['nsort']\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best']\n", + "Cl_best1 = file1['Cl_best']\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n", + "# load map and harmonics from 2nd split chunk\n", + "file2 = np.load('/Users/emigardiner/GWs/holodeck/output/awg_output/2023-05-18-awg-sam01_uniform07B_n1000_r1000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz')\n", + "moll_hc_best2 = file2['moll_hc_best']\n", + "Cl_best2 = file2['Cl_best']\n", + "nbest2 = len(moll_hc_best2)\n", + "file2.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")\n", + "print(f\"{Cl_best.shape=}, {moll_hc_best.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.where(Cl_best[:,0,0,0]==0))\n", + "print(np.where(Cl_best1[:,0,0,0]==0))\n", + "print(np.where(Cl_best2[:,0,0,0]==0))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(np.arange(len(Cl_best)), Cl_best[:,0,0,0])\n", + "plt.ylim(0,0.1e-58)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "print(holo.utils.stats(Cl_best1))\n", + "print(holo.utils.stats(Cl_best2))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)\n", + "print(holo.utils.stats(Cl_best))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = cm.gist_rainbow(np.linspace(0, 1, lmax))\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll], label='$l=%d$' % (ll+1))\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1) \n", + " ax.legend(ncols=2)\n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def plot_Clg0_llp1_medians(xx, Cl_best, lmax, nshow):\n", + "# fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + "# yy = np.sum(Cl_best[:,:,:,1:], axis=-1)/Cl_best[:,:,:,0,] # (B,F,R)\n", + "# yy = np.median(yy, axis=-1) # (B,F) median over realizations\n", + "\n", + "# ax.plot(xx, np.median(yy, axis=0), color='k', label='median of samples, $l_\\mathrm{max}=%d$' % lmax)\n", + "# for pp in [50, 98]:\n", + "# percs = pp/2\n", + "# percs = [50-percs, 50+percs]\n", + "# ax.fill_between(xx, *np.percentile(yy, percs, axis=0), alpha=0.1, color='k')\n", + "\n", + "# colors = cm.rainbow(np.linspace(1, 0, nshow))\n", + "# bb=0\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1, label=\"individual best samples, median of realizations\")\n", + "# for bb in range(1,nshow):\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1)\n", + "# ax.legend()\n", + "# plot._twin_hz(ax, nano=False)\n", + " \n", + "# # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + "# # % (nbest, lmax))\n", + "# return fig\n", + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d, awg-sam01, l=5, uniform07B, 100 best out of 1000 samples' % nside)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=100)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# for ll in range(len(Cl_nihan[0])):\n", + " \n", + "\n", + "# ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# # ax.set_xscale('linear')\n", + "# fig.legend(loc='lower right')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# # ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# ax.legend(loc='lower right')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Sato-Polito & Kamionkowski" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "ax = fig.axes[0]\n", + "\n", + "xx = freq_bins_Hz * YR \n", + "ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='tab:orange')\n", + "ax.set_xlim(0, np.max(fobs_yrs))\n", + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "hdfname = sspath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "print('Best sample:', nsort[0])\n", + "hc_ss = ssfile['hc_ss'][nsort[0],...]\n", + "hc_bg = ssfile['hc_bg'][nsort[0],...]\n", + "fobs = ssfile['fobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape = hc_ss.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "print('F,R,L =', nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Scratch" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "split=7\n", + "nbest=100\n", + "for ss in range(split):\n", + " bestrange = (np.array([ss, (ss+1)])*(nbest)/split).astype(int)\n", + " bestrange[1] = np.min([bestrange[1], nbest])\n", + " print(f\"{bestrange=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, nn in enumerate(range(bestrange[0], bestrange[1])):\n", + " print('on nn=%d out of nbest=%d, index=%d' % (nn,nbest, ii))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns08.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_paper_plots_ns08.ipynb similarity index 99% rename from ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns08.ipynb rename to ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_paper_plots_ns08.ipynb index 9dafaac6..a34b4428 100644 --- a/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns08.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_paper_plots_ns08.ipynb @@ -319,13 +319,13 @@ "# where each row represents the frequency bin from low to high (0 to 4) \n", "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", "# (F, l)\n", - "Cl_nihan = np.array([\n", + "ClC0_nihan = np.array([\n", " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", - "print(Cl_nihan.shape)\n", + "print(ClC0_nihan.shape)\n", "\n", "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" ] @@ -336,7 +336,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(Cl_nihan[:,0])" + "print(ClC0_nihan[:,0])" ] }, { @@ -345,7 +345,7 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, ClC0_nihan):\n", " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", "\n", " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", @@ -369,7 +369,7 @@ " linewidth=1, label=label)\n", " \n", " # Add Nihan's data\n", - " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " ax.plot(xx_Nihan, ClC0_nihan[:,ll], \n", " label = '$l=%d$' % (ll+1), \n", " color=colors[ll], marker='o', ms=8)\n", " \n", diff --git a/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns32.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_paper_plots_ns32.ipynb similarity index 85% rename from ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns32.ipynb rename to ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_paper_plots_ns32.ipynb index 4208cba0..4a712311 100644 --- a/ecg-notebooks/anisotropy/hc2dOm_paper_plots_ns32.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_paper_plots_ns32.ipynb @@ -124,9 +124,13 @@ "metadata": {}, "outputs": [], "source": [ - "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", - "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", - "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")" + "\n", + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" ] }, { @@ -135,13 +139,9 @@ "metadata": {}, "outputs": [], "source": [ - "\n", - "# concatenate Cl and moll_hc\n", - "nbest=nbest1+nbest2\n", - "print(nbest)\n", - "npix = hp.nside2npix(nside)\n", - "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", - "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")" ] }, { @@ -390,8 +390,93 @@ "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", "\n", - "fig.tight_layout()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians_big(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", "fig.text(0.05,1, 'nside=%d' % nside)\n", "fig.tight_layout()" ] diff --git a/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss18_02B_l1000_plots_ns08.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss18_02B_l1000_plots_ns08.ipynb new file mode 100644 index 00000000..7f1d0c6f --- /dev/null +++ b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss18_02B_l1000_plots_ns08.ipynb @@ -0,0 +1,650 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load and concatenate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss18_n100_r40_d15_f30_l1000_p0/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r40_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = file1['nsort']\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best']\n", + "Cl_best1 = file1['Cl_best']\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n", + "# load map and harmonics from 2nd split chunk\n", + "file2 = np.load('/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss18_n100_r40_d15_f30_l1000_p0/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r40_b50-99.npz')\n", + "moll_hc_best2 = file2['moll_hc_best']\n", + "Cl_best2 = file2['Cl_best']\n", + "nbest2 = len(moll_hc_best2)\n", + "file2.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")\n", + "print(f\"{Cl_best.shape=}, {moll_hc_best.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.where(Cl_best[:,0,0,0]==0))\n", + "print(np.where(Cl_best1[:,0,0,0]==0))\n", + "print(np.where(Cl_best2[:,0,0,0]==0))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(np.arange(len(Cl_best)), Cl_best[:,0,0,0])\n", + "plt.ylim(0,0.1e-58)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "print(holo.utils.stats(Cl_best1))\n", + "print(holo.utils.stats(Cl_best2))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)\n", + "print(holo.utils.stats(Cl_best))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = cm.gist_rainbow(np.linspace(0, 1, lmax))\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll], label='$l=%d$' % (ll+1))\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1) \n", + " ax.legend(ncols=2)\n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def plot_Clg0_llp1_medians(xx, Cl_best, lmax, nshow):\n", + "# fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + "# yy = np.sum(Cl_best[:,:,:,1:], axis=-1)/Cl_best[:,:,:,0,] # (B,F,R)\n", + "# yy = np.median(yy, axis=-1) # (B,F) median over realizations\n", + "\n", + "# ax.plot(xx, np.median(yy, axis=0), color='k', label='median of samples, $l_\\mathrm{max}=%d$' % lmax)\n", + "# for pp in [50, 98]:\n", + "# percs = pp/2\n", + "# percs = [50-percs, 50+percs]\n", + "# ax.fill_between(xx, *np.percentile(yy, percs, axis=0), alpha=0.1, color='k')\n", + "\n", + "# colors = cm.rainbow(np.linspace(1, 0, nshow))\n", + "# bb=0\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1, label=\"individual best samples, median of realizations\")\n", + "# for bb in range(1,nshow):\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1)\n", + "# ax.legend()\n", + "# plot._twin_hz(ax, nano=False)\n", + " \n", + "# # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + "# # % (nbest, lmax))\n", + "# return fig\n", + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d, mbp-ss18, l=1000, uniform02B, 100 best out of 100 samples' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best[:10], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, mbp-ss18, l=1000, uniform02B, 10 best out of 100 samples' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=100)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# for ll in range(len(Cl_nihan[0])):\n", + " \n", + "\n", + "# ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# # ax.set_xscale('linear')\n", + "# fig.legend(loc='lower right')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# # ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# ax.legend(loc='lower right')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Sato-Polito & Kamionkowski" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "ax = fig.axes[0]\n", + "\n", + "xx = freq_bins_Hz * YR \n", + "ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='tab:orange')\n", + "ax.set_xlim(0, np.max(fobs_yrs))\n", + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "hdfname = sspath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "print('Best sample:', nsort[0])\n", + "hc_ss = ssfile['hc_ss'][nsort[0],...]\n", + "hc_bg = ssfile['hc_bg'][nsort[0],...]\n", + "fobs = ssfile['fobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape = hc_ss.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "print('F,R,L =', nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Scratch" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "split=7\n", + "nbest=100\n", + "for ss in range(split):\n", + " bestrange = (np.array([ss, (ss+1)])*(nbest)/split).astype(int)\n", + " bestrange[1] = np.min([bestrange[1], nbest])\n", + " print(f\"{bestrange=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, nn in enumerate(range(bestrange[0], bestrange[1])):\n", + " print('on nn=%d out of nbest=%d, index=%d' % (nn,nbest, ii))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss19_05A_l2000_plots_ns08 copy.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss19_05A_l2000_plots_ns08 copy.ipynb new file mode 100644 index 00000000..1c6cc4f8 --- /dev/null +++ b/ecg-notebooks/anisotropy/plot-notebooks/hc2dOm_ss19_05A_l2000_plots_ns08 copy.ipynb @@ -0,0 +1,708 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Set Up\n", + "\n", + "## Read in library\n", + "\n", + "ss16 has 10 loudest, definitely will replace this with a better library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "# hdfname = sspath+'/sam_lib.hdf5'\n", + "# ssfile = h5py.File(hdfname, 'r')\n", + "# print(list(ssfile.keys()))\n", + "# hc_ss = ssfile['hc_ss'][...]\n", + "# hc_bg = ssfile['hc_bg'][...]\n", + "# fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "# ssfile.close()\n", + "\n", + "# shape = hc_ss.shape\n", + "# nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# print('N,F,R,L =', nsamps, nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Find Best Samples" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# hc_ref15_10yr = 11.2*10**-15 \n", + "# nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss, hc_bg, fobs, hc_ref=hc_ref15_10yr, ret_all=True)\n", + "# nbest = 100\n", + "# print(hc_ref15)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load and concatenate pixel strains and harmonic coefficients" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = file1['nsort']\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best']\n", + "Cl_best1 = file1['Cl_best']\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n", + "# load map and harmonics from 2nd split chunk\n", + "file2 = np.load('/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz')\n", + "moll_hc_best2 = file2['moll_hc_best']\n", + "Cl_best2 = file2['Cl_best']\n", + "nbest2 = len(moll_hc_best2)\n", + "file2.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# concatenate Cl and moll_hc\n", + "nbest=nbest1+nbest2\n", + "print(nbest)\n", + "npix = hp.nside2npix(nside)\n", + "Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + "moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{shape=}, {nsort.shape=}, {nbest=}\")\n", + "print(f\"{Cl_best1.shape=}, {moll_hc_best1.shape=}\")\n", + "print(f\"{Cl_best2.shape=}, {moll_hc_best2.shape=}\")\n", + "print(f\"{Cl_best.shape=}, {moll_hc_best.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# npix = anisotropy.NPIX\n", + "# lmax = anisotropy.LMAX\n", + "\n", + "# Cl_best = np.zeros((nbest, nfreqs, nreals, lmax+1 ))\n", + "# moll_hc_best = np.zeros((nbest, nfreqs, nreals, npix))\n", + "# for nn in range(nbest):\n", + "# print('on nn=%d out of nbest=%d' % (nn,nbest))\n", + "# moll_hc_best[nn,...], Cl_best[nn,...] = anisotropy.sph_harm_from_hc(hc_ss[nsort[nn]], \n", + "# hc_bg[nsort[nn]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.where(Cl_best[:,0,0,0]==0))\n", + "print(np.where(Cl_best1[:,0,0,0]==0))\n", + "print(np.where(Cl_best2[:,0,0,0]==0))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(np.arange(len(Cl_best)), Cl_best[:,0,0,0])\n", + "plt.ylim(0,0.1e-58)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "print(holo.utils.stats(Cl_best1))\n", + "print(holo.utils.stats(Cl_best2))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)\n", + "print(holo.utils.stats(Cl_best))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow):\n", + " fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " colors = cm.gist_rainbow(np.linspace(0, 1, lmax))\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll], label='$l=%d$' % (ll+1))\n", + " for pp in [50, 98]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.1,\n", + " linewidth=1) \n", + " ax.legend(ncols=2)\n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def plot_Clg0_llp1_medians(xx, Cl_best, lmax, nshow):\n", + "# fig, ax = plot.figax(figsize=(8,5), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell>0}/C_0$')\n", + "\n", + "# yy = np.sum(Cl_best[:,:,:,1:], axis=-1)/Cl_best[:,:,:,0,] # (B,F,R)\n", + "# yy = np.median(yy, axis=-1) # (B,F) median over realizations\n", + "\n", + "# ax.plot(xx, np.median(yy, axis=0), color='k', label='median of samples, $l_\\mathrm{max}=%d$' % lmax)\n", + "# for pp in [50, 98]:\n", + "# percs = pp/2\n", + "# percs = [50-percs, 50+percs]\n", + "# ax.fill_between(xx, *np.percentile(yy, percs, axis=0), alpha=0.1, color='k')\n", + "\n", + "# colors = cm.rainbow(np.linspace(1, 0, nshow))\n", + "# bb=0\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1, label=\"individual best samples, median of realizations\")\n", + "# for bb in range(1,nshow):\n", + "# ax.plot(xx, yy[bb,:], color=colors[bb], linestyle=':', alpha=0.4,\n", + "# linewidth=1)\n", + "# ax.legend()\n", + "# plot._twin_hz(ax, nano=False)\n", + " \n", + "# # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + "# # % (nbest, lmax))\n", + "# return fig\n", + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_nihan[:,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_best.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('%e' % (1/YR))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d, mbp-ss19, l=2000, uniform05a, 100 best out of 1000 samples' % nside)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best[:10], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "fig.text(0.05,1, 'nside=%d, mbp-ss19, l=2000, uniform05a, 10 best out of 1000 samples' % nside)\n", + "fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Only 1 realization harmonic" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C1C0_medians(xx, Cl_best, lmax, lreals, nshow, xx_Nihan, Cl_nihan):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " \n", + " for ll in lreals:\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + "\n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " for ll in range(lmax):\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_hz(ax, nano=False)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_1ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_C1C0_medians(fobs_yrs, Cl_best, lmax=6, lreals=[0,5], nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n", + "ax = fig.axes[0]\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "# ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "ax.set_xlim(fobs[0]*YR-.005, 1)\n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3)\n", + "\n", + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model07a_ClC0_2ell.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=100)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# for ll in range(len(Cl_nihan[0])):\n", + " \n", + "\n", + "# ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# # ax.set_xscale('linear')\n", + "# fig.legend(loc='lower right')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "# ax = fig.axes[0]\n", + "\n", + "# xx = freq_bins_Hz * YR \n", + "# ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# # ax.set_xlim(0.18*10**-8*YR, 1.2*10**-8*YR)\n", + "# ax.legend(loc='lower right')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add Sato-Polito & Kamionkowski" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_Clg0_llp1_medians(fobs_yrs, Cl_best, lmax, nshow=50)\n", + "ax = fig.axes[0]\n", + "\n", + "xx = freq_bins_Hz * YR \n", + "ax.plot(xx, Clg0_nihan, label = 'per-frequency Bayesian upper limits', color='tab:blue', marker='o', ms=8)\n", + "\n", + "# Sato-Polito & Kamionkowski\n", + "spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + "spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + "\n", + "ax.plot(spk_xx * YR, spk_yy, label='SP & K Rough Estimate', color='tab:orange')\n", + "ax.set_xlim(0, np.max(fobs_yrs))\n", + "ax.legend()\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsort)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspath = '/Users/emigardiner/GWs/holodeck/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000'\n", + "\n", + "hdfname = sspath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "print('Best sample:', nsort[0])\n", + "hc_ss = ssfile['hc_ss'][nsort[0],...]\n", + "hc_bg = ssfile['hc_bg'][nsort[0],...]\n", + "fobs = ssfile['fobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape = hc_ss.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "print('F,R,L =', nfreqs, nreals, nloudest)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Scratch" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "split=7\n", + "nbest=100\n", + "for ss in range(split):\n", + " bestrange = (np.array([ss, (ss+1)])*(nbest)/split).astype(int)\n", + " bestrange[1] = np.min([bestrange[1], nbest])\n", + " print(f\"{bestrange=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, nn in enumerate(range(bestrange[0], bestrange[1])):\n", + " print('on nn=%d out of nbest=%d, index=%d' % (nn,nbest, ii))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/oldhc_anisotropy_paper_plots.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/oldhc_anisotropy_paper_plots.ipynb similarity index 100% rename from ecg-notebooks/anisotropy/oldhc_anisotropy_paper_plots.ipynb rename to ecg-notebooks/anisotropy/plot-notebooks/oldhc_anisotropy_paper_plots.ipynb diff --git a/ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/oldhc_paper_plots_nside8.ipynb similarity index 100% rename from ecg-notebooks/anisotropy/oldhc_paper_plots_nside8.ipynb rename to ecg-notebooks/anisotropy/plot-notebooks/oldhc_paper_plots_nside8.ipynb From bd35209611390b6f085305bdf1e33df5d476cbc8 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 15 Jun 2023 16:56:50 -0700 Subject: [PATCH 066/291] Added scatter points to plot. --- ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb b/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb index d1970ac3..703265ee 100644 --- a/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb +++ b/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb @@ -311,10 +311,10 @@ "\n", " yy = Cl_arr\n", " ax.plot(xx, yy, label = 'From Eq. (3), nside=%d' % nside,\n", - " color=colors[ii])\n", + " color=colors[ii], linestyle='-', marker='o')\n", " # ax.plot(xx, Cl2dOm_arrs[ii,ff,rr,:], color=colors[ii], linestyle=':',\n", " # label=('hp.anafast, nside=%d' % (nside)))\n", - " ax.plot(xx, Cl_hpy[:], color=colors[ii], linestyle=':',\n", + " ax.plot(xx, Cl_hpy[:], color=colors[ii], linestyle=':', marker='x',\n", " label=('hp.anafast, nside=%d' % (nside)))\n", "\n", "ax.legend()\n", From 9b1a2d90326caa6fe9c0ae5749a20a2858f20b83 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 09:22:42 -0700 Subject: [PATCH 067/291] Plotting ClC0 for various libraries in compare_models_hc2d)m.ipynb --- .../compare_models_hc2dOm.ipynb | 1001 +++++++++++++++++ 1 file changed, 1001 insertions(+) create mode 100644 ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb diff --git a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb new file mode 100644 index 00000000..255bc5ef --- /dev/null +++ b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb @@ -0,0 +1,1001 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Nihan's Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# decision threshold from the frequentist analysis for l = 0 through l = 6\n", + "freq_dthresh = np.array([1. , 0.39622564, 0.32362566, 0.20984702, 0.11960839,\n", + " 0.07806638, 0.04426357])\n", + "\n", + "# This is for the all-band Bayesian analysis from l = 1 to l = 6:\n", + "bayes_Cl = np.array([0.24187743, 0.17480158, 0.10009671, 0.08109598, 0.05493891,\n", + " 0.0317599 ])\n", + "\n", + "# And these are the per-frequency Bayesian upper limits, \n", + "# where each row represents the frequency bin from low to high (0 to 4) \n", + "# and then each column is the spherical harmonic multipole from l = 1 to l = 6:\n", + "# (F, l)\n", + "Cl_nihan = np.array([\n", + " [0.20216773, 0.14690035, 0.09676646, 0.07453352, 0.05500382, 0.03177427],\n", + " [0.21201336, 0.14884939, 0.10545698, 0.07734305, 0.05257189, 0.03090662],\n", + " [0.20840993, 0.14836757, 0.09854803, 0.07205384, 0.05409881, 0.03305785],\n", + " [0.19788951, 0.15765126, 0.09615489, 0.07475364, 0.0527356 , 0.03113331],\n", + " [0.20182648, 0.14745265, 0.09681202, 0.0746824 , 0.05503161, 0.0317012 ]])\n", + "print(Cl_nihan.shape)\n", + "\n", + "freq_bins_Hz = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Functions" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "read_split_anis_file()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def read_split2_anis_file(filename1, filename2):\n", + " file1 = np.load(filename1)\n", + " file2 = np.load(filename2)\n", + " print(f\"{file1.files=}\")\n", + " # load ss info\n", + " shape = file1['ss_shape']\n", + " nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " fobs = file1['fobs']\n", + "\n", + " # # load ranking info\n", + " # nsort = file1['nsort']\n", + " # fidx = file1['fidx']\n", + " # hc_ref = file1['hc_ref']\n", + "\n", + " # load harmonics info\n", + " # nside = file1['nside']\n", + " lmax = file1['lmax']\n", + "\n", + " # load map and harmonics from 1st split chunk\n", + " # moll_hc_best1 = file1['moll_hc_best']\n", + " Cl_best1 = file1['Cl_best']\n", + " nbest1 = len(Cl_best1)\n", + "\n", + " file1.close()\n", + "\n", + " # load map and harmonics from 2nd split chunk\n", + " # moll_hc_best2 = file2['moll_hc_best']\n", + " Cl_best2 = file2['Cl_best']\n", + " nbest2 = len(Cl_best2)\n", + " file2.close()\n", + "\n", + "\n", + " # concatenate Cl and moll_hc\n", + " nbest=nbest1+nbest2\n", + " print(f\"{nbest=}\")\n", + " Cl_best = np.concatenate((Cl_best1, Cl_best2)).reshape(nbest, nfreqs, nreals, lmax+1)\n", + " # moll_hc_best = np.concatenate((moll_hc_best1, moll_hc_best2), axis=0).reshape(nbest, nfreqs, nreals, npix)\n", + "\n", + " print(f\"{shape=}, {nbest=}\")\n", + " print(f\"{Cl_best1.shape=}, {Cl_best2.shape=}, {Cl_best.shape=}\")\n", + " # print(f\"{moll_hc_best1.shape=}, {moll_hc_best2.shape=}, {moll_hc_best.shape=}\")\n", + "\n", + " vals = {\n", + " 'fobs':fobs, 'lmax':lmax, 'Cl_best':Cl_best\n", + " }\n", + " return vals\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "read_one_anis_file()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def read_one_anis_file(filename1):\n", + " file1 = np.load(filename1)\n", + " print(f\"{file1.files=}\")\n", + " # load ss info\n", + " shape = file1['ss_shape']\n", + " nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " fobs = file1['fobs']\n", + "\n", + " # # load ranking info\n", + " # nsort = file1['nsort']\n", + " # fidx = file1['fidx']\n", + " # hc_ref = file1['hc_ref']\n", + "\n", + " # load harmonics info\n", + " # nside = file1['nside']\n", + " lmax = file1['lmax']\n", + "\n", + " # load map and harmonics from 1st split chunk\n", + " # moll_hc_best1 = file1['moll_hc_best']\n", + " Cl_best = file1['Cl_best']\n", + " nbest = len(Cl_best)\n", + "\n", + " file1.close()\n", + "\n", + "\n", + " print(f\"{shape=}, {nbest=}\")\n", + " print(f\"{Cl_best.shape=}\")\n", + " # print(f\"{moll_hc_best1.shape=}, {moll_hc_best2.shape=}, {moll_hc_best.shape=}\")\n", + "\n", + " vals = {\n", + " 'fobs':fobs, 'lmax':lmax, 'Cl_best':Cl_best\n", + " }\n", + " return vals\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_ClC0_medians()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan,\n", + " figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$'):\n", + " fig, ax = plot.figax(figsize=figsize, xlabel=xlabel, ylabel=ylabel,)\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [68,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=5)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + " ax.set_xlabel(xlabel, fontsize=11)\n", + " ax.set_ylabel(ylabel, fontsize=11)\n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_ClC0_medians_big" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_medians_big(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan,\n", + " xmin=None, xmax=None, ymin=None, ymax=None, show_spk = False):\n", + " fig, ax = plot.figax(figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$')\n", + "\n", + " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", + " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", + "\n", + " # colors = ['k', 'b', 'r', 'g', 'c', 'm']\n", + " colors = ['#0a5da4', '#00ba44', '#ff9503', '#fe2c02', '#845b98', '#474747']\n", + " for ll in range(lmax):\n", + " ax.plot(xx, np.median(yy[:,:,ll], axis=0), color=colors[ll]) #, label='median of samples, $l=%d$' % ll)\n", + " for pp in [50, 95]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[:,:,ll], percs, axis=0), alpha=0.1, color=colors[ll])\n", + " \n", + " for bb in range(0,nshow):\n", + " # if ll==0 and bb==0:\n", + " # label = \"individual best samples, median of realizations\"\n", + " # else: \n", + " label=None\n", + " ax.plot(xx, yy[bb,:,ll], color=colors[ll], linestyle=':', alpha=0.25,\n", + " linewidth=1, label=label)\n", + " \n", + " # Add Nihan's data\n", + " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", + " label = '$l=%d$' % (ll+1), \n", + " color=colors[ll], marker='o', ms=8)\n", + " \n", + " plot._twin_yr(ax, nano=False)\n", + "\n", + " if show_spk:\n", + " # Sato-Polito & Kamionkowski\n", + " spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", + " spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", + " ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + "\n", + " if xmin is not None and xmax is not None:\n", + " ax.set_xlim(xmin, xmax)\n", + " if ymin is not None and ymax is not None:\n", + " ax.set_ylim(ymin, ymax)\n", + " \n", + " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", + " # % (nbest, lmax))\n", + " return fig\n", + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Uniform_09A" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 09A ns 32" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform09A'\n", + "nside = 32\n", + "\n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss58_anis09A_2023-06-15_uniform-09a_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b00-49.npz'\n", + "filename2 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss58_anis09A_2023-06-15_uniform-09a_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b50-99.npz'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = read_split2_anis_file(filename1, filename2)\n", + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 09a ns 08" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform09A'\n", + "nside = 8\n", + "\n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss58_anis09A_2023-06-15_uniform-09a_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-99.npz'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "vals = read_one_anis_file(filename1)\n", + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Uniform_07A" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 07a nside 32" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform07A'\n", + "nside = 32\n", + "\n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b00-49.npz'\n", + "filename2 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b50-99.npz'\n", + "\n", + "vals = read_split2_anis_file(filename1, filename2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 07A nside 08" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform07A'\n", + "nside = 8\n", + "\n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz'\n", + "filename2 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz'\n", + "\n", + "vals = read_split2_anis_file(filename1, filename2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Uniform_05A" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 05A ns 08" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform_05A'\n", + "nside = 32\n", + "\n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz'\n", + "filename2 = '/Users/emigardiner/GWs/holodeck/output/2023-05-16-mbp-ss19_uniform05A_n1000_r50_d20_f30_l2000_p0/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz'\n", + "\n", + "vals = read_split2_anis_file(filename1, filename2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Uniform07_GW" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 07GW ns 32" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform09_GW'\n", + "nside = 32\n", + "\n", + "filename1 = \n", + "filename2 = \n", + "\n", + "vals = read_split2_anis_file(filename1, filename2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 07GW ns 08" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = 'Uniform09_GW'\n", + "nside = 8\n", + "\n", + "filename1 = \n", + "filename2 = \n", + "\n", + "vals = read_split2_anis_file(filename1, filename2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot Results" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65))\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "\n", + "# fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 4164649469c2ac8a40d73ace5418e9f73c010f2c Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 09:29:00 -0700 Subject: [PATCH 068/291] Added plots for just 25 best ClC0 to compare_models_hc2dOm.ipynb --- .../compare_models_hc2dOm.ipynb | 142 ++++++++++-------- 1 file changed, 82 insertions(+), 60 deletions(-) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb index 255bc5ef..cdf9f065 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb @@ -301,7 +301,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 09A ns 32" + "## 09A ns32" ] }, { @@ -329,14 +329,6 @@ "Cl_best = vals['Cl_best']" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot Results" - ] - }, { "cell_type": "code", "execution_count": null, @@ -393,7 +385,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 09a ns 08" + "## 09a ns08" ] }, { @@ -463,7 +455,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Plot Results" + "### 25 best (09A ns08)" ] }, { @@ -472,11 +464,13 @@ "metadata": {}, "outputs": [], "source": [ - "lvals = np.arange(lmax+1)\n", - "fobs_nHz = fobs*10**9\n", - "fobs_yrs = fobs*YR\n", - "ff_labels = (0,9,19,29,39)\n", - "nshow = 10" + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" ] }, { @@ -521,14 +515,6 @@ "Cl_best = vals['Cl_best']" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot Results" - ] - }, { "cell_type": "code", "execution_count": null, @@ -614,13 +600,6 @@ "Cl_best = vals['Cl_best']" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot Results" - ] - }, { "cell_type": "code", "execution_count": null, @@ -672,6 +651,29 @@ "fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 25 best (07A ns08)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -685,7 +687,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 05A ns 08" + "## 05A ns08" ] }, { @@ -714,13 +716,6 @@ "Cl_best = vals['Cl_best']" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot Results" - ] - }, { "cell_type": "code", "execution_count": null, @@ -772,6 +767,29 @@ "fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 25 best (05A ns32)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -785,7 +803,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 07GW ns 32" + "## 07GW ns32" ] }, { @@ -814,13 +832,6 @@ "Cl_best = vals['Cl_best']" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot Results" - ] - }, { "cell_type": "code", "execution_count": null, @@ -877,7 +888,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 07GW ns 08" + "## 07GW ns08" ] }, { @@ -906,18 +917,6 @@ "Cl_best = vals['Cl_best']" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot Results" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -969,6 +968,29 @@ "fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 25 best (07GW ns08)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, { "cell_type": "code", "execution_count": null, From 5b75db432ae0dc4e93440b36a3a22bcf7193ca50 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 10:58:58 -0700 Subject: [PATCH 069/291] 09A paper plot without reals in compare_models_hc2dOm.ipynb. --- .../compare_models_hc2dOm.ipynb | 132 ++++-------------- 1 file changed, 27 insertions(+), 105 deletions(-) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb index cdf9f065..9835c18f 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb @@ -223,7 +223,7 @@ " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", " # % (nbest, lmax))\n", " return fig\n", - "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" ] }, { @@ -275,7 +275,7 @@ " # Sato-Polito & Kamionkowski\n", " spk_xx = np.array([3.5*10**-9, 1.25*10**-8, 1*10**-7])\n", " spk_yy = np.array([1*10**-5, 1*10**-3, 1*10**-1])\n", - " ax.plot(spk_xx * YR, spk_yy, label='SP & K', color='tab:orange')\n", + " ax.plot(spk_xx, spk_yy, label='SP & K', color='limegreen', linestyle='--')\n", "\n", " if xmin is not None and xmax is not None:\n", " ax.set_xlim(xmin, xmax)\n", @@ -285,7 +285,7 @@ " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", " # % (nbest, lmax))\n", " return fig\n", - "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" + "# fig1 = plot_ClC0_medians(fobs_yrs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz * YR, Cl_nihan=Cl_nihan)\n" ] }, { @@ -348,7 +348,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", @@ -371,7 +371,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=20, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -418,7 +418,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=0, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", @@ -441,7 +441,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -464,7 +464,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -534,7 +534,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", @@ -557,7 +557,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -619,7 +619,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", @@ -642,7 +642,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -665,7 +665,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -735,7 +735,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", @@ -758,7 +758,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -781,7 +781,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -803,7 +803,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 07GW ns32" + "## 07GW ns08" ] }, { @@ -812,11 +812,11 @@ "metadata": {}, "outputs": [], "source": [ - "pspace = 'Uniform09_GW'\n", - "nside = 32\n", + "pspace = 'Uniform_07_GW'\n", + "nside = 8\n", "\n", - "filename1 = \n", - "filename2 = \n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss59_anis07GW_2023-06-15_uniform-07-gw_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-49.npz'\n", + "filename2 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss59_anis07GW_2023-06-15_uniform-07-gw_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b50-99.npz'\n", "\n", "vals = read_split2_anis_file(filename1, filename2)" ] @@ -851,7 +851,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " figsize=(7/1.65, 6/1.65))\n", "ax = fig.axes[0]\n", "\n", @@ -874,7 +874,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", @@ -888,69 +888,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 07GW ns08" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "pspace = 'Uniform09_GW'\n", - "nside = 8\n", - "\n", - "filename1 = \n", - "filename2 = \n", - "\n", - "vals = read_split2_anis_file(filename1, filename2)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fobs = vals['fobs']\n", - "lmax = vals['lmax']\n", - "Cl_best = vals['Cl_best']" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "lvals = np.arange(lmax+1)\n", - "fobs_nHz = fobs*10**9\n", - "fobs_yrs = fobs*YR\n", - "ff_labels = (0,9,19,29,39)\n", - "nshow = 10" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", - " figsize=(7/1.65, 6/1.65))\n", - "ax = fig.axes[0]\n", - "\n", - "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", - "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", - "plt.rc('ytick', labelsize=10) \n", - "\n", - "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", - "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", - "\n", - "# fig.tight_layout()\n", - "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/modelhc2dOm_ClC0_ns%d.png' % nside, dpi=300)\n", - "# fig.text(0.05,1, 'nside=%d' % nside)\n", - "fig.tight_layout()" + "### 25 best (07GW ns08)" ] }, { @@ -959,37 +897,21 @@ "metadata": {}, "outputs": [], "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", "ax = fig.axes[0]\n", "ax.legend(loc='lower right', ncols=4)\n", "\n", - "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", "fig.tight_layout()" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### 25 best (07GW ns08)" - ] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=10, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", - " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", - "ax = fig.axes[0]\n", - "ax.legend(loc='lower right', ncols=4)\n", - "\n", - "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", - "fig.tight_layout()" - ] + "source": [] }, { "cell_type": "code", From 27a0dd27419d9d8a6b667fdd44107cdc808f5d85 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 10:59:55 -0700 Subject: [PATCH 070/291] generated anatomy plots for GW Only full shape in take5B_GW_anatomy_fullshape. --- ...ake5A_FT_anatomy_fullshape_normpars.ipynb} | 0 ...take5B_GW_anatomy_fullshape_normpars.ipynb | 750 ++++++++++++++++++ ...pynb => take7A_FT_anatomy_fromsaved.ipynb} | 0 3 files changed, 750 insertions(+) rename ecg-notebooks/parameter_investigation/{take5_gwb_anatomy_fullshape_normpars.ipynb => take5A_FT_anatomy_fullshape_normpars.ipynb} (100%) create mode 100644 ecg-notebooks/parameter_investigation/take5B_GW_anatomy_fullshape_normpars.ipynb rename ecg-notebooks/parameter_investigation/{take7_gwb_anatomy_fromsaved.ipynb => take7A_FT_anatomy_fromsaved.ipynb} (100%) diff --git a/ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5A_FT_anatomy_fullshape_normpars.ipynb similarity index 100% rename from ecg-notebooks/parameter_investigation/take5_gwb_anatomy_fullshape_normpars.ipynb rename to ecg-notebooks/parameter_investigation/take5A_FT_anatomy_fullshape_normpars.ipynb diff --git a/ecg-notebooks/parameter_investigation/take5B_GW_anatomy_fullshape_normpars.ipynb b/ecg-notebooks/parameter_investigation/take5B_GW_anatomy_fullshape_normpars.ipynb new file mode 100644 index 00000000..1fc41608 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take5B_GW_anatomy_fullshape_normpars.ipynb @@ -0,0 +1,750 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1 Choose a Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = 10\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "# params = pars * pspace.param_samples\n", + "params = pspace.normalized_params(pars)\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 Mid of all params\n", + "## 2.1 Plot hc vs. bin pars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents = data['fobs_cents']\n", + "hc_ss_mid = data['hc_ss']\n", + "hc_bg_mid = data['hc_bg']\n", + "sspar_mid = sings.all_sspars(fobs_cents, data['sspar'])\n", + "bgpar_mid = data['bgpar']\n", + "binpar_names = sings.par_names\n", + "# params = pars*pspace.params\n", + "print(f\"{hc_ss_mid.shape=}\")\n", + "print(f\"{bgpar_mid.shape=}\")\n", + "print(f\"{sspar_mid.shape=}\")\n", + "print(f\"{param_names=}\")\n", + "print(f\"{params=}\")\n", + "print(f\"{binpar_names=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_hs_vs_binpars(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, fast_ss=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 Calibrate PTA" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 50\n", + "SIGMA = 3.55e-6\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "def detect_pspace_model(data, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape = hc_ss_mid.shape\n", + "nfreqs, nreals, nloudest = shape[0], shape[1], shape[2]\n", + "debug=True\n", + "\n", + "# calculate dur, cad, dfobs\n", + "dur = DUR * YR\n", + "hifr = nfreqs/dur\n", + "cad = 1.0 / (2 * hifr)\n", + "fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad)\n", + "dfobs = np.diff(fobs_edges)\n", + "\n", + "# build PTA\n", + "if debug: print('Building pulsar timing array.')\n", + "phis = np.random.uniform(0, 2*np.pi, size = NPSRS)\n", + "thetas = np.random.uniform(np.pi/2, np.pi/2, size = NPSRS)\n", + "# sigmas = np.ones_like(phis)*sigma\n", + "psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=SIGMA,\n", + " phi=phis, theta=thetas)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, hc_bg_mid)\n", + "print(f\"{np.median(dp_bg)=}, {np.mean(dp_bg)=}, {np.std(dp_bg)=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dsdata_mid= detect_pspace_model(data)\n", + "print(f\"{dsdata_mid.keys()=}\")\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.3 Plot everything vs freqs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss_mid = dsdata_mid['dp_ss'] \n", + "dp_bg_mid = dsdata_mid['dp_bg']\n", + "snr_ss_mid = dsdata_mid['snr_ss']\n", + "snr_bg_mid = dsdata_mid['snr_bg']\n", + "print(f\"{dp_ss_mid.shape=}, {dp_bg_mid.shape=}, {snr_ss_mid.shape=}, {snr_bg_mid.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest):\n", + " if show_reals:\n", + " if fast:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', alpha=0.1, color=color_bg)\n", + " else:\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor='k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[:,rr,ll], marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.plot(xx, yy_bg[:,rr], marker='x', alpha=0.1, color=colors[rr])\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.1, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=15, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "fig=plot_everything_vs_freqs(fobs_cents, hc_ss_mid, hc_bg_mid, sspar_mid, bgpar_mid, \n", + " dp_ss_mid, dp_bg_mid, snr_ss_mid, snr_bg_mid,\n", + " fast=False)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 Plot-Three Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg, colors,\n", + " fast, show_reals, nreals, nloudest)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def draw_three_models(\n", + " data, params, hard_name, shape, target_param, filename,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(dat)\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def draw_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param, filename,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + "\n", + " return fig\n", + "\n", + "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 Vary Parameters!!!!!!!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape'\n", + "SHAPE = None\n", + "\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " pars=None, save_dir=None \n", + " ):\n", + " print(f\"{pspace.sam_shape=}\")\n", + "\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, sam_shape=pspace.sam_shape)\n", + " print(f\"{sam.shape}\")\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, hard_name, sam.shape, target_param, filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(pspace.param_samples[0])\n", + "# print(type(rv_hard_time[1][0].values()))\n", + "print(param_names)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_phi0 = vary_parameter('gsmf_phi0', save_dir=save_dir) \n", + "fig = draw_three_models(*rv_gsmf_phi0)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', save_dir=save_dir) \n", + "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10', save_dir=save_dir) \n", + "fig = draw_three_models(*rv_mmb_mamp_log10)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex', save_dir=save_dir) \n", + "fig = draw_three_models(*rv_mmb_scatter_dex)\n", + "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/take7_gwb_anatomy_fromsaved.ipynb b/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb similarity index 100% rename from ecg-notebooks/parameter_investigation/take7_gwb_anatomy_fromsaved.ipynb rename to ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb From 78f1f50af5cba419b787891f2367d7eb350e214a Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 11:02:17 -0700 Subject: [PATCH 071/291] Changed draw_three to plot_three --- .../take7A_FT_anatomy_fromsaved.ipynb | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb b/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb index 40e5c0e2..3d70b807 100644 --- a/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb +++ b/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb @@ -392,7 +392,7 @@ "\n", " return fig\n", "\n", - "# fig = draw_three_models(data = data_hard_time, params = params_hard_time,\n", + "# fig = plot_three_models(data = data_hard_time, params = params_hard_time,\n", "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" ] }, @@ -446,7 +446,7 @@ "\n", " return fig\n", "\n", - "# fig = draw_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# fig = plot_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", "# hard_name, sam.shape, target_param)\n" ] }, @@ -486,8 +486,8 @@ "rv_hard_time = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", "# rv_hard_time = vary_parameter('hard_time', save_dir=save_dir) # save for later so we don't have to recalculate, if \n", - "fig = draw_three_models(*rv_hard_time)\n", - "fig = draw_three_hs_vs_binpars(*rv_hard_time)" + "fig = plot_three_models(*rv_hard_time)\n", + "fig = plot_three_hs_vs_binpars(*rv_hard_time)" ] }, { @@ -509,8 +509,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_gsmf_phi0)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0)" + "fig = plot_three_models(*rv_gsmf_phi0)\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0)" ] }, { @@ -534,8 +534,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_gsmf_phi0_hard0)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard0)" + "fig = plot_three_models(*rv_gsmf_phi0_hard0)\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0_hard0)" ] }, { @@ -560,8 +560,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_gsmf_phi0_hard1)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_phi0_hard1)" + "fig = plot_three_models(*rv_gsmf_phi0_hard1)\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0_hard1)" ] }, { @@ -583,8 +583,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_gsmf_mchar0_log10)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + "fig = plot_three_models(*rv_gsmf_mchar0_log10)\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" ] }, { @@ -607,8 +607,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_gsmf_mchar0_log10_hard0)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard0)" + "fig = plot_three_models(*rv_gsmf_mchar0_log10_hard0)\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard0)" ] }, { @@ -631,8 +631,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_gsmf_mchar0_log10_hard1)\n", - "fig = draw_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard1)" + "fig = plot_three_models(*rv_gsmf_mchar0_log10_hard1)\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard1)" ] }, { @@ -654,8 +654,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_mamp_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_mmb_mamp_log10)\n", - "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + "fig = plot_three_models(*rv_mmb_mamp_log10)\n", + "fig = plot_three_hs_vs_binpars(*rv_mmb_mamp_log10)" ] }, { @@ -679,8 +679,8 @@ "rv_mmb_mamp_log10_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", " \n", - "fig = draw_three_models(*rv_mmb_mamp_log10_hard1)\n", - "fig = draw_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1)" + "fig = plot_three_models(*rv_mmb_mamp_log10_hard1)\n", + "fig = plot_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1)" ] }, { @@ -702,8 +702,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_scatter_dex = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_mmb_scatter_dex)\n", - "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + "fig = plot_three_models(*rv_mmb_scatter_dex)\n", + "fig = plot_three_hs_vs_binpars(*rv_mmb_scatter_dex)" ] }, { @@ -726,8 +726,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_scatter_dex_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_mmb_scatter_dex_hard1)\n", - "fig = draw_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1)" + "fig = plot_three_models(*rv_mmb_scatter_dex_hard1)\n", + "fig = plot_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1)" ] }, { @@ -749,8 +749,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_hard_gamma_inner = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_hard_gamma_inner)\n", - "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner)" + "fig = plot_three_models(*rv_hard_gamma_inner)\n", + "fig = plot_three_hs_vs_binpars(*rv_hard_gamma_inner)" ] }, { @@ -773,8 +773,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_hard_gamma_inner_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_hard_gamma_inner_hard1)\n", - "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" + "fig = plot_three_models(*rv_hard_gamma_inner_hard1)\n", + "fig = plot_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" ] }, { @@ -789,8 +789,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_hard_gamma_inner_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = draw_three_models(*rv_hard_gamma_inner_hard0)\n", - "fig = draw_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0)" + "fig = plot_three_models(*rv_hard_gamma_inner_hard0)\n", + "fig = plot_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0)" ] }, { From 64028d2db941bc9ffd21ab86a234db52b4e835b4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 12:03:06 -0700 Subject: [PATCH 072/291] Looking at ClC0 healpy vs equations for different realizations. --- .../anisotropy/healpix/varying_nside_B.ipynb | 1228 +++++++++++++++++ .../healpix/varying_nside_hc2dOm.ipynb | 103 +- .../anisotropy/healpix/vn2_ClC0_eqs.ipynb | 215 ++- 3 files changed, 1515 insertions(+), 31 deletions(-) create mode 100644 ecg-notebooks/anisotropy/healpix/varying_nside_B.ipynb diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside_B.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside_B.ipynb new file mode 100644 index 00000000..0bc47f65 --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/varying_nside_B.ipynb @@ -0,0 +1,1228 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "import holodeck.anisotropy as anis\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=684\n", + "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdfname = sspath+'sam_lib.hdf5'\n", + "ssfile = h5py.File(hdfname, 'r')\n", + "print(list(ssfile.keys()))\n", + "hc_ss = ssfile['hc_ss'][nn]\n", + "hc_bg = ssfile['hc_bg'][nn]\n", + "fobs = ssfile['fobs'][:]\n", + "# dfobs = ssfile['dfobs'][:]\n", + "ssfile.close()\n", + "\n", + "shape=hc_ss.shape\n", + "nfreqs = shape[-3]\n", + "nreals = shape[-2]\n", + "nloudest = shape[-1]\n", + "print('nfreqs=%d, nreals=%d, nloudest=%d' % (nfreqs, nreals, nloudest))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 1 hc\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc_B684.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "pix_ss08 = hcfile['pix_ss08']\n", + "pix_ss16 = hcfile['pix_ss16']\n", + "pix_ss32 = hcfile['pix_ss32']\n", + "pix_ss64 = hcfile['pix_ss64']\n", + "# pix_ss128 = hcfile['pix_ss128']\n", + "Cl_arrs = hcfile['Cl_arrs']\n", + "nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "lmax=6" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]/np.sqrt(npix)) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "# nsides=np.array([8, 16, 32, 64]) #, 128])\n", + "# moll_bg08 = make_bg_map(hc_bg, nside=8)\n", + "# moll_bg16 = make_bg_map(hc_bg, nside=16)\n", + "# moll_bg32 = make_bg_map(hc_bg, nside=32)\n", + "# moll_bg64 = make_bg_map(hc_bg, nside=64)\n", + "# # moll_bg128 = make_bg_map(hc_bg, nside=128)\n", + "# print(moll_bg08.shape)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Place single sources at random pixels" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2\n", + " + hc_ss[ff,rr,ll]**2)\n", + " return moll_ss, pix_ss\n", + "# moll_ss08, pix_ss08 = make_ss_map(hc_ss, 8)\n", + "# print(f\"{moll_ss08.shape=}\")\n", + "# print(f\"{pix_ss08.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def convert_pix_ss(pix_ss1, nside1, nside2):\n", + " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", + " print(f\"{theta.shape=}, {phi.shape=}\")\n", + " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", + " return pix_ss2\n", + "\n", + "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "# pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "# pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "# # pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.1 Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll_ss16, temp = make_ss_map(hc_ss, 16, pix_ss16)\n", + "# moll_ss32, temp = make_ss_map(hc_ss, 32, pix_ss32)\n", + "# moll_ss64, temp = make_ss_map(hc_ss, 64, pix_ss64)\n", + "# # moll_ss128, temp = make_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll_tt08 = np.sqrt(moll_ss08**2 + moll_bg08**2)\n", + "# moll_tt16 = np.sqrt(moll_ss16**2 + moll_bg16**2)\n", + "# moll_tt32 = np.sqrt(moll_ss32**2 + moll_bg32**2)\n", + "# moll_tt64 = np.sqrt(moll_ss64**2 + moll_bg64**2)\n", + "# # moll_tt128 = np.sqrt(moll_ss128**2 + moll_bg128**2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(moll_tt08[ff,rr], unit='$h_c$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(moll_tt16[ff,rr], unit='$h_c$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(moll_tt32[ff,rr],unit='$h_c$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# lmax=6\n", + "# Cl_08 = anis.sph_harm_from_map(moll_tt08, lmax=6)\n", + "# Cl_16 = anis.sph_harm_from_map(moll_tt16, lmax=6)\n", + "# Cl_32 = anis.sph_harm_from_map(moll_tt32, lmax=6)\n", + "# Cl_64 = anis.sph_harm_from_map(moll_tt64, lmax=6)\n", + "# # Cl_128 = anis.sph_harm_from_map(moll_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cl_arrs = np.array([Cl_08, Cl_16, Cl_32, Cl_64]) #, Cl_128])\n", + "print(Cl_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(fobs*YR)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c$' % (nn, rr, fobs[ff]*YR,))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl_arrs[...,ll]/Cl_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,:,rr], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $h_c$' % (nn, rr))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl_arrs[...,ll]/Cl_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, $h_c$' % (nn))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc_B684.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, #moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64,# moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, #moll_tt128=moll_tt128,\n", + "# Cl_arrs=Cl_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 hc^2 \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc2_B684.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "Cl2_arrs = hcfile['Cl2_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.1 Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hc2_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]**2/(npix)) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "# nsides=np.array([8,16,32, 64, 128])\n", + "# moll2_bg08 = make_hc2_bg_map(hc_bg, nside=8)\n", + "# moll2_bg16 = make_hc2_bg_map(hc_bg, nside=16)\n", + "# moll2_bg32 = make_hc2_bg_map(hc_bg, nside=32)\n", + "# moll2_bg64 = make_hc2_bg_map(hc_bg, nside=64)\n", + "# # moll2_bg128 = make_hc2_bg_map(hc_bg, nside=128)\n", + "# print(moll2_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hc2_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = moll_ss[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2\n", + " return moll_ss, pix_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll2_ss08, temp = make_hc2_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# moll2_ss16, temp = make_hc2_ss_map(hc_ss, 16, pix_ss16)\n", + "# moll2_ss32, temp = make_hc2_ss_map(hc_ss, 32, pix_ss32)\n", + "# moll2_ss64, temp = make_hc2_ss_map(hc_ss, 64, pix_ss64)\n", + "# # moll2_ss128, temp = make_hc2_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll2_tt08 = (moll2_ss08 + moll2_bg08)\n", + "# moll2_tt16 = (moll2_ss16 + moll2_bg16)\n", + "# moll2_tt32 = (moll2_ss32 + moll2_bg32)\n", + "# moll2_tt64 = (moll2_ss64 + moll2_bg64)\n", + "# # moll2_tt128 = (moll2_ss128 + moll2_bg128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(moll2_tt08[ff,rr], unit='$h_c^2$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(moll2_tt16[ff,rr], unit='$h_c^2$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(moll2_tt32[ff,rr], unit='$h_c^2$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# lmax=6\n", + "# Cl2_08 = anis.sph_harm_from_map(moll2_tt08, lmax=6)\n", + "# Cl2_16 = anis.sph_harm_from_map(moll2_tt16, lmax=6)\n", + "# Cl2_32 = anis.sph_harm_from_map(moll2_tt32, lmax=6)\n", + "# Cl2_64 = anis.sph_harm_from_map(moll2_tt64, lmax=6)\n", + "# # Cl2_128 = anis.sph_harm_from_map(moll2_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cl2_arrs = np.array([Cl2_08, Cl2_16, Cl2_32, Cl2_64]) #, Cl2_128])\n", + "print(Cl2_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl2_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2$' % (nn, rr, fobs[ff]*YR))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl2_arrs[...,ll]/Cl2_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, $h_c^2$' % (nn,))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 2.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc2_B684.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll2_ss08=moll2_ss08, moll2_ss16=moll2_ss16, moll2_ss32=moll2_ss32, moll2_ss64=moll2_ss64, #moll_ss128=moll_ss128,\n", + "# moll2_bg08=moll2_bg08, moll2_bg16=moll2_bg16, moll2_bg32=moll2_bg32, moll2_bg64=moll2_bg64,# moll_bg128=moll_bg128,\n", + "# moll2_tt08=moll2_tt08, moll2_tt16=moll2_tt16, moll2_tt32=moll2_tt32, moll2_tt64=moll2_tt64, #moll_tt128=moll_tt128,\n", + "# Cl2_arrs=Cl2_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 hc^2/dOmega \n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hc2dOm_B684.npz')\n", + "\n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", + "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", + "# moll_bg08=moll_bg08, moll_bg16=moll_bg16, moll_bg32=moll_bg32, moll_bg64=moll_bg64, moll_bg128=moll_bg128,\n", + "# moll_tt08=moll_tt08, moll_tt16=moll_tt16, moll_tt32=moll_tt32, moll_tt64=moll_tt64, moll_tt128=moll_tt128,\n", + "# pix_ss08 = hcfile['pix_ss08']\n", + "# pix_ss16 = hcfile['pix_ss16']\n", + "# pix_ss32 = hcfile['pix_ss32']\n", + "# pix_ss64 = hcfile['pix_ss64']\n", + "# # pix_ss128 = hcfile['pix_ss128']\n", + "Cl2dOm_arrs = hcfile['Cl2dOm_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.1 Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hc2dOm_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]**2/npix/area) # (frequency, realization, pixel)\n", + " return moll_bg\n", + "\n", + "# nsides=np.array([8,16,32, 64, 128])\n", + "# moll2dOm_bg08 = make_hc2dOm_bg_map(hc_bg, nside=8)\n", + "# moll2dOm_bg16 = make_hc2dOm_bg_map(hc_bg, nside=16)\n", + "# moll2dOm_bg32 = make_hc2dOm_bg_map(hc_bg, nside=32)\n", + "# moll2dOm_bg64 = make_hc2dOm_bg_map(hc_bg, nside=64)\n", + "# # moll2dOm_bg128 = make_hc2dOm_bg_map(hc_bg, nside=128)\n", + "# print(moll2dOm_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hc2dOm_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = (moll_ss[ff,rr,pix_ss[ff,rr,ll]] \n", + " + hc_ss[ff,rr,ll]**2 /area)\n", + " return moll_ss, pix_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll2dOm_ss08, temp = make_hc2dOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# moll2dOm_ss16, temp = make_hc2dOm_ss_map(hc_ss, 16, pix_ss16)\n", + "# moll2dOm_ss32, temp = make_hc2dOm_ss_map(hc_ss, 32, pix_ss32)\n", + "# moll2dOm_ss64, temp = make_hc2dOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# # moll2dOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# moll2dOm_tt08 = (moll2dOm_ss08 + moll2dOm_bg08)\n", + "# moll2dOm_tt16 = (moll2dOm_ss16 + moll2dOm_bg16)\n", + "# moll2dOm_tt32 = (moll2dOm_ss32 + moll2dOm_bg32)\n", + "# moll2dOm_tt64 = (moll2dOm_ss64 + moll2dOm_bg64)\n", + "# # moll2dOm_tt128 = (moll2dOm_ss128 + moll2dOm_bg128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(moll2dOm_tt08[ff,rr], unit='$h_c^2/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(moll2dOm_tt16[ff,rr], unit='$h_c^2/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(moll2dOm_tt32[ff,rr], unit='$h_c^2/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# lmax=6\n", + "# Cl2dOm_08 = anis.sph_harm_from_map(moll2dOm_tt08, lmax=6)\n", + "# Cl2dOm_16 = anis.sph_harm_from_map(moll2dOm_tt16, lmax=6)\n", + "# Cl2dOm_32 = anis.sph_harm_from_map(moll2dOm_tt32, lmax=6)\n", + "# Cl2dOm_64 = anis.sph_harm_from_map(moll2dOm_tt64, lmax=6)\n", + "# # Cl2dOm_128 = anis.sph_harm_from_map(moll2dOm_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Cl2dOm_arrs = np.array([Cl2dOm_08, Cl2dOm_16, Cl2dOm_32, Cl2dOm_64]) #, Cl2dOm_128])\n", + "print(Cl2dOm_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2dOm_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = Cl2dOm_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ll=1\n", + "\n", + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(Cl2dOm_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = Cl2dOm_arrs[...,ll]/Cl2dOm_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, $\\ell$=%d, $h_c^2/d\\Omega$' % (nn,ll))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 3.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hc2dOm_B684.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# moll2dOm_ss08=moll2dOm_ss08, moll2dOm_ss16=moll2dOm_ss16, moll2dOm_ss32=moll2dOm_ss32, moll2dOm_ss64=moll2dOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# moll2dOm_bg08=moll2dOm_bg08, moll2dOm_bg16=moll2dOm_bg16, moll2dOm_bg32=moll2dOm_bg32, moll2dOm_bg64=moll2dOm_bg64,# moll_bg128=moll_bg128,\n", + "# moll2dOm_tt08=moll2dOm_tt08, moll2dOm_tt16=moll2dOm_tt16, moll2dOm_tt32=moll2dOm_tt32, moll2dOm_tt64=moll2dOm_tt64, #moll_tt128=moll_tt128,\n", + "# Cl2dOm_arrs=Cl2dOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 hc / dOmega\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.0 Load NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "hcfile = np.load(save_loc+'/hcdOm_B684.npz')\n", + "\n", + "# pix_ss08=hcfile['pix_ss08']\n", + "# pix_ss16=hcfile['pix_ss16']\n", + "# pix_ss32=hcfile['pix_ss32']\n", + "# pix_ss64=hcfile['pix_ss64']\n", + "# moll_ss08=hcfile['moll_ss08']\n", + "# moll_ss16=hcfile['moll_ss16']\n", + "# moll_ss32=hcfile['moll_ss32']\n", + "# moll_ss64=hcfile['moll_ss64']\n", + "# moll_bg08=hcfile['moll_bg08']\n", + "# moll_bg16=hcfile['moll_bg16']\n", + "# moll_bg32=hcfile['moll_bg32']\n", + "# moll_bg64=hcfile['moll_bg64']\n", + "# moll_tt08=hcfile['moll_tt08']\n", + "# moll_tt16=hcfile['moll_tt16']\n", + "# moll_tt32=hcfile['moll_tt32']\n", + "# moll_tt64=hcfile['moll_tt64']\n", + "CldOm_arrs = hcfile['CldOm_arrs']\n", + "# nsides=hcfile['nsides']\n", + "\n", + "hcfile.close()\n", + "\n", + "# lmax=6" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Maps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# spread background evenly across pixels\n", + "\n", + "def make_hcdOm_bg_map(hc_bg, nside):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " moll_bg = (np.ones((hc_bg.shape + (npix,))) \n", + " * hc_bg[:,:,np.newaxis]/np.sqrt(npix)/area) # (frequency, realization, pixel)\n", + " return moll_bg\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# nsides=np.array([8,16,32, 64]) #, 128])\n", + "# molldOm_bg08 = make_hcdOm_bg_map(hc_bg, nside=8)\n", + "# molldOm_bg16 = make_hcdOm_bg_map(hc_bg, nside=16)\n", + "# molldOm_bg32 = make_hcdOm_bg_map(hc_bg, nside=32)\n", + "# molldOm_bg64 = make_hcdOm_bg_map(hc_bg, nside=64)\n", + "# # molldOm_bg128 = make_hcdOm_bg_map(hc_bg, nside=128)\n", + "# print(molldOm_bg08.shape)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# place single sources at random pixels, for one map\n", + "\n", + "def make_hcdOm_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2\n", + " + hc_ss[ff,rr,ll]**2) /area\n", + " return moll_ss, pix_ss\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# molldOm_ss08, temp = make_hcdOm_ss_map(hc_ss, 8, pix_ss=pix_ss08)\n", + "# molldOm_ss16, temp = make_hcdOm_ss_map(hc_ss, 16, pix_ss16)\n", + "# molldOm_ss32, temp = make_hcdOm_ss_map(hc_ss, 32, pix_ss32)\n", + "# molldOm_ss64, temp = make_hcdOm_ss_map(hc_ss, 64, pix_ss64)\n", + "# molldOm_ss128, temp = make_hc2dOm_ss_map(hc_ss, 128, pix_ss128)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# molldOm_tt08 = np.sqrt(molldOm_ss08**2 + molldOm_bg08**2)\n", + "# molldOm_tt16 = np.sqrt(molldOm_ss16**2 + molldOm_bg16**2)\n", + "# molldOm_tt32 = np.sqrt(molldOm_ss32**2 + molldOm_bg32**2)\n", + "# molldOm_tt64 = np.sqrt(molldOm_ss64**2 + molldOm_bg64**2)\n", + "# molldOm_tt128 = np.sqrt(molldOm_ss128**2 + molldOm_bg128**2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# rr=0\n", + "# for ff in range(0,5):\n", + "# fig, axs = plot.figax(ncols=3, figsize=(15,5))\n", + "# plt.axes(axs[0])\n", + "# hp.mollview(molldOm_tt08[ff,rr], unit='$h_c/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 8), hold=True )\n", + "# plt.axes(axs[1])\n", + "# hp.mollview(molldOm_tt16[ff,rr], unit='$h_c/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 16), hold=True )\n", + "# plt.axes(axs[2])\n", + "# hp.mollview(molldOm_tt32[ff,rr], unit='$h_c/d\\Omega$',\n", + "# title='f=%.2f yr$^{-1}$, nside=%d' % (fobs[ff]*YR, 32), hold=True )\n", + "# fig.tight_layout()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.2 sph harm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# lmax=6\n", + "# CldOm_08 = anis.sph_harm_from_map(molldOm_tt08, lmax=6)\n", + "# CldOm_16 = anis.sph_harm_from_map(molldOm_tt16, lmax=6)\n", + "# CldOm_32 = anis.sph_harm_from_map(molldOm_tt32, lmax=6)\n", + "# CldOm_64 = anis.sph_harm_from_map(molldOm_tt64, lmax=6)\n", + "# CldOm_128 = anis.sph_harm_from_map(molldOm_tt128, lmax=6)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# CldOm_arrs = np.array([CldOm_08, CldOm_16, CldOm_32, CldOm_64]) #, CldOm_128])\n", + "print(CldOm_arrs.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rr = 0\n", + "ll=1\n", + "\n", + "xx = np.arange(lmax+1)\n", + "colors = cm.rainbow(np.linspace(0,1,len(CldOm_arrs)))\n", + "\n", + "for ff in np.array([1,5,10]):\n", + " yy = CldOm_arrs\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, yy[ii,ff,rr,:], color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c/d\\Omega$' % (nn, rr, fobs[ff]*YR))\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = fobs*YR\n", + "colors = cm.rainbow(np.linspace(0,1,len(CldOm_arrs)))\n", + "\n", + "for ll in range(1,7):\n", + " yy = CldOm_arrs[...,ll]/CldOm_arrs[...,0]\n", + " fig, ax = plot.figax(xlabel='$f$ yr$^{-1}$', ylabel='$C_1/C_0$')\n", + " for ii, nside in enumerate(nsides):\n", + " ax.plot(xx, np.median(yy[ii], axis=-1), color=colors[ii], label=('$\\ell=%d$, $\\ell_\\mathrm{max}=%d,$ nside=%d' % (ll, lmax, nside)))\n", + " for pp in [50,]:\n", + " percs = pp/2\n", + " percs = [50-percs, 50+percs]\n", + " ax.fill_between(xx, *np.percentile(yy[ii], percs, axis=-1), alpha=0.25, color=colors[ii])\n", + "\n", + " ax.legend()\n", + " ax.set_title('Sample %d, Realization %d, $\\ell$=%d, $h_c/d\\Omega$' % (nn, rr, ll))\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 4.3 Save npz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "# np.savez(save_loc+'/hcdOm_B684.npz', \n", + "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + "# molldOm_ss08=molldOm_ss08, molldOm_ss16=molldOm_ss16, molldOm_ss32=molldOm_ss32, molldOm_ss64=molldOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + "# molldOm_bg08=molldOm_bg08, molldOm_bg16=molldOm_bg16, molldOm_bg32=molldOm_bg32, molldOm_bg64=molldOm_bg64,# moll_bg128=moll_bg128,\n", + "# molldOm_tt08=molldOm_tt08, molldOm_tt16=molldOm_tt16, molldOm_tt32=molldOm_tt32, molldOm_tt64=molldOm_tt64, #moll_tt128=moll_tt128,\n", + "# CldOm_arrs=CldOm_arrs, nsides=nsides)\n", + "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Simple Function" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "$$ a_{\\ell m} = \\int d\\Omega_n \\Delta T (\\vec{n}) Y^*_{\\ell m} (\\vec{n}) $$\n", + "$$ C_{\\ell m} = \\frac{1}{2\\ell + 1} \\sum_{m=-\\ell}^\\ell |a_{\\ell m}|^2 $$\n", + "\n", + "$$ C_0 = (1) \\int d\\Omega \\cdot \\frac{h_c^2}{d\\Omega} \\cdot \\mathrm {constant} $$" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def solid_angle(nside):\n", + "# area = hp.nside2pixarea(nside, degrees=False) # \n", + "# return area\n", + "\n", + "# def C0_integral(moll2_ss, nside, Y00star=1):\n", + "# sum=0\n", + "# dOm = solid_angle(nside)\n", + "# for ii, hc2 in enumerate(moll2_ss):\n", + "# sum += Y00star * hc2 * dOm\n", + "# return sum\n", + "\n", + "# ff = 1\n", + "# rr = 0\n", + "# dOmega =solid_angle(nside=8)\n", + "# print(dOmega)\n", + "# C0ss_08 = C0_integral(moll2dOm_ss08[ff,rr], 8)\n", + "# C0ss_16 = C0_integral(moll2dOm_ss16[ff,rr], 16)\n", + "# C0ss_32 = C0_integral(moll2dOm_ss32[ff,rr], 32)\n", + "# C0ss_64 = C0_integral(moll2dOm_ss64[ff,rr], 64)\n", + "# C0ss_128 = C0_integral(moll2dOm_ss128[ff,rr], 125)\n", + "\n", + "\n", + "# C0tt_08 = C0_integral(moll2dOm_tt08[ff,rr], 8)\n", + "# C0tt_16 = C0_integral(moll2dOm_tt16[ff,rr], 16)\n", + "# C0tt_32 = C0_integral(moll2dOm_tt32[ff,rr], 32)\n", + "# C0tt_64 = C0_integral(moll2dOm_tt64[ff,rr], 64)\n", + "# C0tt_128 = C0_integral(moll2dOm_tt128[ff,rr], 125)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# nsides = np.array([8, 16, 32, 64, 128])\n", + "# C0ss = np.array([C0ss_08, C0ss_16, C0ss_32, C0ss_64, C0ss_128])\n", + "# C0tt = np.array([C0tt_08, C0tt_16, C0tt_32, C0tt_64, C0tt_128])\n", + "\n", + "# fig, ax = plot.figax(xlabel='nside', ylabel=r'$\\int d\\Omega \\frac{h_c^2}{d\\Omega}$')\n", + "# ax.plot(nsides, C0ss, marker='o', label='ss only')\n", + "# ax.plot(nsides, C0tt, marker='o', label='total map')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "l/ 2 pi r = theta / 2 pi \n", + "l = theta r\n", + "l^2 = theta^2 r^2 = area\n", + "omega = area / r^2 = theta ^2 r^2 / r^2 = theta^2" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb b/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb index b33af17e..ec6108c1 100644 --- a/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb +++ b/ecg-notebooks/anisotropy/healpix/varying_nside_hc2dOm.ipynb @@ -24,7 +24,7 @@ "metadata": {}, "outputs": [], "source": [ - "nn=346\n", + "nn=684\n", "sspath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", "hdfname = sspath+'sam_lib.hdf5'\n", "ssfile = h5py.File(hdfname, 'r')\n", @@ -50,6 +50,66 @@ "# 1 hc\n" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 1.0A Calculate and save NPZ" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# place single sources at random pixels, for one map\n", + "def make_ss_map(hc_ss, nside, pix_ss=None):\n", + " npix = hp.nside2npix(nside)\n", + " if pix_ss is None:\n", + " pix_ss = np.random.randint(0, npix-1, size=hc_ss.size).reshape(hc_ss.shape)\n", + " moll_ss = np.zeros((len(hc_ss), len(hc_ss[0]), npix,))\n", + " for ff in range(hc_ss.shape[-3]):\n", + " for rr in range(hc_ss.shape[-2]):\n", + " for ll in range(hc_ss.shape[-1]):\n", + " moll_ss[ff,rr,pix_ss[ff,rr,ll]] = np.sqrt(moll_ss[ff,rr,pix_ss[ff,rr,ll]]**2\n", + " + hc_ss[ff,rr,ll]**2)\n", + " return moll_ss, pix_ss\n", + "moll_ss08, pix_ss08 = make_ss_map(hc_ss, 8)\n", + "print(f\"{moll_ss08.shape=}\")\n", + "print(f\"{pix_ss08.shape=}\")\n", + "\n", + "\n", + "def convert_pix_ss(pix_ss1, nside1, nside2):\n", + " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", + " print(f\"{theta.shape=}, {phi.shape=}\")\n", + " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", + " return pix_ss2\n", + "\n", + "pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", + "pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", + "pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", + "# pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", + "\n", + "np.savez(save_loc+'/pix_ss_B684.npz', \n", + " pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64,) #pix_ss128=pix_ss128,\n", + " # moll2dOm_ss08=moll2dOm_ss08, moll2dOm_ss16=moll2dOm_ss16, moll2dOm_ss32=moll2dOm_ss32, moll2dOm_ss64=moll2dOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + " # moll2dOm_bg08=moll2dOm_bg08, moll2dOm_bg16=moll2dOm_bg16, moll2dOm_bg32=moll2dOm_bg32, moll2dOm_bg64=moll2dOm_bg64,# moll_bg128=moll_bg128,\n", + " # moll2dOm_tt08=moll2dOm_tt08, moll2dOm_tt16=moll2dOm_tt16, moll2dOm_tt32=moll2dOm_tt32, moll2dOm_tt64=moll2dOm_tt64, #moll_tt128=moll_tt128,\n", + " # Cl2dOm_arrs=Cl2dOm_arrs, nsides=nsides)\n", + " # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -65,7 +125,7 @@ "outputs": [], "source": [ "save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", - "hcfile = np.load(save_loc+'/hc_A.npz')\n", + "hcfile = np.load(save_loc+'/pix_ss_B684.npz')\n", "\n", "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, pix_ss128=pix_ss128,\n", "# moll_ss08=moll_ss08, moll_ss16=moll_ss16, moll_ss32=moll_ss32, moll_ss64=moll_ss64, moll_ss128=moll_ss128,\n", @@ -85,24 +145,6 @@ "nsides=np.array([8,16,32,64])" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def convert_pix_ss(pix_ss1, nside1, nside2):\n", - " theta, phi = hp.pix2ang(nside1, pix_ss1)\n", - " print(f\"{theta.shape=}, {phi.shape=}\")\n", - " pix_ss2 = hp.ang2pix(nside2, theta, phi).reshape(pix_ss1.shape)\n", - " return pix_ss2\n", - "\n", - "# pix_ss16 = convert_pix_ss(pix_ss08, 8, 16)\n", - "# pix_ss32 = convert_pix_ss(pix_ss08, 8, 32)\n", - "# pix_ss64 = convert_pix_ss(pix_ss08, 8, 64)\n", - "# # pix_ss128 = convert_pix_ss(pix_ss08, 8, 128)" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -351,14 +393,21 @@ "outputs": [], "source": [ "# save_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/healpix/varying_nside_testnpz'\n", - "# np.savez(save_loc+'/hc2dOm_A.npz', \n", - "# pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", - "# moll2dOm_ss08=moll2dOm_ss08, moll2dOm_ss16=moll2dOm_ss16, moll2dOm_ss32=moll2dOm_ss32, moll2dOm_ss64=moll2dOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", - "# moll2dOm_bg08=moll2dOm_bg08, moll2dOm_bg16=moll2dOm_bg16, moll2dOm_bg32=moll2dOm_bg32, moll2dOm_bg64=moll2dOm_bg64,# moll_bg128=moll_bg128,\n", - "# moll2dOm_tt08=moll2dOm_tt08, moll2dOm_tt16=moll2dOm_tt16, moll2dOm_tt32=moll2dOm_tt32, moll2dOm_tt64=moll2dOm_tt64, #moll_tt128=moll_tt128,\n", - "# Cl2dOm_arrs=Cl2dOm_arrs, nsides=nsides)\n", - "# # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" + "np.savez(save_loc+'/hc2dOm_B684.npz', \n", + " pix_ss08=pix_ss08, pix_ss16=pix_ss16, pix_ss32=pix_ss32, pix_ss64=pix_ss64, #pix_ss128=pix_ss128,\n", + " moll2dOm_ss08=moll2dOm_ss08, moll2dOm_ss16=moll2dOm_ss16, moll2dOm_ss32=moll2dOm_ss32, moll2dOm_ss64=moll2dOm_ss64, #moll2dOm_ss128=moll2dOm_ss128,\n", + " moll2dOm_bg08=moll2dOm_bg08, moll2dOm_bg16=moll2dOm_bg16, moll2dOm_bg32=moll2dOm_bg32, moll2dOm_bg64=moll2dOm_bg64,# moll_bg128=moll_bg128,\n", + " moll2dOm_tt08=moll2dOm_tt08, moll2dOm_tt16=moll2dOm_tt16, moll2dOm_tt32=moll2dOm_tt32, moll2dOm_tt64=moll2dOm_tt64, #moll_tt128=moll_tt128,\n", + " Cl2dOm_arrs=Cl2dOm_arrs, nsides=nsides)\n", + " # Cl_08=Cl_08, Cl_16=Cl_16, Cl_32=Cl_32, Cl_64=Cl_64, Cl_128=Cl_128)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb b/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb index 703265ee..46a9ede2 100644 --- a/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb +++ b/ecg-notebooks/anisotropy/healpix/vn2_ClC0_eqs.ipynb @@ -109,10 +109,10 @@ " alm = calc_alm(ell, emm, func, nside)\n", " sum += alm*np.conjugate(alm)\n", " Cl = 1/(2*ell + 1) * sum\n", - " if Cl.imag != 0:\n", - " print(f\"warning! {Cl=} contains imaginary numbers\")\n", - " print(f\"{alm=}\")\n", - " return Cl\n", + " # if Cl.imag != 0:\n", + " # # print(f\"warning! {Cl=} contains imaginary numbers\")\n", + " # # print(f\"{alm=}\")\n", + " # return Cl\n", " return Cl.real" ] }, @@ -146,6 +146,14 @@ " print('C_%d = %.2e' % (ll, Cl_arr[ll]))" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# ff=1, rr=0, ll=1" + ] + }, { "cell_type": "code", "execution_count": null, @@ -208,6 +216,8 @@ "metadata": {}, "outputs": [], "source": [ + "ff=1\n", + "rr=1\n", "\n", "nsides = np.array([8, 16, 32, 64])\n", "colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", @@ -436,6 +446,203 @@ "fig" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Different realizations and frequencies" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_Cl_vs_l" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_Cl_vs_l(ff, rr, lmax):\n", + " xx = np.arange(lmax+1)\n", + "\n", + " nsides = np.array([8, 16, 32, 64])\n", + " colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell$', xscale='linear',\n", + " figsize=(6,4))\n", + "\n", + " for ii, nside in enumerate(nsides):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " # moll = anis.healpix_map(hc_ss[ff:ff+1,rr:rr+1], hc_bg[ff:ff+1,rr:rr+1], nside)\n", + " # moll = np.squeeze(moll)\n", + " moll = moll_arrs[ii][ff,rr]\n", + "\n", + " Cl_arr = np.zeros(lmax+1)\n", + " Cl_hpy = hp.anafast(moll, lmax=lmax)\n", + " for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside)\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + "\n", + " yy = Cl_arr\n", + " ax.plot(xx, yy, label = 'From Eq. (3), nside=%d' % nside,\n", + " color=colors[ii], linestyle='-', marker='o')\n", + " # ax.plot(xx, Cl2dOm_arrs[ii,ff,rr,:], color=colors[ii], linestyle=':',\n", + " # label=('hp.anafast, nside=%d' % (nside)))\n", + " ax.plot(xx, Cl_hpy[:], color=colors[ii], linestyle=':', marker='x',\n", + " label=('hp.anafast, nside=%d' % (nside)))\n", + "\n", + " ax.legend(fontsize=10, loc='upper right')\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot_ClC0_vs_l" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_ClC0_vs_l(ff, rr, lmax):\n", + " xx = np.arange(1,lmax+1)\n", + "\n", + " nsides = np.array([8, 16, 32, 64])\n", + " colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + " fig, ax = plot.figax(xlabel='$\\ell$', ylabel='$C_\\ell/C_0$', xscale='linear',\n", + " figsize=(6,4))\n", + "\n", + " for ii, nside in enumerate(nsides):\n", + " npix = hp.nside2npix(nside)\n", + " area = hp.nside2pixarea(nside)\n", + " theta, phi = hp.pix2ang(nside, np.arange(npix))\n", + " moll = moll_arrs[ii][ff,rr]\n", + "\n", + " Cl_arr = np.zeros(lmax+1)\n", + " Cl_hpy = hp.anafast(moll, lmax=lmax)\n", + " for ll in range(lmax+1):\n", + " Cl_arr[ll] = calc_Cl(ll, moll, nside)\n", + " # print('C_%d = %.2e' % (ll, Cl_arr[ll]))\n", + "\n", + " \n", + " y1 = Cl_arr[1:]/Cl_arr[0]\n", + " y2 = Cl_hpy[1:]/Cl_hpy[0]\n", + " ax.plot(xx, y1, label = 'From Eq. (3), nside=%d' % nside,\n", + " color=colors[ii])\n", + " # ax.plot(xx, Cl2dOm_arrs[ii,ff,rr,:], color=colors[ii], linestyle=':',\n", + " # label=('hp.anafast, nside=%d' % (nside)))\n", + " ax.plot(xx, y2, color=colors[ii], linestyle=':',\n", + " label=('hp.anafast, nside=%d' % (nside)))\n", + "\n", + " ax.legend(fontsize=8, loc='upper right')\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + " fig.tight_layout()\n", + " return fig\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_C0_vs_nside(ff, rr, lmax):\n", + "\n", + " nsides = np.array([8, 16, 32, 64])\n", + " xx = np.arange(len(nsides))\n", + " # colors = cm.rainbow(np.linspace(0, 1, len(nsides)))\n", + " fig, ax = plot.figax(xlabel='$N_\\mathrm{side}$', ylabel='$C_{\\ell=0}$', xscale='log',\n", + " figsize=(5,3))\n", + "\n", + " # Calculate Cl from Eqs.\n", + " moll = moll_arrs[ii][ff,rr]\n", + " C0_arr = np.zeros(len(nsides))\n", + " C0_hpy = np.zeros(len(nsides))\n", + " for nn, nside in enumerate(nsides):\n", + " moll = moll_arrs[nn][ff,rr]\n", + " C0_arr[nn] = calc_Cl(0, moll, nside)\n", + " C0_hpy[nn] = hp.anafast(moll, lmax=lmax)[0]\n", + "\n", + " y1 = C0_arr\n", + " y2 = C0_hpy\n", + " ax.plot(xx, y1, label = 'From Eq. (3)' % nside, linestyle='-')\n", + " ax.plot(xx, y2, label=('hp.anafast' % (nside)), linestyle=':', )\n", + "\n", + " ax.legend(fontsize=12, loc='lower right')\n", + " ax.set_title('Sample %d, Realization %d, $f$=%.2f/yr, $h_c^2/d\\Omega$' % (nn, rr, fobs[ff]*YR, ))\n", + " fig.tight_layout()\n", + " return fig\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "C0 vs nside" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for rr in range(10):\n", + " fig = plot_C0_vs_nside(1, rr, lmax)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Cl Comparison" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for rr in range(10):\n", + " fig = plot_Cl_vs_l(1, rr, lmax)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "ClC0 comparison" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for rr in range(10):\n", + " fig = plot_ClC0_vs_l(1, rr, lmax)\n" + ] + }, { "cell_type": "code", "execution_count": null, From 953dcb19ee3b210aa19bb0d6db25b780234afe02 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 16 Jun 2023 15:40:46 -0700 Subject: [PATCH 073/291] Corrected paper plots with twin_yr axis. --- .../compare_models_hc2dOm.ipynb | 122 +++++++++++++++++- 1 file changed, 117 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb index 9835c18f..bbe24b59 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/compare_models_hc2dOm.ipynb @@ -189,8 +189,9 @@ "outputs": [], "source": [ "def plot_ClC0_medians(xx, Cl_best, lmax, nshow, xx_Nihan, Cl_nihan,\n", - " figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$'):\n", - " fig, ax = plot.figax(figsize=figsize, xlabel=xlabel, ylabel=ylabel,)\n", + " figsize=(7,6), xlabel=plot.LABEL_GW_FREQUENCY_HZ, ylabel='$C_{\\ell}/C_0$',\n", + " yscale='log'):\n", + " fig, ax = plot.figax(figsize=figsize, xlabel=xlabel, ylabel=ylabel, yscale=yscale)\n", "\n", " yy = Cl_best[:,:,:,1:]/Cl_best[:,:,:,0,np.newaxis] # (B,F,R,l)\n", " yy = np.median(yy, axis=-1) # (B,F,l) median over realizations\n", @@ -215,9 +216,9 @@ " # Add Nihan's data\n", " ax.plot(xx_Nihan, Cl_nihan[:,ll], \n", " label = '$l=%d$' % (ll+1), \n", - " color=colors[ll], marker='o', ms=5)\n", + " color=colors[ll], marker='o', linestyle='--', ms=5)\n", " \n", - " plot._twin_yr(ax, nano=False)\n", + " # plot._twin_yr(ax, nano=False)\n", " ax.set_xlabel(xlabel, fontsize=11)\n", " ax.set_ylabel(ylabel, fontsize=11)\n", " # ax.set_title('50%% and 98%% confidence intervals of the %d best samples \\nusing realizations medians, lmax=%d'\n", @@ -906,12 +907,123 @@ "fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Uniform_09B" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 09B ns08" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "pspace = 'Uniform_09B'\n", + "nside = 8\n", + "\n", + "filename1 = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss60_anis09B_2023-06-16_uniform-09b_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-99.npz'\n", + "\n", + "vals = read_one_anis_file(filename1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = vals['fobs']\n", + "lmax = vals['lmax']\n", + "Cl_best = vals['Cl_best']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lvals = np.arange(lmax+1)\n", + "fobs_nHz = fobs*10**9\n", + "fobs_yrs = fobs*YR\n", + "ff_labels = (0,9,19,29,39)\n", + "nshow = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians(fobs, Cl_best, lmax, nshow=0, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " figsize=(7/1.65, 6/1.65), yscale='log')\n", + "ax = fig.axes[0]\n", + "\n", + "ax.set_xlim(fobs[0]-10**-10, 1/YR) # fontsize of the x and y labels\n", + "plt.rc('xtick', labelsize=10) # fontsize of the tick labels\n", + "plt.rc('ytick', labelsize=10) \n", + "\n", + "# fig1.legend(bbox_to_anchor=(0,0), loc='upper left', bbox_transform=ax.transAxes)\n", + "ax.legend(loc='lower right', ncols=3, fontsize=8)\n", + "ax.set_ylim(0,0.6)\n", + "\n", + "plot._twin_yr(ax, nano=False)\n", + "\n", + "fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/model09B_ClC0_ns%d.png' % nside, dpi=300)\n", + "# fig.text(0.05,1, 'nside=%d' % nside)\n", + "# fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best, lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### 25 best (09B ns08)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_ClC0_medians_big(fobs, Cl_best[:25], lmax, nshow=25, xx_Nihan=freq_bins_Hz, Cl_nihan=Cl_nihan,\n", + " show_spk=True, xmin = fobs[0]-10**-10, xmax = 1/YR, ymin = 10**-4, ymax = 1.5)\n", + "ax = fig.axes[0]\n", + "ax.legend(loc='lower right', ncols=4)\n", + "\n", + "fig.text(0.05,1, 'nside=%d, pspace=%s, best 25' % (nside, pspace), fontsize=14)\n", + "fig.tight_layout()" + ] }, { "cell_type": "code", From 7c6b97d433da2fd0e68528aa3985013762e38c05 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 10:49:37 -0700 Subject: [PATCH 074/291] added expectation value (ev) calculation to detect_lib() in detstats.py --- holodeck/detstats.py | 65 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index f3c809a1..d28e889a 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1578,11 +1578,12 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, Signal to noise ratio of the background at each frequency of each realization. df_ss : (N,) - Fraction of realizations with a single source detection. + Fraction of realizations with a single source detection, for each sample. df_bg : (N,) 1Darray - Fraction of realizations with a background detection. - - TODO: Speed it up by doing the gamma_ssi integration in cython. + Fraction of realizations with a background detection, for each sample. + ev_ss : (N,) 1Darray + Expectation number of single source detections, averaged across realizations, + for each sample. """ @@ -1625,6 +1626,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, snr_bg = np.zeros((nsamp, nfreqs, nreals)) df_ss = np.zeros(nsamp) df_bg = np.zeros(nsamp) + ev_ss = np.zeros(nsamp) gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) # # one time calculations @@ -1640,8 +1642,10 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) dp_ss[nn,:,:], snr_ss[nn,...], gamma_ssi[nn] = vals_ss[0], vals_ss[1], vals_ss[2] - df_ss[nn] = np.sum(dp_ss[nn]>thresh)/(nreals*nskies) - df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) + # df_ss[nn] = np.sum(dp_ss[nn]>thresh)/(nreals*nskies) + # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) + df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) + ev_ss[nn] = expval_of_ss(gamma_ssi) if plot: fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], @@ -1661,7 +1665,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, snr_ss=snr_ss, snr_bg=snr_bg, gamma_ssi=gamma_ssi) - return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg + return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg, ev_ss def _build_skies(nfreqs, nskies, nloudest): @@ -1673,6 +1677,53 @@ def _build_skies(nfreqs, nskies, nloudest): return theta_ss, phi_ss, Phi0_ss, iota_ss, psi_ss +def detfrac_of_reals(dp_ss, dp_bg, thresh=DEF_THRESH): + """ Calculate the fraction of realizations with a detection. + + Parameters + ---------- + dp_ss : (R,S) Ndarray + Single source detection probability for each of + dp_bg : (R) Ndarray + Background detectin probability. + thresh : float + Fractional threshold for DP to claim a detection. + + Returns + ------- + df_ss : float + Fraction of realizations with dp_ss>threshold + def_bg : float + Fraction of realizations with dp_bg>threshold + """ + + df_ss = np.sum(dp_ss>thresh)/(dp_ss.size) + df_bg = np.sum(dp_bg>thresh)/(dp_bg.size) + return df_ss, df_bg + + + +def expval_of_ss(gamma_ssi, thresh=DEF_THRESH): + """ Calculate the expected number of single source detections for a given realization + + Parameters + ---------- + gamma_ssi : (F,R,S,L) NDarray + Detection probability of each single source + + Returns + ------- + ev_ss : int + Expected number of single source detection (dp_ss>thresh) averaged across all strain and sky realizations. + + """ + + ev_ss = np.sum(gamma_ssi>thresh)/(gamma_ssi.size) + return ev_ss + # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) + + + ############################# Plot Library ############################# def plot_sample_nn(fobs, hc_ss, hc_bg, dp_ss, dp_bg, df_ss, df_bg, nn): From 3244202cdc3f7c0eb74fa17894a3abba48b99f04 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 11:53:31 -0700 Subject: [PATCH 075/291] corrected expectation value function and removed it from library calculations. --- holodeck/detstats.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index d28e889a..eb2ecf64 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1581,9 +1581,6 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, Fraction of realizations with a single source detection, for each sample. df_bg : (N,) 1Darray Fraction of realizations with a background detection, for each sample. - ev_ss : (N,) 1Darray - Expectation number of single source detections, averaged across realizations, - for each sample. """ @@ -1626,7 +1623,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, snr_bg = np.zeros((nsamp, nfreqs, nreals)) df_ss = np.zeros(nsamp) df_bg = np.zeros(nsamp) - ev_ss = np.zeros(nsamp) + # ev_ss = np.zeros(nsamp) gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) # # one time calculations @@ -1645,7 +1642,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, # df_ss[nn] = np.sum(dp_ss[nn]>thresh)/(nreals*nskies) # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) - ev_ss[nn] = expval_of_ss(gamma_ssi) + # ev_ss[nn] = expval_of_ss(gamma_ssi) if plot: fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], @@ -1665,7 +1662,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, snr_ss=snr_ss, snr_bg=snr_bg, gamma_ssi=gamma_ssi) - return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg, ev_ss + return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg #, ev_ss def _build_skies(nfreqs, nskies, nloudest): @@ -1703,8 +1700,8 @@ def detfrac_of_reals(dp_ss, dp_bg, thresh=DEF_THRESH): -def expval_of_ss(gamma_ssi, thresh=DEF_THRESH): - """ Calculate the expected number of single source detections for a given realization +def expval_of_ss(gamma_ssi,): + """ Calculate the expected number of single source detections, across all realization Parameters ---------- @@ -1717,8 +1714,8 @@ def expval_of_ss(gamma_ssi, thresh=DEF_THRESH): Expected number of single source detection (dp_ss>thresh) averaged across all strain and sky realizations. """ - - ev_ss = np.sum(gamma_ssi>thresh)/(gamma_ssi.size) + nfreqs, nreals, nskies, nloudest = [*gamma_ssi.size] + ev_ss = np.sum(gamma_ssi)/(nreals*nskies) return ev_ss # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) @@ -1848,7 +1845,7 @@ def plot_detfrac(df_ss, df_bg, nsamp, thresh): def amp_to_hc(amp_ref, fobs, dfobs): - """ Calculate characteristic strain from strain amplitude. + """ Calculate characteristic strain from strain amplitude (from 1/yr amplitude). """ hc = amp_ref*np.sqrt(fobs/dfobs) From 4df10486fb2e191b8604b765d67c32f733e9ca65 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 12:04:23 -0700 Subject: [PATCH 076/291] Added ev back to library calculation, because it requires gamma_ssi which is too large to store. --- holodeck/detstats.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index eb2ecf64..f34c828e 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1581,6 +1581,9 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, Fraction of realizations with a single source detection, for each sample. df_bg : (N,) 1Darray Fraction of realizations with a background detection, for each sample. + ev_ss : (N,) 1Darray + Expectation number of single source detections, averaged across realizations, + for each sample. """ @@ -1623,7 +1626,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, snr_bg = np.zeros((nsamp, nfreqs, nreals)) df_ss = np.zeros(nsamp) df_bg = np.zeros(nsamp) - # ev_ss = np.zeros(nsamp) + ev_ss = np.zeros(nsamp) gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) # # one time calculations @@ -1642,7 +1645,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, # df_ss[nn] = np.sum(dp_ss[nn]>thresh)/(nreals*nskies) # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) - # ev_ss[nn] = expval_of_ss(gamma_ssi) + ev_ss[nn] = expval_of_ss(gamma_ssi) if plot: fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], @@ -1662,7 +1665,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, snr_ss=snr_ss, snr_bg=snr_bg, gamma_ssi=gamma_ssi) - return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg #, ev_ss + return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg, ev_ss def _build_skies(nfreqs, nskies, nloudest): From 505e30182222131625818cd2dcc81008ca89c38b Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 12:20:32 -0700 Subject: [PATCH 077/291] Updated detect_lib to have option of returning dict, otherwise return nothing. Also has option to calculate and save gamma_ssi, which takes up huge amounts of space. --- holodeck/detstats.py | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index f34c828e..79528223 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1538,7 +1538,8 @@ def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, dur=None, cad=None, dfobs=None, plot=True, debug=False, - grid_path=GAMMA_RHO_GRID_PATH, snr_cython = True): + grid_path=GAMMA_RHO_GRID_PATH, snr_cython = True, + save_ssi=False, ret_dict=False): """ Calculate detection statistics for an ss library output. Parameters @@ -1559,6 +1560,12 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, Whether or not to make and save plots. debug : Bool Whether to print info along the way. + grid_path : string + Path to snr interpolation grid + snr_cython : Bool + Whether to use cython interpolation for ss snr calculation. + save_ssi : Bool + Whether to store gamma_ssi in npz arrays Returns ------- @@ -1627,7 +1634,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, df_ss = np.zeros(nsamp) df_bg = np.zeros(nsamp) ev_ss = np.zeros(nsamp) - gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) + if save_ssi: gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) # # one time calculations # Num = nfreqs * nloudest # number of single sources in a single strain realization (F*L) @@ -1641,11 +1648,10 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, gamma_cython=True, snr_cython=snr_cython, theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) - dp_ss[nn,:,:], snr_ss[nn,...], gamma_ssi[nn] = vals_ss[0], vals_ss[1], vals_ss[2] - # df_ss[nn] = np.sum(dp_ss[nn]>thresh)/(nreals*nskies) - # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) + dp_ss[nn,:,:], snr_ss[nn,...] = vals_ss[0], vals_ss[1], df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) ev_ss[nn] = expval_of_ss(gamma_ssi) + if save_ssi: gamma_ssi[nn] = vals_ss[2] if plot: fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], @@ -1662,10 +1668,22 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, fig2.savefig(output_dir+'/allsamp_detfracs.png', dpi=300) plt.close(fig1) plt.close(fig2) - np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, - df_ss=df_ss, df_bg=df_bg, snr_ss=snr_ss, snr_bg=snr_bg, gamma_ssi=gamma_ssi) - - return dp_ss, dp_bg, df_ss, df_bg, snr_ss, snr_bg, ev_ss + if save_ssi: + np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss, gamma_ssi=gamma_ssi) + else: + np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss) + + # return dictionary + if ret_dict: + data = { + 'dp_ss':dp_ss, 'dp_bg':dp_bg, 'df_ss':df_ss, 'df_bg':df_bg, + 'snr_ss':snr_ss, 'snr_bg':snr_bg, 'ev_ss':ev_ss + } + if save_ssi: data.update({'gamma_ssi':gamma_ssi}) + return data + return def _build_skies(nfreqs, nskies, nloudest): From 28d9cff510e8a390e2649e138166d5aca108e9e0 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 12:58:46 -0700 Subject: [PATCH 078/291] Debugged and tested detect_lib with dict and ev returned, with and without gamma_ssi in detect_lib_ev.ipynb --- .../lib_detstats/ds1_detect_lib_ev.ipynb | 135 ++++++++++++++++++ .../parameter_investigation/take1.ipynb | 8 ++ ecg-notebooks/scratch_ds.ipynb | 61 ++++++++ ecg-notebooks/scratch_libs.ipynb | 2 +- holodeck/detstats.py | 6 +- 5 files changed, 209 insertions(+), 3 deletions(-) create mode 100644 ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb create mode 100644 ecg-notebooks/scratch_ds.ipynb diff --git a/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb b/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb new file mode 100644 index 00000000..198c7b13 --- /dev/null +++ b/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb @@ -0,0 +1,135 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "from holodeck import plot\n", + "import holodeck.detstats as ds\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "lib_path = '/Users/emigardiner/GWs/holodeck/output/2023-05-09-mbp-ss15_n100_r30_f100_d15_l5_p0'\n", + "hdf_name = lib_path+'/sam_lib.hdf5'\n", + "hdf_file = h5py.File(hdf_name)\n", + "print(hdf_file.keys())\n", + "# params = hdf_file['sample_params'][...]\n", + "# hc_ss = hdf_file['hc_ss'][...]\n", + "# hc_bg = hdf_file['hc_bg'][...]\n", + "# sspar = hdf_file['sspar'][...]\n", + "# bgpar = hdf_file['bgpar'][...]\n", + "fobs = hdf_file['fobs'][:]\n", + "dur = hdf_file['pta_dur'][0]\n", + "cad = hdf_file['pta_cad'][0]\n", + "hdf_file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npsrs = 50\n", + "sigma = 1e-7 \n", + "nskies = 25 \n", + "thresh = 0.5\n", + "nfreqs = len(fobs)\n", + "\n", + "fobs_cents, fobs_edges = holo.utils.pta_freqs(dur, cad)\n", + "dfobs = np.diff(fobs_edges)[:nfreqs]\n", + "assert np.all(fobs_cents[:nfreqs] == fobs), 'fobs should match'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "output_dir = (lib_path+'/detstats/psrs%d_sigma%.2e' % (npsrs, sigma))\n", + "data = ds.detect_lib(hdf_name, output_dir, npsrs=npsrs, sigma=sigma, nskies=nskies, thresh=thresh,\n", + " plot=True, debug=True, dur=dur, cad=cad, dfobs=dfobs, \n", + " save_ssi=False, ret_dict=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time data1 = ds.detect_lib(hdf_name, output_dir, npsrs=npsrs, sigma=sigma, nskies=nskies, thresh=thresh, \\\n", + " plot=True, debug=True, dur=dur, cad=cad, dfobs=dfobs, \\\n", + " save_ssi=False, ret_dict=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time data2 = ds.detect_lib(hdf_name, output_dir, npsrs=npsrs, sigma=sigma, nskies=nskies, thresh=thresh, \\\n", + " plot=True, debug=True, dur=dur, cad=cad, dfobs=dfobs, \\\n", + " save_ssi=True, ret_dict=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data['ev_ss'].shape)\n", + "print(holo.utils.stats(data['ev_ss']))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/take1.ipynb b/ecg-notebooks/parameter_investigation/take1.ipynb index d1981f49..6e52c845 100644 --- a/ecg-notebooks/parameter_investigation/take1.ipynb +++ b/ecg-notebooks/parameter_investigation/take1.ipynb @@ -74,6 +74,14 @@ "ds_file.close()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Calculate expectation values" + ] + }, { "attachments": {}, "cell_type": "markdown", diff --git a/ecg-notebooks/scratch_ds.ipynb b/ecg-notebooks/scratch_ds.ipynb new file mode 100644 index 00000000..f453ec53 --- /dev/null +++ b/ecg-notebooks/scratch_ds.ipynb @@ -0,0 +1,61 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "# import holodeck as holo\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "arr = np.zeros((3,4,5))\n", + "print(*arr.shape)\n", + "x, y, z = [*arr.shape]\n", + "print(x,y,z)\n", + "print(z)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/scratch_libs.ipynb b/ecg-notebooks/scratch_libs.ipynb index d3448dc6..a049f997 100644 --- a/ecg-notebooks/scratch_libs.ipynb +++ b/ecg-notebooks/scratch_libs.ipynb @@ -48,7 +48,7 @@ "metadata": {}, "outputs": [], "source": [ - "ssfile = h5py.File('/Users/emigardiner/GWs/holodeck/brc_output/ss_lib_ss43.hdf5', 'r')\n", + "ssfile = h5py.File('/Users/emigardiner/GWs/holodeck/output/brc_output/ss_lib_ss43.hdf5', 'r')\n", "list(ssfile.keys())" ] }, diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 79528223..b2ffd817 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1618,6 +1618,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, phis = np.random.uniform(0, 2*np.pi, size = npsrs) thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) # sigmas = np.ones_like(phis)*sigma + if debug: print(f"{phis.shape=}, {thetas.shape=}, {dur=}, {cad=}, {sigma=}") psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) @@ -1650,7 +1651,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) dp_ss[nn,:,:], snr_ss[nn,...] = vals_ss[0], vals_ss[1], df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) - ev_ss[nn] = expval_of_ss(gamma_ssi) + ev_ss[nn] = expval_of_ss(vals_ss[2]) if save_ssi: gamma_ssi[nn] = vals_ss[2] if plot: @@ -1735,7 +1736,8 @@ def expval_of_ss(gamma_ssi,): Expected number of single source detection (dp_ss>thresh) averaged across all strain and sky realizations. """ - nfreqs, nreals, nskies, nloudest = [*gamma_ssi.size] + print(f"{gamma_ssi.shape=}, {[*gamma_ssi.shape]}") + nfreqs, nreals, nskies, nloudest = [*gamma_ssi.shape] ev_ss = np.sum(gamma_ssi)/(nreals*nskies) return ev_ss # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) From 7ff4bf7e04c01b39fe1beced6719f1de628424a4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 14:17:59 -0700 Subject: [PATCH 079/291] Checked detect_libe_script results, gamma_ssi and ev look good. --- .../lib_detstats/ds1_detect_lib_ev.ipynb | 51 +++++++++++++++++++ scripts/detect_lib_script.py | 8 ++- 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb b/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb index 198c7b13..9f691abc 100644 --- a/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb +++ b/ecg-notebooks/detstats_functions/lib_detstats/ds1_detect_lib_ev.ipynb @@ -103,6 +103,57 @@ "print(holo.utils.stats(data['ev_ss']))" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Check script results (ss15)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/2023-05-09-mbp-ss15_n100_r30_f100_d15_l5_p0/detstats/psrs60_sigma2.50e-06'\n", + "filename = path+'/detstats.npz'\n", + "file = np.load(filename)\n", + "print(file.files)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ev_ss = file['ev_ss']\n", + "gamma_ssi = file['gamma_ssi']\n", + "file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xscale='linear', xlabel='n', ylabel='expval ss')\n", + "ax.scatter(np.arange(ev_ss.size), ev_ss)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(gamma_ssi.shape)\n", + "print(holo.utils.stats(gamma_ssi[1,2,10,0]))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/scripts/detect_lib_script.py b/scripts/detect_lib_script.py index b034fe02..682cec0c 100644 --- a/scripts/detect_lib_script.py +++ b/scripts/detect_lib_script.py @@ -13,6 +13,8 @@ DEF_NSKIES = 25 DEF_THRESH = 0.5 +DEF_SNR_CYTHON = True +DEF_SAVE_SSI = False GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system @@ -42,8 +44,10 @@ def _setup_argparse(): help='produce plots for each simulation configuration') parser.add_argument('--debug', action='store_true', default=False, help='print steps along the way') - parser.add_argument('--snr_cython', action='store_true', default=False, + parser.add_argument('--snr_cython', action='store_true', default=DEF_SNR_CYTHON, help='Use cython for ss snr clculations') + parser.add_argument('--save_ssi', action='store_true', default=DEF_SAVE_SSI, + help="Save 'gamma_ssi', the detprob of each single source.") args = parser.parse_args() return args @@ -80,7 +84,7 @@ def main(): ds.detect_lib(hdf_name, output_dir, args.npsrs, args.sigma, nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, dur=dur, cad=cad, dfobs=dfobs, grid_path=args.grid_path, - snr_cython=args.snr_cython) + snr_cython=args.snr_cython, save_ssi=args.save_ssi) if __name__ == "__main__": From 424e01934ddc9aac47016930e198af6cf4c8e616 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 14:20:31 -0700 Subject: [PATCH 080/291] Stripped notebook outputs of double-schechter.ipynb --- notebooks/devs/sams/double-schechter.ipynb | 133 +++------------------ 1 file changed, 14 insertions(+), 119 deletions(-) diff --git a/notebooks/devs/sams/double-schechter.ipynb b/notebooks/devs/sams/double-schechter.ipynb index afdf0716..93824bb5 100644 --- a/notebooks/devs/sams/double-schechter.ipynb +++ b/notebooks/devs/sams/double-schechter.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -42,20 +42,9 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGnCAYAAAB/37dsAAAAOXRFWHRTb2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QRCmFRG8CIIgCIIwrYjgRRAEQRCEaeX/B1p1qSmC+ne4AAAAAElFTkSuQmCC", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "gsmf = holo.sams.comps.GSMF_Double_Schechter()\n", "\n", @@ -89,38 +78,9 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "22:43:41 INFO : Adding MMbulge scatter (2.8000e-01) [sam.py:static_binary_density]\n", - "22:43:41 INFO : \tdens bef: (0.00e+00, 0.00e+00, 1.16e-89, 1.85e-03, 3.85e-02, 1.16e-01, 3.06e-01) [sam.py:static_binary_density]\n", - "22:43:42 INFO : Scatter added after 0.680907 sec [sam.py:static_binary_density]\n", - "22:43:42 INFO : \tdens aft: (4.49e-61, 1.81e-12, 7.59e-10, 1.97e-03, 3.95e-02, 1.16e-01, 2.85e-01) [sam.py:static_binary_density]\n", - "22:43:42 INFO : \tmass: 2.12e-01 ==> 2.12e-01 || change = 1.5723e-03 [sam.py:static_binary_density]\n", - "22:43:42 INFO : zeroing out 1.08e+04/2.70e+04 = 4.00e-01 bins stalled from GMT [sam.py:static_binary_density]\n", - "22:43:44 INFO : Adding MMbulge scatter (2.8000e-01) [sam.py:static_binary_density]\n", - "22:43:44 INFO : \tdens bef: (6.82e-282, 2.78e-158, 1.16e-30, 1.24e-03, 1.63e-02, 3.00e-02, 6.20e-02) [sam.py:static_binary_density]\n", - "22:43:45 INFO : Scatter added after 0.740555 sec [sam.py:static_binary_density]\n", - "22:43:45 INFO : \tdens aft: (7.79e-27, 3.92e-12, 8.40e-09, 1.33e-03, 1.63e-02, 2.99e-02, 5.95e-02) [sam.py:static_binary_density]\n", - "22:43:45 INFO : \tmass: 7.23e-02 ==> 7.23e-02 || change = 8.8835e-04 [sam.py:static_binary_density]\n", - "22:43:45 INFO : zeroing out 1.08e+04/2.70e+04 = 4.00e-01 bins stalled from GMT [sam.py:static_binary_density]\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAmQAAAHdCAYAAACzPGWcAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAACqf0lEQVR4nOzdd3zdd3n3/9f37D20hyXvbSfOcHZix1kkAUrZpGGEtukASvujjBR6Q2fgLpTSO4b2LjcBCoEChUJIcPYkw9nxtmVLsiRrS2fP7/j98bFky9KRJVvL0vV8PPzAOufoe74SifTO53N9rkuzLMtCCCGEEELMGtts34AQQgghxEIngUwIIYQQYpZJIBNCCCGEmGUSyIQQQgghZpkEMiGEEEKIWSaBTAghhBBilkkgE0IIIYSYZRLIhBBCCCFmmQQyIYQQQohZJoFMCCGEEGKWSSATQoySy+W4++67ufrqq7n22mu58sorufTSS/nCF77Anj17AHjrW9+K2+2msbGRT3ziE8Ofu3PnTjRNo6mpafixL3zhCzQ0NHDxxReza9euEe+1c+dOtm7diqZprFmzhq1bt4744/F4ZuaLFiWl02keeOABbrjhhtm+FSHmL0sIIU6SyWSsK664wvrEJz5h5XK54cdfeuklq7y83Hrf+943/Nj1119vvf3tbx/x+XfffbcFWP/2b/824vG3ve1tVjweL/m+gHXvvfeOenzx4sVn9oUsIA8++KD153/+59aTTz45re+zZcuW4b9/5zvfse644w6rs7NzWt9TiIVCVsiEECN88YtfJJ1O841vfAO32z38+MUXX8zf/u3fjnjttm3beOqppzAMY/ixZ555hiuuuILHHnts+DFd18lms4RCoUnfz3e+850z+CoWlu7ubj75yU+yZcuWGXvPO+64g2uuuYZcLjdj7ynEfCaBTAgxTNd1/v3f/533v//9aJo26vn3vve93H777cMfb9u2jXg8zquvvgpAoVAgn8/z9re/nSeeeALLsgC1Lbl58+ZJ3UtLSwtbt25l27ZtAPzsZz9j06ZNaJrGAw88wNve9jbq6up4xzveAUC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f2Kax6DVkIiIiInVlh6BtK9hRyI/VezSzokAmIiIiN59IE3RshWoJyo2/O48CmYiIiNycEl3QuhkK4+CV6z2aaSmQiYiIyM3JMKBlPaR6IDMIfuN2i10Rgezhhx9mx44d7N+/v95DERERkeVk2dC+BWLtQShrUCsikB08eJDjx4/P2K5DREREbkJOBDq2gR1p2CL/FRHIREREZIWLNF8s8i83ZJG/ApmIiIisDIkuaNsM+cYr8ldjWBEREVkZLhX5l3Mwcbreo7mKZshERERk5TCtd4r8q6V6j+YyzZCJiIjIynKpyF+BTERERKSOIs3Q+Z6gLUYDaIxRiIiIiCy3WGu9R3CZashERERE6kyBTERERKTOFMhERERE6kyBTERERKTOFMhERERE6mxFBLKHH36YHTt2sH///noPRUREROQaKyKQHTx4kOPHj3P48OF6D0VERETkGisikImIiIg0MgUyERERkTpTIBMRERGpMwUyERERkTpTIBMRERGpMwUyERERkTpTIBMRERGpM7veA1hOtVoNgP7+/jqPRERWMt/3yefzRKNRDMOo93BEZIlcyhuX8sd0VlQgGxwcBGDfvn11HomIiIisFIODg/T09Ex7jOH7vr9M46m7arXKkSNHWLVqFaa5tKu1+/fv184AF93IP4tGHHu9xrQc112qayz2eRd6vkwmw44dOzh+/DiJRGLRxiXLrxF/R9TLjfyzWKqx12o1BgcH2bNnD7Y9/RzYipohs22bvXv3Lsu1QqEQ3d3dy3KtRncj/ywacez1GtNyXHeprrHY513o+dLpNABr1qwhmUwu1rCkDhrxd0S93Mg/i6Uc+0wzY5eoqH+JHDx4sN5DaBg38s+iEcderzEtx3WX6hqLfd5G/HMh9aE/C++4kX8WjTD2FbVkKSLSCNLpNKlUisnJSc2QiQigGTIRkWUXDof5xje+QTgcrvdQRKRBaIZMREREpM40QyYiIiJSZwpkIiIiInWmQCYiIiJSZwpkIiIiInWmQCYi0mBOnTrFfffdx/3331/voYjIMlEgExFpMM899xz33ntvvYchIstIgUxEZJGVy2UeeughbNumr6/vmvefeOIJ7rjjDj7wgQ9w11138dprr131/ic/+Un1KBNZYRTIREQWUV9fH3fddRcXLlzA87xr3n/uued44IEHeOyxx/jVr37FH/3RH3HvvfeSyWTqMFoRaRQKZCIiiyibzfLoo4/yxS9+8brvf+tb3+KjH/0oW7duBeD++++nWq1y6NCh5RymiDQYBTIRkUW0a9cuNm3aNOX7Tz/9NHv37r38tWma3H777fziF79YjuGJSINSIBMRWSajo6NMTk7S2dl51fc7Ozt5++23L3/9k5/8hB//+Me8+uqrfPvb317uYYpIHdj1HoCIyEqRz+cBrinYD4fDl98DOHDgAAcOHFjWsYlIfWmGTERkmUSjUQBKpdJV3y+VSpffE5GVSYFMRGSZtLa2kkqlGBgYuOr7AwMDbNiwoU6jEpFGoEAmIrKM7r77bl544YXLX/u+z0svvcQ999xTx1GJSL0pkImILKMHH3yQp556ihMnTgDw2GOPYVkWn//85+s8MhGpJxX1i4gsonK5zIc//GEmJiYA+NSnPsXatWt5/PHHAdi3bx+HDh3iM5/5DJFIBNM0+fnPf04ikajjqEWk3gzf9/16D0JERERkJdOSpYiIiEidKZCJiIiI1JkCmYiIiEidKZCJiIiI1JkCmYiIiEidKZCJiIiI1JkCmYiIiEidKZCJiIiI1JkCmYiIiEidKZCJiIiI1JkCmYiIiEidKZCJiIiI1Nn/D8ewrOoTdO1mAAAAAElFTkSuQmCC", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "SHAPE = 30\n", "NFREQ = 20\n", @@ -168,25 +128,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " logphi1 : c0 = $ -2.383 \\pm 0.027$\n", - " logphi1 : c1 = $ -0.264 \\pm 0.071$\n", - " logphi1 : c2 = $ -0.107 \\pm 0.030$\n", - " logphi2 : c0 = $ -2.818 \\pm 0.050$\n", - " logphi2 : c1 = $ -0.368 \\pm 0.070$\n", - " logphi2 : c2 = $ +0.046 \\pm 0.020$\n", - " logmstar : c0 = $+10.767 \\pm 0.026$\n", - " logmstar : c1 = $ +0.124 \\pm 0.045$\n", - " logmstar : c2 = $ -0.033 \\pm 0.015$\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"{'logphi1':>10s} : c0 = $ -2.383 \\pm 0.027$\")\n", "print(f\"{'logphi1':>10s} : c1 = $ -0.264 \\pm 0.071$\")\n", @@ -201,20 +145,9 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAi8AAAGdCAYAAADaPpOnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAABW2klEQVR4nO3deXwU5eE/8M/snd0kG3KTmIMQCCIqV0RFTUAOz9IqthUVhP5erVoVi1qhHkAt9eBbRfCsVsALvthqVbw4/OItpxc3JIQjBwk5djebvXd+f8zuZDcJJIHsJpN83rz2NTPPzM4+eTZkP/vMMzOCKIoiiIiIiBRC1d0VICIiIuoMhhciIiJSFIYXIiIiUhSGFyIiIlIUhhciIiJSFIYXIiIiUhSGFyIiIlIUhhciIiJSFE13V6Cr+f1+VFRUIC4uDoIgdHd1iIiIqANEUYTNZkNGRgZUqlP3rfS68FJRUYGsrKzurgYRERGdhqNHj+Kss8465Ta9LrzExcUBkH74+Pj4Lt23KIqw2+0wmUzs1YkgtnN0sJ2jg+0cPWzr6IhUO1utVmRlZcmf46fS68JLsCHj4+MjEl7UajX/Y0QY2zk62M7RwXaOHrZ1dES6nTuyTw7YJSIiIkVheCEiIiJFYXghIiIiRWF4ISIiIkVheCEiIiJFYXghIiIiRWF4ISIiIkVheCEiIiJFYXghIiIiRel1V9gl6ol8fh92VO9ATVMNUowpGJk6EmqVururRRHm8/uw/fh21DTUICUhBaPSRvF9J+oCDC9Rxg+xvmfD4Q14fMvjON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K1NTUAACWLl2KYcOG4aqrrpK3GT9+fFgwmTt3Lj766CPs378fAPDmm29CrVZjxowZkaomERERKcxp97y43W5MmjQJDQ0NAIDf/va3yMrKwttvvw0AuO6661BdXY3JkyfDYDCgX79++OCDD6BSNeclh8MRNsblggsuwMqVKzFt2jTExMRApVLh008/RVxc3OlWk4iIiHoZQexlw7KtVivMZjMsFgvi4+O7dN/B24DzeGpksZ2jg+0cHWzn6GFbR0ek2rkzn9+8MSMREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpCsMLERERKQrDCxERESkKwwsREREpiiaSOx8yZAjS09PDyo4dO4aMjAx88cUXrbZfsWIFHn/88VbP+fjjjxETExPJqhIREZFCRDS8pKenY9OmTWFlU6dOxbhx4076nLlz5+LWW2+NZLWIiIhIwSJ62Gj58uVhy3V1dVi/fj2mTZsWyZclIiKiXiyi4WXAgAFhy6tWrcKVV16Jfv36RfJliYiIqBeL6GGjllasWIG//e1vp9xm7dq1eO211+B2u5GRkYF58+ZhxIgRJ93e5XLB5XLJy1arFQAgiiJEUeyaigcE99nV+6VwbOfoYDtHB9s5etjW0RGpdu7M/qIWXnbv3o2qqipMnDjxpNukpaVh0KBBWLBgAfR6PZYvX44xY8Zg8+bNJw0wjz32GBYuXNiq3G63Q61Wd1n9AalhHQ4HAEAQhC7dNzVjO0cH2zk62M7Rw7aOjki1s91u7/C2ghiliPrnP/8ZWq0WixYt6tTzCgsLMXjwYLz55pttrm+r5yUrKwsNDQ2Ij48/ozq3JIoi7HY7TCYT/2NEENs5OtjO0cF2jh62dXREqp2tVisSEhJgsVja/fyOSs+Lz+fDm2++ic8//7zTzx04cCBKSkpOul6v10Ov17cqFwQhIr+8wf3yP0ZksZ2jg+0cHWzn6GFbR0ck2rkz+4rKRerWrVuHgQMHIj8//5TbzZs3D01NTWFl5eXlyMrKimT1iIiISEGiEl5WrFiBmTNntiqfOXMmbrnlFnn522+/xb/+9S95ef369fjmm29w2223RaOaREREpAARP2zU0NCAjRs3hoWSIKfTCY/HIy8/8MADePbZZ/H222/D5/PB7/fjnXfeweWXXx7pahIREZFCRG3AbrRYrVaYzeYODfjpLA4Giw62c3SwnaOD7Rw9bOvoiOSA3Y5+fvPGjERERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQoDC9ERESkKAwvREREpCgML0RERKQomkjufMGCBfjvf/+LhIQEucxsNuO999476XO++uor3HfffdDr9XC5XFi8eDEuvfTSSFaTiIiIFCSi4QUAlixZguLi4g5te/jwYVx99dV47733UFxcjM8//xzXXHMNfvrpJ+Tk5ES2okRERKQIPeqw0dKlSzFkyBA57BQVFaGgoADLli3r3ooRERFRj9GjwsuGDRtQWFgYVlZYWIgNGzZ0U42IiIiop4n4YaNXX30VCxYsgMfjQX5+Ph555BEMHDiwzW1LS0txww03hJWlp6ejtLT0pPt3uVxwuVzystVqBQCIoghRFLvgJ2gW3GdX75fCsZ2jg+0cHWzn6GFbR0ek2rkz+4toeMnOzobZbMarr74KlUqFv/71rxg1ahR27dqFzMzMVts3NTVBr9eHlen1ejQ1NZ30NR577DEsXLiwVbndbodarT7zHyKEKIpwOBwAAEEQunTf1IztHB1s5+hgO0cP2zo6ItXOdru9w9tGNLzMmjUrbPnhhx/Giy++iOeffx6LFi1qtb3RaAzrRQGknhWj0XjS15g3bx7mzJkjL1utVmRlZcFkMsFkMp3hTxAumApNJhP/Y0QQ2zk62M7RwXaOHrZ1dESqnX0+X4e3jfhho1BqtRq5ubkoKSlpc31eXh6qqqrCyqqqqpCXl3fSfer1+la9NYCUBiPxyxvcL/9jRBbbOTrYztHBdo4etnV0RKKdO7OviA7YnT17dquyiooKZGVltbn95Zdfjm3btoWVbdu2DRMmTIhI/YiIiEh5Ihpe3n//fbz//vvy8iuvvILq6mr5cNLMmTNxyy23yOtnz56NPXv24IsvvgAAfPnll9izZw/uuuuuSFaTiIiIFCSih40WLVqEJUuW4Omnn4bL5YJOp8P69etx9tlnAwCcTic8Ho+8fU5ODtauXYv7778fOp0OLpcLH374IS9QR0RERDJB7GXnlFmtVpjNZlgsFsTHx3fpvkVRhN1u52CwCGM7RwfbOTrYztHDto6OSLVzZz6/e9RF6oiIiIjaw/BCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIqiifQLrFmzBq+88gp8Ph+sViuys7OxePFi5OXltbn9ihUr8PjjjyM9PT2s/OOPP0ZMTEykq0tEREQ9XMTDy80334y1a9di0qRJ8Pv9mDVrFq644gr89NNPMBgMbT5n7ty5uPXWWyNdNSIiIlKgiB82mjJlCiZNmiS9mEqFO++8EwcOHMCOHTsi/dJERETUC0U8vLz99tthy8HeFrfbHemXJiIiol4o6gN2v/32W2RkZGDs2LEn3Wbt2rUYP348LrnkEvz617/G999/H8UaEhERUU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8yiuvoLq6GrNmzeqW+vCu0h307rvvYtGiRYiJiYFKpcLzzz+Pc845p7ur1au43W5MmjQJDQ0N+PHHHzFmzBhkZWW1Oq2XzozNZkNCQgL8fn+rdcuXL8ett94a/Ur1QsuWLcOqVaugVqvh8/kgCAL+8pe/4Oqrr+7uqvVa99xzD7777jts3rwZ559/PoYMGSL3xNCZeeutt/DKK69AFEW4XC7odDo8+uijuPTSS7ulPgwvREREpCg8bERERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIrC8EJERESKwvBCREREisLwQkRERIry/wGJmv+AYyi+9gAAAABJRU5ErkJggg==", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "# parameters from [Leja+2020]_ Fig.3 also in Appendix B code snippet\n", "pars = {\n", @@ -277,20 +210,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAABMkAAAF1CAYAAADyYL09AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAADo0ElEQVR4nOzdd5xcd3no/88509vOltnZplW3ZFmyJUu4gLFleokJxcYYkmBscoNv+AGOIYmdhLhcfI1tMCWQhAsXAoQEAiH0coMLGINtXCQbSbbVVm3LzGybPnPmnPP7Y7Szu97V1pk5M7PP+/XSS1NOeb6zZ853znO+RTFN00QIIYQQQgghhBBCiBVMtToAIYQQQgghhBBCCCGsJkkyIYQQQgghhBBCCLHiSZJMCCGEEEIIIYQQQqx4kiQTQgghhBBCCCGEECueJMmEEEIIIYQQQgghxIonSTIhhBBCCCGEEEIIseJJkkwIIYQQQgghhBBCrHiSJBNCCCGEEEIIIYQQK54kyYQQQgghhBBCCCHEiidJMmG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JdeeolsNsvevXsLz+3du5dsNstLL710Xe+9WNdTxieeeIL//J//M01NTcUKb1kUq4zlUI+33npr4efJyUm+8Y1v8LGPfYzq6uqixHk9ilVGu9fjTTfdxB/90R9d9hrDMDBNsyhxlqOl7Ad9fX289dZb7Nu3b87zN998M8FgsKjxzlZK+/BSXE/8VuehpcZeKsfepcRfKsecpX72995774p+P2c899xzc2LVdZ3du3fz7LPPzrv9s88+O2d7yJfvStsX22Ljb2trY8+ePSsVnu3Z+bt4NcUql9V5z27Hn4UoVpnsWFdHjhxhbGxszmtuvPFGAoGAbY7BC8khi33PYijl3CiNZIvw2muv8Wu/9mvX3O73fu/32LdvH+95z3v4whe+QDQaLfzu/PnzOJ1O6urqCs/V19fjcDg4f/58UeJejIWU8dChQ7z55pt88pOfvOI28XicT3ziE4U5BZ566ilL5nmaz3KUsRzqEcAwDG677TZaWlpobm7mW9/61pzf270e4eplLJd6vPQ1Dz30EC6Xq/BcKddjKVjKfnD06FEAurq6eN/73scdd9zBww8/zJEjR1Yk5hnXsw9fLVetlKXGv5A8VGzX89lf69i7Epbr+DffMafYSv3YPdvExAThcPiyxtympqYrxnr+/PlFbV9MS4lfLE4xv4tW5v9ilcvq738x/75V9VWsMtmxrmaen33M0zSNxsbGOa9ZqboqRg4pheN6MXPj3/7t37J//37uvPNOPv7xj3Pu3LlFx+dc9CtWqZ///Of09vbyk5/85Krb7dy5k/e///38j//xP4hGozzyyCPcd999vPrqqzgcDhKJBG63+7LXud1uEolEscJfkIWU0TRNPv3pT/ONb3wDXb9yG+umTZv43d/9Xfbs2cPIyAgf+MAHePvtt/mnf/qnYoS+YMtVRrvX4wyHw8Hrr7/O9PQ0H/3oR/ngBz/IT3/608Ik2HauxxlXK2O51OOMkydP8swzz3DgwIE5z5dqPZaKpewHU1NTQL43009/+lPq6+v52te+xm233caxY8dYu3ZtUWOesdR9+Fq5aqUsJf6F5qFiu57jx7WOvSthOY5/VzrmFFspH7svNROPx+OZ87zH47lirIlEYlHbF9N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71+PTTz99xdfMnEyWUj2WsmvtB/MdJ3K5nPrCF76gtm/fru6++261f/9+9corr5R87AvNVaUa/2xXO0avhMXGvtDjUqnGv5BjTqnGrlT+hHzfvn2qs7NTeTwetW/fvst6VRbLv/zLv6jdu3eru+66S73nPe+Z09vgkUceUQ8//PCc7V966SV16623qrvvvlvdcsst6qWXXlqROK9ksfF/5CMfUbfeeqsC1E033aT27duncrncSodtG8X4LpZC/i/WMcbqc7diHH+srq9iHVPtWFemaaonn3xS7dy5U+3du1d99KMfVVNTU4XfW1FXxcghV3vPlbLc5fqHf/gHdc8996j9+/er22+/Xe3bt29J+VNTSqnFDdAUQgghhBBCCCGEEKK8rLrVLYUQQgghhBBCCCGEuJQ0kgkhhBBCCCGEEEKIVU8ayYQQQgghhBBCCCHEqieNZEIIIYQQQgghhBBi1ZNGMiGEEEIIIYQQQgix6kkjmRBCCCGEEEIIIYRY9aSRTAghhBBCCCGEEEKsetJIJoQQQgghhBBCCCFWPWkkE0IIIYQQQgghhBCrnjSSCSGEEEIIIYQQQohVTxrJhBBCCCGEEEIIIcSqJ41kQgghhBBCCCGEEGLV+/8BYzfQYsIvBMUAAAAASUVORK5CYII=", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "NUM = 1e5\n", "par = 'logphi1'\n", @@ -328,35 +250,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " logphi1 : c0 -- $ -2.383 \\pm 0.027$\n", - " logphi1 : c1 -- $ -0.264 \\pm 0.071$\n", - " logphi1 : c2 -- $ -0.107 \\pm 0.030$\n", - " logphi2 : c0 -- $ -2.818 \\pm 0.050$\n", - " logphi2 : c1 -- $ -0.368 \\pm 0.070$\n", - " logphi2 : c2 -- $ +0.046 \\pm 0.020$\n", - " logmstar : c0 -- $+10.767 \\pm 0.026$\n", - " logmstar : c1 -- $ +0.124 \\pm 0.044$\n", - " logmstar : c2 -- $ -0.033 \\pm 0.015$\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAABMQAAAPdCAYAAABlTrQnAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjcuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/bCgiHAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeXxc9Xno/885s89oNFpHI8nyboOxwQZjA6EOEBJIUrJQkkDStATyuzfcUkhK82pwmlwwt9QEspC0aUNKU9I0bdJsDZA0adjCanYbMJs32dYyGq2zr+ec3x9jjSVLsiVrZs7M6Hm/Xn55ljNznu9odB6d53wXxTAMAyGEEEIIIYQQQgghFgjV7ACEEEIIIYQQQgghhCgnKYgJIYQQQgghhBBCiAVFCmJCCCGEEEIIIYQQYkGRgpgQQgghhBBCCCGEWFCkICaEEEIIIYQQQgghFhQpiAkhhBBCCCGEEEKIBUUKYkIIIYQQQgghhBBiQZGCmBBCCCGEEEIIIYRYUKQgJoQQQgghhBBCCCEWFCmIiYp15ZVXsnjxYhRFobu72+xwiEajbNiwgaamJpYuXTqv99I0je3bt+NwOLjvvvuKEp8QQoi5kTxTXv/8z/9MfX09t956q9mhCCFE2UiuEaJySUFMVKwf//jH3HbbbWaHUeD1etm5cycf/OAHZ7X9c889R0NDA7/85S8nPb537162bNnCT37yEzKZTClCnbMHH3yQTZs2ccYZZ3DKKaewdetW0um02WEJIURJSZ4pj4GBAT74wQ/y7W9/m2g0anY4QghRVpJrSi+RSPC9732Piy++mLPPPpt169axYcMG7r77btNjE5XNanYAQtQqj8fDkiVL8Pl8kx7fvn07n/3sZ2lra+Oiiy4yKbqjfv3rX/PhD3+YX/ziF3zgAx9gcHCQLVu2cODAAX70ox+ZHZ4QQogZVEue+eY3v8m73/1uPvCBD7B8+XKzwxFCCDEH1ZBr7r//fj7zmc/w85//nA984AMAPPLII7zvfe/jySef5Kc//amp8YnKJQUxIUpk7dq17Nq1a8rj99xzD1arlccee6z8QR3DMAxuvPFG3vOe9xSSR2trK7feeisf//jHuf7669myZYvJUQohhJhONeQZgNtuuw2r1VoRQ4WEEELMTbXkmve///2F8xmAd73rXXz0ox/lhz/8Ifv375cLMmJaMmRSVKUXX3yR973vfSxZsoRly5axZcsWHnrooSnb/f73v2fjxo0EAgE2bdrErbfeytVXX43dbmfDhg08+uijk8b133///Vx66aWsXbsWv9/PjTfeSCqVmjaGRx55hIsvvphly5axceNGnn322cJzv/jFL9iwYQOKokyZK8VqLV8deuLntGHDBjZu3Mgtt9zC4OAgAC+88AL79u3j3e9+96TXjd//8Y9/XLZYhRCikkiemZ0T5ZlyxyOEENVEcs3snCjXfOxjH+NnP/vZlNd1dnYCMDo6WrZYRXWRgpioOi+88AJbtmxhw4YNdHd3c+DAAa666iouvfRS7r///sJ2e/bs4dJLL2Xjxo309fXx/PPP09TUxE9/+lM6OjrYuXMnF1100aRx/f/v//0/vv/977N7925+97vf8YMf/IDrr79+Sgyjo6M8+OCDPPTQQ+zbt49ly5bx8Y9/HE3TALj88svZuXNnSdo/NjZGIpE44Xbjn9PGjRvp7u5m586dfPWrX2X79u089dRTAIUYj71i0tLSUphfQAghFhrJM8XLM0IIIaYnuaZ4uUZV1WkLdG+++SZ+v59169YVPX5RG6QgJqrO5z//eerq6rjttttQFAWA66+/nrVr1/K5z30OwzCAfCIwDIM77rgDVc1/1W+44QY6OjpmfO/PfvazBAIBANavX88111zDfffdx969eydtF41G2bp1K4qioKoqV155JQcOHGD//v2laHJBLBZj+fLlnHnmmSfc9vOf/zxer5dbbrml8DlddNFFXH755VgsFoDCVZX6+vopr6+vr590hV8IIRYKyTPFyzNCCCGmJ7mmtLlm//79/Pd//zd/+7d/i8PhKFrsorZIQUxUlUQiwRNPPMFZZ52FzWab9Nx5553HgQMH2LNnDwBPPfUUK1asoKmpqbCNoijHvUJwxhlnTLq/efNmdF1nx44dkx5vbm6mtbV10n2AYDB4cg2bJZv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saBAGdhNMuhhOO1GBlno3q9vrZ/VyS/fjbHRleD2+EoCndr7G6tWnYbfL9HzHs3//fi677DKi0eikx8PhMADf/va32bRpE+vXry9MmP+tb30LVVV5+umnefDBBwsT8F955ZX85V/+JYsWLSKdTvPud7+bJUuWsGTJksLrLBYLTz755KTXQf6E5m//9m+PO96+qamJ//t//++kOK1WK9///ve5/fbbOffcc/n973/PD3/4w8LzE+OfabsTfQYA9fX1k3p6CCEWpqGoxkBYI+CBBreNUwPeOb/HWaev4+U33iSTTLA74mJTYxxfz/PQWtvHmBMdr//hH/6hcLw+0XH5+9//Prfccguvv/46+/bt44EHHihMIgz5v42/9a1vEQwG+drXvkYikeD9738/UJx8c8455/D73/+ef/u3fys8P5t8M26mnPIf//EfPP744wDcfPPNvPOd7yyspimEqEx7QzF6x5IANLptrF/UwKtDB2f/Bs0raG1qxteTYTALoZSLdHiwRNHWrrmcE8DMx9sTvQ8c/7zAzHOaiedq051znahdZlOMk1yD+7HHHuOiiy6aMj9Yb28v73//+3nmmWd47rnnpt3meCKRCD6fj3A4TH397IoS82EYBvF4HI/HM2np7FokbZ1GdABj/+N89cWDhNJ2VNXKp//wI6xe5C9somkaTzzxBMCklVp2hnaSHXob26Ed9IyuZE8s30X3vDPP4Nyzzy5Z21KpFAcOHGDZsmU4nU4Mw0DXdVRVremf60JpJ5xcW4/9XkxU7uNqNTDrM6nG43A1xgzVGfd0Me8M7eSR16MMjBkEPAHec1ob6zp9U157bK56dfhVsnoWm2pjg38DAE8//wLP7nwFVAsbV3byznM2g3P67//xjinHxlyNx+ZqjLsSYpZcM3sn+jyq8Rg1G7XYrkprk6YbfP/pbsLJLAAf3NDBita6/LnJkeP+6c2nT3v+MpEx8DqPPvpbfptqQXc3c95pLfzRus1la8ds88xcVcKxsthqsU0wfbvKnWeK3o3lhhtuYPv27bPuzpdOp0mnjw4DiEQiQP7DOcla3ZyM76cc+zKbtHUadX4OdLyPoT1PYcRCNHgdrOxomfS6ie9z7HsaDUsg9B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+1lyc3NjEudMiFVZE227Tqecq1ev5pvf/OaYZQzDwDTNmMQpZsZ09r+mpiZ27NjBli1bRk1fu3YtmZmZMY0XEu83MxlnEnM8c+B0447nMX46Mcf7GDbd7/mCCy6Yld/csOeff35UjLqus379ep577rlx53/uuedGzQ+Rck00v5hdyfhbOZ1YlSneeSdZjhFTEasyJeO22rt3L11dXaOWWbp0KS6XK27Hy1gc76e6zpmWrDks5SvExvPmm2/yiU984rTzfeUrX2HLli2cf/753Hrrrbjd7uh7x44dw2q1UlBQEJ1WWFiIxWLh2LFjMYl7qiZTznfeeYft27fzt3/7txPO4/F4uPHGGzn//PP54Ac/yD333HPGFYozbSbKmgzbFCa//xqGwdlnn01ZWRmlpaXcf//9o95Ple0Kpy5rMmzXyZbz/ct89KMfxWazRaclwzada6az/+3btw+A+vp6LrvsMs4991yuvvpq9u7dm7AxDztV3oyl6cY8mRwYS2fyXZ/uGB8rM3VMHe8YFivJkAd6enoYGBgYUzFbUlIyYYzHjh2b0vxidsXytxKvfB+rMsX7NxrLz0/2bTVb643l5w9PH3m81DSN4uLiUcvM1raKxfF+OuucSbHMYT//+c/ZunUr5513Htdffz1Hjx6d0dhTvlP993vhhRdobGzkqaeeOuV8a9as4fLLL+eHP/whbrebT37yk1x44YW88cYbWCwWvF7vuB332e12vF5vrMKftMmU0zRNvvjFL3Lfffeh6xPXjS5evJgvfOELbNiwgY6ODj784Q/z9ttv84c//CEWoU/ZTJU10bcpTH7/BbBYLGzbto3+/n4+9alPccUVV/D000+jaRqQGtt12KnKmujbdSrlHHbw4EGeeeYZdu7cOWp6om/TuWg6+19fXx8QeXLp6aefprCwkB//+MecffbZ1NXVUVNTk3Axw+nzZixNJ+bJ5sBYOpPj0+mO8bEyE8fUiY5hsZLoeQCIxuFwOEZNdzgcE8bo9XqnNL+YXbH8rcQr38eqTPH+jcby85N5W83memP5+ZM9vs7WtorF8X4665xJscphVVVVZGdn8/Of/xxd1/nWt77F+vXrqauro7y8fEZiT9onxO688040TT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LsTaduCdz3Iul6X7XpzuGxdKZ7h+zNcrkVVddpa677rroa9M0VUlJyYQjdP393/+9Ouuss0ZN27Rpk4wymSBi9VuJZ76PVZnifa4Wq2NEMm6rYacbZTKZttXwKJMjR+/ev3//qFEmZ3tbxeJ4P9V1zrRYlOnLX/7ymOUqKytn9Hw45SvEfD6f2rp1q7rlllvUjh07ov/WrVsXnaezs1NVVFRET9rr6+tVXl6eqq+vV0pFfkTXX3+9WrhwofL5fNHlbr75ZnXRRRepcDisDMNQF198sbr55ptntXzDplPO9xvvYuDFF19UCxcujB5gvF6vuuiii9T555+vTNOMXYFOIVZlVSqxtqlS0yvriy++qAoLC6P7r2EY6m//9m9VSUlJdDumynadTFmVSqztOp1yGoahPvWpT6lPfvKTo5a54ooromVPxG0qIk63/413vLr11lvVWWedpbxer1JKqccee0w5nU713nvvJWTMk82biRTz+8WjQkypqcc92eNeIsU8mWNYosU80mxViL311lsqMzMz+jt/6KGHVHl5uRocHFRKKfW5z31OffrTn47O39DQoLKystTLL7+slFLqlVdeUZmZmaqhoSHmsYrJicVvJd75Pla//3ifq8XiGJFs22qkUx33knFbff/731crVqxQHo9HKaXU3/zN36grr7wy+v5sb6tYHO9Pt85Yi0WZqqur1eOPPx59/bOf/Uw5HA61f//+GYs75SvE/u3f/k0B4/4b1t7ervLz89Wjjz6qlIpcsN59993q7LPPVlu3blUbNmxQ11133ZgTDL/fr26++Wa1bt06tW7dOvWlL31J+f3+2Sxe1HTKOdKWLVvU4sWLFaC2bNmi7rnnHqWUUj09Peq2225TmzZtUlu2bFHr1q1Tf/u3f6u6urpmq2hjxKqsSiXWNlVqemUd3mbr1q1TmzdvVuvXr1cf/ehHVV1dXXSZVNmukymrUom1XadTzieffHLCZYZPJhNxm4qI0+1/4x2vwuGwuvXWW9XKlSvV5s2b1datW9Xrr7+esDFPNm8mUswjnSovJFrckz3uJVLMkzmGJVrMSkVO7rds2aLmzZunHA6H2rJly5gnIWfaI488otavX68+8IEPqPPPP3/Ukwm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/4BH/84x85duzYrMcjkoNUiImk9Pbbb3PZZZcxb948ampq2Lx5M88999yY+V5++WXWr19PSUkJGzdu5M477+T666/HbrezZs0aXnzxxVHt+v/0pz9xySWXsHz5coqKivjyl7+M3+8fN4YXXniBD33oQ9TU1LB+/Xreeuut6HuPPvooa9asQdO0UX2l/OM//iP/8i//MmZd5eXlBINBvF7vmX85I4z8ntasWcP69eu544476OrqAmDnzp0cPXqUCy+8cNRyw69/+9vfzmg8QgiRLCTPTM7p8gyA1SoNEoQQYjySaybndLnm2muv5Y9//OO48QD09fXNaDwihSghEtgDDzygAFVfXx+dtmPHDpWWlqZuvfVWZZqmUkqpf/u3f1O6rqvHH388Ot+hQ4eUw+FQ//t//29lGIZSSqkf/vCHKj09Xc2bN2/cz9mwYYNqa2tTSim1e/dulZOTo2688cZR815//fUqKytL/f3f/70yTVMZhqGuvvpqVVNTo8Lh8Kh5AXXHHXectpyrVq1Sq1atmtR30tfXpzwez2nnG/6evvnNb0a/pxdeeEHZbDb16KOPKqWU+s///E8FqEceeWTM8pmZmeq8886bVExCCJGsJM+MNZN5ZqT6+vpJxyuEEKlEcs1Ysco1I33kIx9RRUVFyu/3TyomMfdIhZhIaOMljy1btqjCwkIVDAZHzbty5UpVU1MTPVB+5jOfUXa7XfX09ETnMU1TLViwYMLk8dBDD42a/vd///dK13V1+PDh6LTrr79eaZqmOjs7o9N+97vfKUAdOnRo1PKTSR6vvvqq0jRNPfvss6ecTyml3G63ys3NVYsWLTrtvFu2bFFFRUVjvqdrr71W/elPf1JKKXX33XcrQD333HNjli8vL5/U5wghRDKTPDPaTOeZkaRCTAgxV0muGS2WuWbY0aNHlc1mU/fff/9pP0PMXdJkUiQVr9fLq6++yrp167DZbKPeO+ecc6ivr+fw4cMAvP7668yfP5+8vLzoPJqmsWLFignXv2rVqlGvN23ahGmabNu2bdT0/Px8CgsLR70GaG9vn1J5ent7ufHGG/nnf/5nLrrootPOb7PZKCoqij7+O5Hh72nt2rVjvqff/va3o9rXT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44kOjSRhKRBTIgY2LBhA3feeWeiwxg3l8vFunXrANi9ezd79uxh4cKFnHXWWdTU1CQ4OiGEmL6mSp7ZsWMHGzduZMuWLcyaNSvR4QghhDhuquSZc889F4PBwJtvvsn27dvZuHEje/fuZeXKlRw7dizR4YkkIw1iQoion/70pxw+fJgf//jHmEwmNE3jP//zPwkEAlPijpEQQojEWrhwIU8//TR5eXmJDkUIIcQUZDAY+NGPfkRKSgoAeXl5/Od//ift7e088sgjCY5OJBtpEBNJ6X//939ZsWIFs2fPpry8nKuvvpqDBw/2W+/BBx9k5syZVFVVceqpp/LnP/+ZGTNmkJ2dzbJly3C5XJx55pkUFhaiaRoffPABF110EVVVVZxyyils2rQJj8fD5z//eZYuXUpVVRWPPvpon8/o7u7m5ptvZvHixSxfvpylS5dy0003cfjwYQA++clP8tBDDwGwbNkyli1bxlVXXQWAz+fj29/+NitWrGDFihUsWbKEK6+8kkOHDkX3v2/fPpYtW0ZaWhrr16/nySef5KyzzqKsrAxN09i+fXtMjml3dzdf//rXqaysZPHixSxatIhPf/rTvPXWW32O+4IFCyguLo4us9lsnHHGGfz5z39G1/WYxCKEEIkmeSYxecZkMsXks4QQItlJnklMnuno6CAnJ6fPdiUlJdH3hOhDCZFA119/vaqoqOiz7IEHHlAmk0n99a9/VUopFQgE1LXXXqtyc3NVdXV1dL3HHntMAerxxx/vs57ValXXX399n33efvvtClBf/OIXVTAYVLquq6uvvloVFhaq733ve6qhoUEppdR///d/K6PRqA4ePBjd9nOf+5w699xzld/vV0op1dDQoGbPnq0effTRfvs/WUNDg8rLy4vuT9d19YMf/ECVl5er7u7uPuuuW7dO5efnq1tvvVUppZTf71ezZ89W77///qDHLxQKqcbGxkHf7xEIBNSpp56qli5dqpqbm5VSSrW1tak1a9aoyy+/XCmllNfrVQaDQX30ox/tt/3NN9+sAHXgwIFhP0sIIZKJ5JkTEp1nTrZu3bp+vxshhJhsJM+ckGx5psdTTz2lAPXUU08N+zliepEGMZFQJycQp9Op0tLS1B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yMgwa73NydA22rVrF44cOYKjR4/C0dERPT09yM3NxfPPP2+pFJhgoq5Pw8UFgMLCQrzxxhsIDw9Hb28vEhISsHHjRovktHHjRnR0dGD+/PlQKpUIDg5GYWGhVuyioiLExcVhzJgxWtuio6NRXV2NqKgouLi4oL29HbGxsdi2bZvV5RMWFoZly5YhNjYWrq6uaG9vx5w5c5CZmQkHBwdpPxF9JCKf3NxcnD17FmfPnsWePXt0Pq+p+kfEGGa4mIC4OZKp82lvb8e6devQ39+PefPmyZ4rLy9P+r89zX0ciIgsXQnGGGOMMcYYY4wxxszFLr5DjDHGGGOMMcYYY4yxAbwgxhhjjDHGGGOMMcbsCi+IMcYYY4wxxhhjjDG7wgtijDHGGGOMMcYYY8yu8IIYY4wxxhhjjDHGGLMrvCDGGGOMMcYYY4wxxuwKL4gxxhhjjDHGGGOMMbvCC2KMMcYYY4wxxhhjzK7wghhjjDHGGGOMMcYYsyu8IMYYY4wxxhhjjDHG7AoviDHGGGOMMcYYY4wxu8ILYowxxhhjjDHGGGPMrvwPW4Kw07RKg98AAAAASUVORK5CYII=", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "NUM = 1e5\n", "\n", @@ -416,8 +312,7 @@ "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.11" - }, - "orig_nbformat": 4 + } }, "nbformat": 4, "nbformat_minor": 2 From 9d119762a3096b526b23a84b15b963a6cdbfd7d9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 14:51:41 -0700 Subject: [PATCH 081/291] Saving all three_model figures. --- .../take7B_GW_anatomy_fromsaved.ipynb | 594 ++++++++++++++++++ 1 file changed, 594 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb diff --git a/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb b/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb new file mode 100644 index 00000000..a94a2be8 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb @@ -0,0 +1,594 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get PSpace Info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz_hard_time = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape/gsmf_mchar0_log10_p0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True)\n", + "sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape/'\n", + "save_dir=sam_loc+'/figures'\n", + "\n", + "print(npz_hard_time.files)\n", + "SHAPE = npz_hard_time['shape']\n", + "print(SHAPE)\n", + "\n", + "npz_hard_time.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "print(param_names)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Detstats Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 50\n", + "SIGMA = 3.55e-6\n", + "NSKIES = 25\n", + "THRESH = 0.5\n", + "DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "def detect_pspace_model(data, dur=DUR,\n", + " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + " fobs_cents = data['fobs_cents']\n", + " hc_ss = data['hc_ss']\n", + " hc_bg = data['hc_bg']\n", + " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + " npsrs, sigma, nskies, thresh)\n", + " return dsdata" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plotting Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_sample_text(fig, params, param_names, \n", + " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + " text = ''\n", + " for pp, name in enumerate(param_names):\n", + " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + " # if pp == int(len(param_names)/2):\n", + " # text = text+'\\n'\n", + " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + " show_medians = False, show_ci=False, show_reals=True):\n", + " if show_reals:\n", + " if (xx_ss is not None) and (yy_ss is not None):\n", + " if fast_ss:\n", + " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + " else:\n", + " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + " for rr in range(len(yy_ss[0])):\n", + " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + " if (xx_bg is not None) and (yy_bg is not None):\n", + " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + " # if show_medians:\n", + " # if (xx_ss is not None) and (yy_ss is not None):\n", + " # ax.plot(np.median(xx_ss, axis=())\n", + " # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + " print(f\"{xx_ss.shape=}\")\n", + " print(f\"{xx_bg.shape=}\")\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "draw_par_vs_freq" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_par_vs_freq(\n", + " ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + " color_ss, color_bg, ls_bg='-',\n", + " show_bg_median=True, show_bg_ci=True, \n", + " show_ss_err=True, show_ss_reals=True):\n", + "\n", + " if show_bg_median:\n", + " ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", + " if show_bg_ci:\n", + " for pp in [50, 98]:\n", + " conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1)\n", + " ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", + " if show_ss_err:\n", + " ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1),\n", + " color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", + " if show_ss_reals:\n", + " ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20)\n", + "\n", + "\n", + "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + " \n", + " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + " if fast:\n", + " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss)\n", + " for rr in range(nreals):\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + " else:\n", + " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies):\n", + " for rr in range(nreals):\n", + " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + " for ss in range(nskies):\n", + " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + " dc_final (4), sepa_final(5), angs_final(6),\n", + " hs, snr, dp\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + " print(f\"{yy_ss.shape=}\")\n", + " print(f\"{yy_bg.shape=}\")\n", + "\n", + " print(f\"{snr_ss.shape=}\")\n", + " print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " print('plotting', labels[ii])\n", + " ax.set_ylabel(labels[ii])\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " ax.set_ylabel(labels[ii])\n", + " print('plotting', labels[ii])\n", + "\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + " fig.tight_layout()\n", + " return fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 Plot-Three Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " fig=plot_everything_vs_freqs(\n", + " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + " fast=True, show_reals=True): \n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + " shape = snr_ss.shape\n", + " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + " xx = fobs_cents*YR\n", + " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + " units = sings.par_units[idx]\n", + " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + " # plot all pars and hs\n", + " for ii,ax in enumerate(axs.flatten()[:7]):\n", + " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + " color_ss, color_bg,)\n", + " \n", + " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + " ii=7\n", + " ax = axs.flatten()[ii]\n", + " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + " \n", + " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + " ii=8\n", + " ax = axs.flatten()[ii]\n", + " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + " nreals, nskies)\n", + " \n", + " return fig\n", + "\n", + "\n", + "def plot_three_models(\n", + " data, params, hard_name, shape, target_param, filename,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " datlw = np.array([3,4,5]),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append=''):\n", + " \n", + " fobs_cents = data[0]['fobs_cents']\n", + " fig, axs = holo.plot.figax(\n", + " nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5))\n", + "\n", + " idx = [0,1,2,4,5,6]\n", + " labels = np.append(sings.par_labels[idx], \n", + " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + " 'SNR', 'Detection Probability']))\n", + " \n", + " for ax in axs[-1]:\n", + " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + " for ii,ax in enumerate(axs.flatten()):\n", + " ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + " for ii, dat in enumerate(data):\n", + " print(f'on dat {ii}')\n", + " dsdat = detect_pspace_model(dat)\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + " dsdat['snr_ss'], dsdat['snr_bg'], \n", + " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=12)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + " if save_dir is not None:\n", + " str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2])\n", + " filename = save_dir+'/%s_allvsfreqs%s_%s.png' % (target_param, save_append, str_shape) \n", + " fig.savefig(filename, dpi=100)\n", + "\n", + " return fig\n", + "\n", + "# fig = plot_three_models(data = data_hard_time, params = params_hard_time,\n", + "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True,):\n", + " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + " idx = [0,1,2,4,5,6]\n", + "\n", + " labels = sings.par_labels[idx]\n", + " units = sings.par_units[idx]\n", + " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + " yy_ss = hc_ss\n", + " yy_bg = hc_bg\n", + "\n", + " for ax in axs[:,0]:\n", + " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(labels[ii])\n", + " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + " \n", + " return fig\n", + "\n", + "def plot_three_hs_vs_binpars(data, params,\n", + " hard_name, shape, target_param, filename,\n", + " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + " dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append='',):\n", + " fobs_cents = data[0]['fobs_cents']\n", + " \n", + " fig, axs = holo.plot.figax(\n", + " nrows=2, ncols=3, sharey=True, figsize=(9,4)\n", + " )\n", + " \n", + " for ii, dat in enumerate(data):\n", + " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + " \n", + " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", + " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + " fig.tight_layout()\n", + " if save_dir is not None:\n", + " str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2])\n", + " filename = save_dir+'/%s_hsvsbinpars%s_%s.png' % (target_param, save_append, str_shape) \n", + " fig.savefig(filename, dpi=100)\n", + "\n", + " return fig\n", + "\n", + "# fig = plot_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# hard_name, sam.shape, target_param)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4 Vary Parameters!!!!!!!" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_phi0'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_gsmf_phi0 = vary_parameter('gsmf_phi0', save_dir=save_dir)\n", + "filename='/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape/gsmf_phi0_p0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_phi0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = plot_three_models(*rv_gsmf_phi0, save_dir=save_dir, save_append='_p.5')\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0, save_dir=save_dir, save_append='_p.5')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'gsmf_mchar0_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_gsmf_mchar0_log10 = vary_parameter('gsmf_mchar0_log10', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape/gsmf_mchar0_log10_p0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_gsmf_mchar0_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = plot_three_models(*rv_gsmf_mchar0_log10, save_dir=save_dir, save_append='_p.5')\n", + "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10, save_dir=save_dir, save_append='_p.5')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_mamp_log10'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_mmb_mamp_log10 = vary_parameter('mmb_mamp_log10', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape/mmb_mamp_log10_p0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_mmb_mamp_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = plot_three_models(*rv_mmb_mamp_log10, save_dir=save_dir, save_append='_p.5')\n", + "fig = plot_three_hs_vs_binpars(*rv_mmb_mamp_log10, save_dir=save_dir, save_append='_p.5')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## 'mmb_scatter_dex'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# rv_mmb_scatter_dex = vary_parameter('mmb_scatter_dex', save_dir=save_dir) \n", + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform07GW_fullshape/mmb_scatter_dex_p0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + "npz = np.load(filename, allow_pickle=True)\n", + "rv_mmb_scatter_dex = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", + " npz['target_param'], filename)\n", + "fig = plot_three_models(*rv_mmb_scatter_dex, save_dir=save_dir, save_append='_p.5')\n", + "fig = plot_three_hs_vs_binpars(*rv_mmb_scatter_dex, save_dir=save_dir, save_append='_p.5')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b004d0d190ce8ed55bef28f0f3111a5313005e52 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 15:16:03 -0700 Subject: [PATCH 082/291] Moved three model plotting functions to anatomy.py in ecg-notebooks, saved all threemodel figs for GW and 09A full shape. --- .../parameter_investigation/anatomy.py | 355 ++++++++++ .../take7A_FT_anatomy_fromsaved.ipynb | 614 ++++++++--------- .../take7B_GW_anatomy_fromsaved.ipynb | 633 +++++++++--------- .../take8_anatomy_time_vs_sepa.ipynb | 0 4 files changed, 984 insertions(+), 618 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/anatomy.py create mode 100644 ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb diff --git a/ecg-notebooks/parameter_investigation/anatomy.py b/ecg-notebooks/parameter_investigation/anatomy.py new file mode 100644 index 00000000..2304597c --- /dev/null +++ b/ecg-notebooks/parameter_investigation/anatomy.py @@ -0,0 +1,355 @@ +import numpy as np +import matplotlib.pyplot as plt +import matplotlib.cm as cm +import h5py + + +from holodeck import plot, detstats +import holodeck.single_sources as sings +from holodeck.constants import YR, MSOL, MPC +import holodeck as holo + +import hasasia.sim as hsim + + + +NPSRS = 50 +SIGMA = 3.55e-6 +NSKIES = 25 +THRESH = 0.5 +DUR = holo.librarian.DEF_PTA_DUR + +def detect_pspace_model(data, dur=DUR, + npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH): + fobs_cents = data['fobs_cents'] + hc_ss = data['hc_ss'] + hc_bg = data['hc_bg'] + dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur, + npsrs, sigma, nskies, thresh) + return dsdata + + +def draw_sample_text(fig, params, param_names, + xx=0.1, yy=-0.025, fontsize=10, color='k'): + text = '' + for pp, name in enumerate(param_names): + text = text+"'%s'=%.2e, " % (name, params[name]) + # if pp == int(len(param_names)/2): + # text = text+'\n' + fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75) + + +############################################################ +#### Draw hc vs par +############################################################ + +def draw_hc_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, + show_medians = False, show_ci=False, show_reals=True): + if show_reals: + if (xx_ss is not None) and (yy_ss is not None): + if fast_ss: + ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss) + else: + colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0]))) + for rr in range(len(yy_ss[0])): + ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr]) + if (xx_bg is not None) and (yy_bg is not None): + ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg) + # if show_medians: + # if (xx_ss is not None) and (yy_ss is not None): + # ax.plot(np.median(xx_ss, axis=()) + # if (xx_bg is not None) and (yy_bg is not None): + + + + +def plot_hc_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, params, param_names, color_ss='r', color_bg='k', fast_ss=True): + """ plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)""" + colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0]))) + idx = [0,1,2,4,5,6] + + labels = sings.par_labels[idx] + units = sings.par_units[idx] + xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] + xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] + print(f"{xx_ss.shape=}") + print(f"{xx_bg.shape=}") + + yy_ss = hc_ss + yy_bg = hc_bg + print(f"{yy_ss.shape=}") + print(f"{yy_bg.shape=}") + + + fig, axs = holo.plot.figax( + nrows=2, ncols=3, sharey=True, figsize=(12,6)) + for ax in axs[:,0]: + ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN) + for ii, ax in enumerate(axs.flatten()): + ax.set_xlabel(labels[ii]) + draw_hc_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors) + + draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) + fig.tight_layout() + return fig + + +################################################################### +#### Draw Par vs Frequency +################################################################### + +def draw_par_vs_freq( + ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, + color_ss, color_bg, ls_bg='-', + show_bg_median=True, show_bg_ci=True, + show_ss_err=True, show_ss_reals=True): + + if show_bg_median: + ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75) + if show_bg_ci: + for pp in [50, 98]: + conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1) + ax.fill_between(xx, *conf, color=color_bg, alpha=0.25) + if show_ss_err: + ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1), + color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5) + if show_ss_reals: + ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20) + + +def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, + color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, + colors, fast, nfreqs, nreals, nskies, nloudest,): + + xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest) + if fast: + ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss) + for rr in range(nreals): + ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) + else: + xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies) + for rr in range(nreals): + for ll in range(nloudest): + edgecolor = 'k' if ll==0 else None + ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor) + ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) + +def draw_dp_vs_freqs(ax, dp_ss, dp_bg, + color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, + nreals, nskies): + for rr in range(nreals): + ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg) + for ss in range(nskies): + ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss) + +def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg, + params, param_names, + color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, + fast=True, show_reals=True): + """ plot mtot (0), mrat (1), redz_init (2), + dc_final (4), sepa_final(5), angs_final(6), + hs, snr, dp""" + colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0]))) + idx = [0,1,2,4,5,6] + shape = snr_ss.shape + nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3] + xx = fobs_cents*YR + xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest) + xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals) + + labels = np.append(sings.par_labels[idx], + np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability'])) + units = sings.par_units[idx] + yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L + yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L + yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R + yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R + print(f"{yy_ss.shape=}") + print(f"{yy_bg.shape=}") + + print(f"{snr_ss.shape=}") + print(f"{dp_ss.shape=}") + + + fig, axs = holo.plot.figax( + nrows=3, ncols=3, sharex=True, figsize=(15,10)) + for ax in axs[-1]: + ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR) + + # plot all pars and hs + for ii,ax in enumerate(axs.flatten()[:7]): + print('plotting', labels[ii]) + ax.set_ylabel(labels[ii]) + draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], + color_ss, color_bg) + + # plot snr, snr_ss = (F,R,L), snr_bg = (R) + ii=7 + ax = axs.flatten()[ii] + ax.set_ylabel(labels[ii]) + print('plotting', labels[ii]) + + draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, + color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, + colors, fast, nfreqs, nreals, nskies, nloudest,) + + # plot detection probability, dp_ss = (R,S), dp_bg = (R) + ii=8 + ax = axs.flatten()[ii] + ax.set_ylabel(labels[ii]) + print('plotting', labels[ii]) + + draw_dp_vs_freqs(ax, dp_ss, dp_bg, + color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, + nreals, nskies) + + draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) + fig.tight_layout() + return fig + +def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'): + dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg']) + sspar = sings.all_sspars(data['fobs_cents'], data['sspar']) + fig=plot_everything_vs_freqs( + data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'], + dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'], + color_ss=color_ss, color_bg=color_bg, fast=fast, ) + return fig + + + +################################################################### +#### Plot 3 Functions +################################################################### +def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg, + color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, + fast=True, show_reals=True): + colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0]))) + idx = [0,1,2,4,5,6] + shape = snr_ss.shape + nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3] + xx = fobs_cents*YR + xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest) + xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals) + + units = sings.par_units[idx] + yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L + yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L + yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R + yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R + + # plot all pars and hs + for ii,ax in enumerate(axs.flatten()[:7]): + draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], + color_ss, color_bg,) + + # plot snr, snr_ss = (F,R,L), snr_bg = (R) + ii=7 + ax = axs.flatten()[ii] + draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, + color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, + colors, fast, nfreqs, nreals, nskies, nloudest,) + + # plot detection probability, dp_ss = (R,S), dp_bg = (R) + ii=8 + ax = axs.flatten()[ii] + draw_dp_vs_freqs(ax, dp_ss, dp_bg, + color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, + nreals, nskies) + + return fig + + +def plot_three_models( + data, params, hard_name, shape, target_param, filename, param_names, + datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']), + datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']), + datlw = np.array([3,4,5]), + dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append=''): + + fobs_cents = data[0]['fobs_cents'] + fig, axs = holo.plot.figax( + nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5)) + + idx = [0,1,2,4,5,6] + labels = np.append(sings.par_labels[idx], + np.array([plot.LABEL_CHARACTERISTIC_STRAIN, + 'SNR', 'Detection Probability'])) + + for ax in axs[-1]: + ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR) + for ii,ax in enumerate(axs.flatten()): + ax.set_ylabel(labels[ii]) + + + for ii, dat in enumerate(data): + print(f'on dat {ii}') + dsdat = detect_pspace_model(dat) + sspar = sings.all_sspars(fobs_cents, dat['sspar']) + fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], + sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'], + dsdat['snr_ss'], dsdat['snr_bg'], + color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii], + lw_bg = datlw[ii], lw_ss = datlw[ii]) + draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], + yy=dattext_yy[ii], xx=0, fontsize=12) + fig.suptitle("%s, %s, Varying '%s'" % (hard_name, str(shape), target_param)) + fig.tight_layout() + if save_dir is not None: + str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2]) + filename = save_dir+'/%s_allvsfreqs%s_%s.png' % (target_param, save_append, str_shape) + fig.savefig(filename, dpi=100) + + return fig + + +def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True,): + """ plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)""" + colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0]))) + idx = [0,1,2,4,5,6] + + labels = sings.par_labels[idx] + units = sings.par_units[idx] + xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] + xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] + + yy_ss = hc_ss + yy_bg = hc_bg + + for ax in axs[:,0]: + ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN) + for ii, ax in enumerate(axs.flatten()): + ax.set_xlabel(labels[ii]) + draw_hc_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors) + + return fig + +def plot_three_hs_vs_binpars(data, params, + hard_name, shape, target_param, filename, param_names, + datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']), + datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']), + dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append='',): + fobs_cents = data[0]['fobs_cents'] + + fig, axs = holo.plot.figax( + nrows=2, ncols=3, sharey=True, figsize=(9,4) + ) + + for ii, dat in enumerate(data): + sspar = sings.all_sspars(fobs_cents, dat['sspar']) + + draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True, + color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii]) + draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], + yy=dattext_yy[ii], xx=0, fontsize=9.5) + fig.suptitle("%s, %s, Varying '%s'" % (hard_name, str(shape), target_param)) + fig.tight_layout() + if save_dir is not None: + str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2]) + filename = save_dir+'/%s_hsvsbinpars%s_%s.png' % (target_param, save_append, str_shape) + fig.savefig(filename, dpi=100) + + return fig + +# fig = plot_three_hs_vs_binpars(data_hard_time, params_hard_time, +# hard_name, sam.shape, target_param) diff --git a/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb b/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb index 3d70b807..c4449844 100644 --- a/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb +++ b/ecg-notebooks/parameter_investigation/take7A_FT_anatomy_fromsaved.ipynb @@ -21,7 +21,11 @@ "from holodeck.constants import YR, MSOL, MPC\n", "import holodeck as holo\n", "\n", - "import hasasia.sim as hsim" + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" ] }, { @@ -40,6 +44,8 @@ "source": [ "npz_hard_time = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", " allow_pickle=True)\n", + "sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "save_dir=sam_loc+'/figures' \n", "print(npz_hard_time.files)\n", "SHAPE = npz_hard_time['shape']\n", "\n", @@ -101,65 +107,65 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_sample_text(fig, params, param_names, \n", - " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", - " text = ''\n", - " for pp, name in enumerate(param_names):\n", - " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", - " # if pp == int(len(param_names)/2):\n", - " # text = text+'\\n'\n", - " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", - "\n", - "\n", - "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", - " show_medians = False, show_ci=False, show_reals=True):\n", - " if show_reals:\n", - " if (xx_ss is not None) and (yy_ss is not None):\n", - " if fast_ss:\n", - " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", - " else:\n", - " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", - " for rr in range(len(yy_ss[0])):\n", - " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", - " if (xx_bg is not None) and (yy_bg is not None):\n", - " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", - " # if show_medians:\n", - " # if (xx_ss is not None) and (yy_ss is not None):\n", - " # ax.plot(np.median(xx_ss, axis=())\n", - " # if (xx_bg is not None) and (yy_bg is not None):\n", - "\n", - "\n", - "\n", - "\n", - "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - "\n", - " labels = sings.par_labels[idx]\n", - " units = sings.par_units[idx]\n", - " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", - " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", - " print(f\"{xx_ss.shape=}\")\n", - " print(f\"{xx_bg.shape=}\")\n", - "\n", - " yy_ss = hc_ss\n", - " yy_bg = hc_bg\n", - " print(f\"{yy_ss.shape=}\")\n", - " print(f\"{yy_bg.shape=}\")\n", - "\n", - "\n", - " fig, axs = holo.plot.figax(\n", - " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", - " for ax in axs[:,0]:\n", - " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", - " for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(labels[ii])\n", - " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + "# def draw_sample_text(fig, params, param_names, \n", + "# xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + "# text = ''\n", + "# for pp, name in enumerate(param_names):\n", + "# text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + "# # if pp == int(len(param_names)/2):\n", + "# # text = text+'\\n'\n", + "# fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "# def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + "# show_medians = False, show_ci=False, show_reals=True):\n", + "# if show_reals:\n", + "# if (xx_ss is not None) and (yy_ss is not None):\n", + "# if fast_ss:\n", + "# ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + "# else:\n", + "# colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + "# for rr in range(len(yy_ss[0])):\n", + "# ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + "# if (xx_bg is not None) and (yy_bg is not None):\n", + "# ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + "# # if show_medians:\n", + "# # if (xx_ss is not None) and (yy_ss is not None):\n", + "# # ax.plot(np.median(xx_ss, axis=())\n", + "# # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "# def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + "# \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "\n", + "# labels = sings.par_labels[idx]\n", + "# units = sings.par_units[idx]\n", + "# xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "# xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "# print(f\"{xx_ss.shape=}\")\n", + "# print(f\"{xx_bg.shape=}\")\n", + "\n", + "# yy_ss = hc_ss\n", + "# yy_bg = hc_bg\n", + "# print(f\"{yy_ss.shape=}\")\n", + "# print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + "# for ax in axs[:,0]:\n", + "# ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "# for ii, ax in enumerate(axs.flatten()):\n", + "# ax.set_xlabel(labels[ii])\n", + "# draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", - " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", - " fig.tight_layout()\n", - " return fig" + "# draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + "# fig.tight_layout()\n", + "# return fig" ] }, { @@ -176,113 +182,113 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_par_vs_freq(\n", - " ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", - " color_ss, color_bg, ls_bg='-',\n", - " show_bg_median=True, show_bg_ci=True, \n", - " show_ss_err=True, show_ss_reals=True):\n", - "\n", - " if show_bg_median:\n", - " ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", - " if show_bg_ci:\n", - " for pp in [50, 98]:\n", - " conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1)\n", - " ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", - " if show_ss_err:\n", - " ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1),\n", - " color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", - " if show_ss_reals:\n", - " ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20)\n", - "\n", - "\n", - "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", - " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + "# def draw_par_vs_freq(\n", + "# ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + "# color_ss, color_bg, ls_bg='-',\n", + "# show_bg_median=True, show_bg_ci=True, \n", + "# show_ss_err=True, show_ss_reals=True):\n", + "\n", + "# if show_bg_median:\n", + "# ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", + "# if show_bg_ci:\n", + "# for pp in [50, 98]:\n", + "# conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1)\n", + "# ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", + "# if show_ss_err:\n", + "# ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1),\n", + "# color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", + "# if show_ss_reals:\n", + "# ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20)\n", + "\n", + "\n", + "# def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + "# colors, fast, nfreqs, nreals, nskies, nloudest,):\n", " \n", - " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", - " if fast:\n", - " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss)\n", - " for rr in range(nreals):\n", - " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", - " else:\n", - " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", - " for rr in range(nreals):\n", - " for ll in range(nloudest):\n", - " edgecolor = 'k' if ll==0 else None\n", - " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", - " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", - "\n", - "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " nreals, nskies):\n", - " for rr in range(nreals):\n", - " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", - " for ss in range(nskies):\n", - " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", - "\n", - "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", - " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", - " fast=True, show_reals=True):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", - " dc_final (4), sepa_final(5), angs_final(6),\n", - " hs, snr, dp\"\"\"\n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - " shape = snr_ss.shape\n", - " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - " xx = fobs_cents*YR\n", - " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", - " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", - "\n", - " labels = np.append(sings.par_labels[idx], \n", - " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", - " units = sings.par_units[idx]\n", - " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", - " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", - " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", - " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", - " print(f\"{yy_ss.shape=}\")\n", - " print(f\"{yy_bg.shape=}\")\n", - "\n", - " print(f\"{snr_ss.shape=}\")\n", - " print(f\"{dp_ss.shape=}\")\n", - "\n", - "\n", - " fig, axs = holo.plot.figax(\n", - " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", - " for ax in axs[-1]:\n", - " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", - "\n", - " # plot all pars and hs\n", - " for ii,ax in enumerate(axs.flatten()[:7]):\n", - " print('plotting', labels[ii])\n", - " ax.set_ylabel(labels[ii])\n", - " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", - " color_ss, color_bg)\n", + "# xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + "# if fast:\n", + "# ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss)\n", + "# for rr in range(nreals):\n", + "# ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + "# else:\n", + "# xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + "# for rr in range(nreals):\n", + "# for ll in range(nloudest):\n", + "# edgecolor = 'k' if ll==0 else None\n", + "# ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + "# ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "# def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# nreals, nskies):\n", + "# for rr in range(nreals):\n", + "# ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + "# for ss in range(nskies):\n", + "# ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "# def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + "# color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + "# fast=True, show_reals=True):\n", + "# \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + "# dc_final (4), sepa_final(5), angs_final(6),\n", + "# hs, snr, dp\"\"\"\n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "# shape = snr_ss.shape\n", + "# nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# xx = fobs_cents*YR\n", + "# xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + "# xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + "# labels = np.append(sings.par_labels[idx], \n", + "# np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + "# units = sings.par_units[idx]\n", + "# yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + "# yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + "# yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + "# yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "# print(f\"{yy_ss.shape=}\")\n", + "# print(f\"{yy_bg.shape=}\")\n", + "\n", + "# print(f\"{snr_ss.shape=}\")\n", + "# print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "# for ax in axs[-1]:\n", + "# ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + "# # plot all pars and hs\n", + "# for ii,ax in enumerate(axs.flatten()[:7]):\n", + "# print('plotting', labels[ii])\n", + "# ax.set_ylabel(labels[ii])\n", + "# draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + "# color_ss, color_bg)\n", " \n", - " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", - " ii=7\n", - " ax = axs.flatten()[ii]\n", - " ax.set_ylabel(labels[ii])\n", - " print('plotting', labels[ii])\n", - "\n", - " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + "# # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + "# ii=7\n", + "# ax = axs.flatten()[ii]\n", + "# ax.set_ylabel(labels[ii])\n", + "# print('plotting', labels[ii])\n", + "\n", + "# draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# colors, fast, nfreqs, nreals, nskies, nloudest,)\n", " \n", - " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", - " ii=8\n", - " ax = axs.flatten()[ii]\n", - " ax.set_ylabel(labels[ii])\n", - " print('plotting', labels[ii])\n", - "\n", - " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " nreals, nskies)\n", + "# # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + "# ii=8\n", + "# ax = axs.flatten()[ii]\n", + "# ax.set_ylabel(labels[ii])\n", + "# print('plotting', labels[ii])\n", + "\n", + "# draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# nreals, nskies)\n", " \n", - " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", - " fig.tight_layout()\n", - " return fig" + "# draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + "# fig.tight_layout()\n", + "# return fig" ] }, { @@ -299,14 +305,14 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", - " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", - " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - " fig=plot_everything_vs_freqs(\n", - " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", - " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", - " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", - " return fig" + "# def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + "# dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + "# sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "# fig=plot_everything_vs_freqs(\n", + "# data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + "# dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + "# color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + "# return fig" ] }, { @@ -315,85 +321,85 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", - " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", - " fast=True, show_reals=True): \n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - " shape = snr_ss.shape\n", - " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - " xx = fobs_cents*YR\n", - " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", - " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", - "\n", - " units = sings.par_units[idx]\n", - " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", - " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", - " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", - " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", - "\n", - " # plot all pars and hs\n", - " for ii,ax in enumerate(axs.flatten()[:7]):\n", - " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", - " color_ss, color_bg,)\n", + "# def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + "# color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + "# fast=True, show_reals=True): \n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "# shape = snr_ss.shape\n", + "# nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# xx = fobs_cents*YR\n", + "# xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + "# xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + "# units = sings.par_units[idx]\n", + "# yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + "# yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + "# yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + "# yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + "# # plot all pars and hs\n", + "# for ii,ax in enumerate(axs.flatten()[:7]):\n", + "# draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + "# color_ss, color_bg,)\n", " \n", - " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", - " ii=7\n", - " ax = axs.flatten()[ii]\n", - " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + "# # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + "# ii=7\n", + "# ax = axs.flatten()[ii]\n", + "# draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# colors, fast, nfreqs, nreals, nskies, nloudest,)\n", " \n", - " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", - " ii=8\n", - " ax = axs.flatten()[ii]\n", - " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " nreals, nskies)\n", + "# # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + "# ii=8\n", + "# ax = axs.flatten()[ii]\n", + "# draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# nreals, nskies)\n", " \n", - " return fig\n", + "# return fig\n", "\n", "\n", - "def plot_three_models(\n", - " data, params, hard_name, shape, target_param, filename,\n", - " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", - " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", - " datlw = np.array([3,4,5]),\n", - " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + "# def plot_three_models(\n", + "# data, params, hard_name, shape, target_param, filename,\n", + "# datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + "# datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + "# datlw = np.array([3,4,5]),\n", + "# dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", " \n", - " fobs_cents = data[0]['fobs_cents']\n", - " fig, axs = holo.plot.figax(\n", - " nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5))\n", - "\n", - " idx = [0,1,2,4,5,6]\n", - " labels = np.append(sings.par_labels[idx], \n", - " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", - " 'SNR', 'Detection Probability']))\n", + "# fobs_cents = data[0]['fobs_cents']\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5))\n", + "\n", + "# idx = [0,1,2,4,5,6]\n", + "# labels = np.append(sings.par_labels[idx], \n", + "# np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + "# 'SNR', 'Detection Probability']))\n", " \n", - " for ax in axs[-1]:\n", - " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", - " for ii,ax in enumerate(axs.flatten()):\n", - " ax.set_ylabel(labels[ii])\n", + "# for ax in axs[-1]:\n", + "# ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "# for ii,ax in enumerate(axs.flatten()):\n", + "# ax.set_ylabel(labels[ii])\n", "\n", "\n", - " for ii, dat in enumerate(data):\n", - " print(f'on dat {ii}')\n", - " dsdat = detect_pspace_model(dat)\n", - " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", - " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", - " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", - " dsdat['snr_ss'], dsdat['snr_bg'], \n", - " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", - " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", - " yy=dattext_yy[ii], xx=0, fontsize=12)\n", - " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", - " fig.tight_layout()\n", + "# for ii, dat in enumerate(data):\n", + "# print(f'on dat {ii}')\n", + "# dsdat = detect_pspace_model(dat)\n", + "# sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + "# fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + "# sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + "# dsdat['snr_ss'], dsdat['snr_bg'], \n", + "# color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + "# lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + "# draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + "# yy=dattext_yy[ii], xx=0, fontsize=12)\n", + "# fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + "# fig.tight_layout()\n", "\n", - " return fig\n", + "# return fig\n", "\n", - "# fig = plot_three_models(data = data_hard_time, params = params_hard_time,\n", - "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + "# # fig = anat.plot_three_models(data = data_hard_time, params = params_hard_time,\n", + "# # hard_name=hard_name, shape=sam.shape, target_param=target_param)" ] }, { @@ -402,52 +408,52 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", + "# def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + "# \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", "\n", - " labels = sings.par_labels[idx]\n", - " units = sings.par_units[idx]\n", - " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", - " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "# labels = sings.par_labels[idx]\n", + "# units = sings.par_units[idx]\n", + "# xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "# xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", "\n", - " yy_ss = hc_ss\n", - " yy_bg = hc_bg\n", + "# yy_ss = hc_ss\n", + "# yy_bg = hc_bg\n", "\n", - " for ax in axs[:,0]:\n", - " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", - " for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(labels[ii])\n", - " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + "# for ax in axs[:,0]:\n", + "# ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "# for ii, ax in enumerate(axs.flatten()):\n", + "# ax.set_xlabel(labels[ii])\n", + "# draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", - " return fig\n", - "\n", - "def plot_three_hs_vs_binpars(data, params,\n", - " hard_name, shape, target_param, filename,\n", - " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", - " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", - " dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", - " fobs_cents = data[0]['fobs_cents']\n", + "# return fig\n", + "\n", + "# def plot_three_hs_vs_binpars(data, params,\n", + "# hard_name, shape, target_param, filename,\n", + "# datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + "# datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + "# dattext_yy = np.array([-0.02, -0.05, -0.08])):\n", + "# fobs_cents = data[0]['fobs_cents']\n", " \n", - " fig, axs = holo.plot.figax(\n", - " nrows=2, ncols=3, sharey=True, figsize=(9,4)\n", - " )\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=2, ncols=3, sharey=True, figsize=(9,4)\n", + "# )\n", " \n", - " for ii, dat in enumerate(data):\n", - " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + "# for ii, dat in enumerate(data):\n", + "# sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", " \n", - " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", - " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", - " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", - " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", - " fig.tight_layout()\n", + "# draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + "# color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + "# draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + "# yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", + "# fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + "# fig.tight_layout()\n", "\n", - " return fig\n", + "# return fig\n", "\n", - "# fig = plot_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", - "# hard_name, sam.shape, target_param)\n" + "# # fig = anat.plot_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# # hard_name, sam.shape, target_param)\n" ] }, { @@ -472,7 +478,7 @@ "metadata": {}, "outputs": [], "source": [ - "save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_rv_fullshape'" + "# save_dir = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_rv_fullshape'" ] }, { @@ -486,8 +492,8 @@ "rv_hard_time = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", "# rv_hard_time = vary_parameter('hard_time', save_dir=save_dir) # save for later so we don't have to recalculate, if \n", - "fig = plot_three_models(*rv_hard_time)\n", - "fig = plot_three_hs_vs_binpars(*rv_hard_time)" + "fig = anat.plot_three_models(*rv_hard_time, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_hard_time, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -509,8 +515,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_phi0)\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0)" + "fig = anat.plot_three_models(*rv_gsmf_phi0, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_phi0, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -534,8 +540,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_phi0_hard0)\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0_hard0)" + "fig = anat.plot_three_models(*rv_gsmf_phi0_hard0, param_names, save_dir=save_dir, save_append='_hard0')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_phi0_hard0, param_names, save_dir=save_dir, save_append='_hard0')" ] }, { @@ -560,8 +566,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_phi0_hard1)\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0_hard1)" + "fig = anat.plot_three_models(*rv_gsmf_phi0_hard1, param_names, save_dir=save_dir, save_append='_hard1')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_phi0_hard1, param_names, save_dir=save_dir, save_append='_hard1')" ] }, { @@ -583,8 +589,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_mchar0_log10)\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10)" + "fig = anat.plot_three_models(*rv_gsmf_mchar0_log10, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -607,8 +613,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_mchar0_log10_hard0)\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard0)" + "fig = anat.plot_three_models(*rv_gsmf_mchar0_log10_hard0, param_names, save_dir=save_dir, save_append='_hard0')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard0, param_names, save_dir=save_dir, save_append='_hard0')" ] }, { @@ -631,8 +637,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_mchar0_log10_hard1)\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard1)" + "fig = anat.plot_three_models(*rv_gsmf_mchar0_log10_hard1, param_names, save_dir=save_dir, save_append='_hard1')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10_hard1, param_names, save_dir=save_dir, save_append='_hard1')" ] }, { @@ -654,8 +660,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_mamp_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_mmb_mamp_log10)\n", - "fig = plot_three_hs_vs_binpars(*rv_mmb_mamp_log10)" + "fig = anat.plot_three_models(*rv_mmb_mamp_log10, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_mmb_mamp_log10, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -679,8 +685,8 @@ "rv_mmb_mamp_log10_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", " \n", - "fig = plot_three_models(*rv_mmb_mamp_log10_hard1)\n", - "fig = plot_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1)" + "fig = anat.plot_three_models(*rv_mmb_mamp_log10_hard1, param_names, save_dir=save_dir, save_append='_hard1')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_mmb_mamp_log10_hard1, param_names, save_dir=save_dir, save_append='_hard1')" ] }, { @@ -702,8 +708,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_scatter_dex = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_mmb_scatter_dex)\n", - "fig = plot_three_hs_vs_binpars(*rv_mmb_scatter_dex)" + "fig = anat.plot_three_models(*rv_mmb_scatter_dex, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_mmb_scatter_dex, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -726,8 +732,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_scatter_dex_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_mmb_scatter_dex_hard1)\n", - "fig = plot_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1)" + "fig = anat.plot_three_models(*rv_mmb_scatter_dex_hard1, param_names, save_dir=save_dir, save_append='_hard1')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_mmb_scatter_dex_hard1, param_names, save_dir=save_dir, save_append='_hard1')" ] }, { @@ -749,8 +755,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_hard_gamma_inner = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_hard_gamma_inner)\n", - "fig = plot_three_hs_vs_binpars(*rv_hard_gamma_inner)" + "fig = anat.plot_three_models(*rv_hard_gamma_inner, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_hard_gamma_inner, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -773,8 +779,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_hard_gamma_inner_hard1 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_hard_gamma_inner_hard1)\n", - "fig = plot_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1)" + "fig = anat.plot_three_models(*rv_hard_gamma_inner_hard1, param_names, save_dir=save_dir, save_append='_hard1')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_hard_gamma_inner_hard1, param_names, save_dir=save_dir, save_append='_hard1')" ] }, { @@ -789,8 +795,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_hard_gamma_inner_hard0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_hard_gamma_inner_hard0)\n", - "fig = plot_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0)" + "fig = anat.plot_three_models(*rv_hard_gamma_inner_hard0, param_names, save_dir=save_dir, save_append='_hard0')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_hard_gamma_inner_hard0, param_names, save_dir=save_dir, save_append='_hard0')" ] }, { diff --git a/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb b/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb index a94a2be8..8d8e4dc4 100644 --- a/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb +++ b/ecg-notebooks/parameter_investigation/take7B_GW_anatomy_fromsaved.ipynb @@ -21,7 +21,12 @@ "from holodeck.constants import YR, MSOL, MPC\n", "import holodeck as holo\n", "\n", - "import hasasia.sim as hsim" + "import hasasia.sim as hsim\n", + "\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" ] }, { @@ -75,20 +80,20 @@ "metadata": {}, "outputs": [], "source": [ - "NPSRS = 50\n", - "SIGMA = 3.55e-6\n", - "NSKIES = 25\n", - "THRESH = 0.5\n", - "DUR = holo.librarian.DEF_PTA_DUR\n", - "\n", - "def detect_pspace_model(data, dur=DUR,\n", - " npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", - " fobs_cents = data['fobs_cents']\n", - " hc_ss = data['hc_ss']\n", - " hc_bg = data['hc_bg']\n", - " dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", - " npsrs, sigma, nskies, thresh)\n", - " return dsdata" + "# NPSRS = 50\n", + "# SIGMA = 3.55e-6\n", + "# NSKIES = 25\n", + "# THRESH = 0.5\n", + "# DUR = holo.librarian.DEF_PTA_DUR\n", + "\n", + "# def detect_pspace_model(data, dur=DUR,\n", + "# npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES, thresh=THRESH):\n", + "# fobs_cents = data['fobs_cents']\n", + "# hc_ss = data['hc_ss']\n", + "# hc_bg = data['hc_bg']\n", + "# dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur,\n", + "# npsrs, sigma, nskies, thresh)\n", + "# return dsdata" ] }, { @@ -105,65 +110,65 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_sample_text(fig, params, param_names, \n", - " xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", - " text = ''\n", - " for pp, name in enumerate(param_names):\n", - " text = text+\"'%s'=%.2e, \" % (name, params[name])\n", - " # if pp == int(len(param_names)/2):\n", - " # text = text+'\\n'\n", - " fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", - "\n", - "\n", - "def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", - " show_medians = False, show_ci=False, show_reals=True):\n", - " if show_reals:\n", - " if (xx_ss is not None) and (yy_ss is not None):\n", - " if fast_ss:\n", - " ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", - " else:\n", - " colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", - " for rr in range(len(yy_ss[0])):\n", - " ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", - " if (xx_bg is not None) and (yy_bg is not None):\n", - " ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", - " # if show_medians:\n", - " # if (xx_ss is not None) and (yy_ss is not None):\n", - " # ax.plot(np.median(xx_ss, axis=())\n", - " # if (xx_bg is not None) and (yy_bg is not None):\n", - "\n", - "\n", - "\n", - "\n", - "def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - "\n", - " labels = sings.par_labels[idx]\n", - " units = sings.par_units[idx]\n", - " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", - " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", - " print(f\"{xx_ss.shape=}\")\n", - " print(f\"{xx_bg.shape=}\")\n", - "\n", - " yy_ss = hc_ss\n", - " yy_bg = hc_bg\n", - " print(f\"{yy_ss.shape=}\")\n", - " print(f\"{yy_bg.shape=}\")\n", - "\n", - "\n", - " fig, axs = holo.plot.figax(\n", - " nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", - " for ax in axs[:,0]:\n", - " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", - " for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(labels[ii])\n", - " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + "# def draw_sample_text(fig, params, param_names, \n", + "# xx=0.1, yy=-0.025, fontsize=10, color='k'):\n", + "# text = ''\n", + "# for pp, name in enumerate(param_names):\n", + "# text = text+\"'%s'=%.2e, \" % (name, params[name])\n", + "# # if pp == int(len(param_names)/2):\n", + "# # text = text+'\\n'\n", + "# fig.text(xx, yy, text, fontsize=fontsize, color=color, alpha=0.75)\n", + "\n", + "\n", + "# def draw_hs_vs_par(ax, xx_ss=None, yy_ss=None, xx_bg=None, yy_bg=None, color_ss='r', color_bg='k', fast_ss=True, \n", + "# show_medians = False, show_ci=False, show_reals=True):\n", + "# if show_reals:\n", + "# if (xx_ss is not None) and (yy_ss is not None):\n", + "# if fast_ss:\n", + "# ax.scatter(xx_ss.flatten(), yy_ss.flatten(), marker='o', s=15, alpha=0.1, color=color_ss)\n", + "# else:\n", + "# colors = cm.rainbow(np.linspace(0,1,len(yy_ss[0])))\n", + "# for rr in range(len(yy_ss[0])):\n", + "# ax.scatter(xx_ss[:,rr,:].flatten(), yy_ss[:,rr,:].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr])\n", + "# if (xx_bg is not None) and (yy_bg is not None):\n", + "# ax.scatter(xx_bg.flatten(), yy_bg.flatten(), marker='x', s=15, alpha=0.1, color=color_bg)\n", + "# # if show_medians:\n", + "# # if (xx_ss is not None) and (yy_ss is not None):\n", + "# # ax.plot(np.median(xx_ss, axis=())\n", + "# # if (xx_bg is not None) and (yy_bg is not None):\n", + "\n", + "\n", + "\n", + "\n", + "# def plot_hs_vs_binpars(fobs_cents, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True):\n", + "# \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "\n", + "# labels = sings.par_labels[idx]\n", + "# units = sings.par_units[idx]\n", + "# xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "# xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "# print(f\"{xx_ss.shape=}\")\n", + "# print(f\"{xx_bg.shape=}\")\n", + "\n", + "# yy_ss = hc_ss\n", + "# yy_bg = hc_bg\n", + "# print(f\"{yy_ss.shape=}\")\n", + "# print(f\"{yy_bg.shape=}\")\n", + "\n", + "\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=2, ncols=3, sharey=True, figsize=(12,6))\n", + "# for ax in axs[:,0]:\n", + "# ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "# for ii, ax in enumerate(axs.flatten()):\n", + "# ax.set_xlabel(labels[ii])\n", + "# draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", - " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", - " fig.tight_layout()\n", - " return fig" + "# draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12)\n", + "# fig.tight_layout()\n", + "# return fig" ] }, { @@ -180,113 +185,113 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_par_vs_freq(\n", - " ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", - " color_ss, color_bg, ls_bg='-',\n", - " show_bg_median=True, show_bg_ci=True, \n", - " show_ss_err=True, show_ss_reals=True):\n", - "\n", - " if show_bg_median:\n", - " ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", - " if show_bg_ci:\n", - " for pp in [50, 98]:\n", - " conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1)\n", - " ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", - " if show_ss_err:\n", - " ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1),\n", - " color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", - " if show_ss_reals:\n", - " ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20)\n", - "\n", - "\n", - "def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", - " colors, fast, nfreqs, nreals, nskies, nloudest,):\n", + "# def draw_par_vs_freq(\n", + "# ax, xx, xx_ss, yy_ss, xx_bg, yy_bg, \n", + "# color_ss, color_bg, ls_bg='-',\n", + "# show_bg_median=True, show_bg_ci=True, \n", + "# show_ss_err=True, show_ss_reals=True):\n", + "\n", + "# if show_bg_median:\n", + "# ax.plot(xx, np.median(yy_bg, axis=-1), color=color_bg, linestyle=ls_bg, alpha=0.75)\n", + "# if show_bg_ci:\n", + "# for pp in [50, 98]:\n", + "# conf = np.percentile(yy_bg, [50-pp/2, 50+pp/2], axis=-1)\n", + "# ax.fill_between(xx, *conf, color=color_bg, alpha=0.25)\n", + "# if show_ss_err:\n", + "# ax.errorbar(xx, np.median(yy_ss[:,:,0], axis=-1), yerr=np.std(yy_ss[:,:,0], axis=-1),\n", + "# color=color_ss, alpha=0.5, marker='o', markersize=5, capsize=5)\n", + "# if show_ss_reals:\n", + "# ax.scatter(xx_ss[...,0].flatten(), yy_ss[:,:,0].flatten(), color=color_ss, alpha=0.1, s=20)\n", + "\n", + "\n", + "# def draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg, \n", + "# colors, fast, nfreqs, nreals, nskies, nloudest,):\n", " \n", - " xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", - " if fast:\n", - " ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss)\n", - " for rr in range(nreals):\n", - " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", - " else:\n", - " xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", - " for rr in range(nreals):\n", - " for ll in range(nloudest):\n", - " edgecolor = 'k' if ll==0 else None\n", - " ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", - " ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", - "\n", - "def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " nreals, nskies):\n", - " for rr in range(nreals):\n", - " ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", - " for ss in range(nskies):\n", - " ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", - "\n", - "def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", - " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", - " fast=True, show_reals=True):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", - " dc_final (4), sepa_final(5), angs_final(6),\n", - " hs, snr, dp\"\"\"\n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - " shape = snr_ss.shape\n", - " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - " xx = fobs_cents*YR\n", - " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", - " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", - "\n", - " labels = np.append(sings.par_labels[idx], \n", - " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", - " units = sings.par_units[idx]\n", - " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", - " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", - " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", - " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", - " print(f\"{yy_ss.shape=}\")\n", - " print(f\"{yy_bg.shape=}\")\n", - "\n", - " print(f\"{snr_ss.shape=}\")\n", - " print(f\"{dp_ss.shape=}\")\n", - "\n", - "\n", - " fig, axs = holo.plot.figax(\n", - " nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", - " for ax in axs[-1]:\n", - " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", - "\n", - " # plot all pars and hs\n", - " for ii,ax in enumerate(axs.flatten()[:7]):\n", - " print('plotting', labels[ii])\n", - " ax.set_ylabel(labels[ii])\n", - " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", - " color_ss, color_bg)\n", + "# xx_snr = np.repeat(xx, nreals*nskies*nloudest).reshape(nfreqs, nreals, nskies, nloudest)\n", + "# if fast:\n", + "# ax.scatter(xx_snr.flatten(), snr_ss.flatten(), marker='o', alpha=0.05, s=5, color=color_ss)\n", + "# for rr in range(nreals):\n", + "# ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg)\n", + "# else:\n", + "# xx_skies = np.repeat(xx, nskies).reshape(nfreqs, nskies)\n", + "# for rr in range(nreals):\n", + "# for ll in range(nloudest):\n", + "# edgecolor = 'k' if ll==0 else None\n", + "# ax.scatter(xx_skies.flatten(), snr_ss[:,rr,:,ll].flatten(), marker='o', s=10, alpha=0.1, color=colors[rr], edgecolor=edgecolor)\n", + "# ax.axhline(snr_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.1, color=color_bg) \n", + "\n", + "# def draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# nreals, nskies):\n", + "# for rr in range(nreals):\n", + "# ax.axhline(dp_bg[rr], ls=ls_bg, lw=lw_bg, alpha=0.25, color=color_bg)\n", + "# for ss in range(nskies):\n", + "# ax.axhline(dp_ss[rr,ss], ls=ls_ss, lw=lw_ss, alpha=0.1, color=color_ss)\n", + "\n", + "# def plot_everything_vs_freqs(fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + "# color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + "# fast=True, show_reals=True):\n", + "# \"\"\" plot mtot (0), mrat (1), redz_init (2), \n", + "# dc_final (4), sepa_final(5), angs_final(6),\n", + "# hs, snr, dp\"\"\"\n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "# shape = snr_ss.shape\n", + "# nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# xx = fobs_cents*YR\n", + "# xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + "# xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + "# labels = np.append(sings.par_labels[idx], \n", + "# np.array([plot.LABEL_CHARACTERISTIC_STRAIN, 'SNR', 'Detection Probability']))\n", + "# units = sings.par_units[idx]\n", + "# yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + "# yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + "# yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + "# yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "# print(f\"{yy_ss.shape=}\")\n", + "# print(f\"{yy_bg.shape=}\")\n", + "\n", + "# print(f\"{snr_ss.shape=}\")\n", + "# print(f\"{dp_ss.shape=}\")\n", + "\n", + "\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=3, ncols=3, sharex=True, figsize=(15,10))\n", + "# for ax in axs[-1]:\n", + "# ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "\n", + "# # plot all pars and hs\n", + "# for ii,ax in enumerate(axs.flatten()[:7]):\n", + "# print('plotting', labels[ii])\n", + "# ax.set_ylabel(labels[ii])\n", + "# draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + "# color_ss, color_bg)\n", " \n", - " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", - " ii=7\n", - " ax = axs.flatten()[ii]\n", - " ax.set_ylabel(labels[ii])\n", - " print('plotting', labels[ii])\n", - "\n", - " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + "# # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + "# ii=7\n", + "# ax = axs.flatten()[ii]\n", + "# ax.set_ylabel(labels[ii])\n", + "# print('plotting', labels[ii])\n", + "\n", + "# draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# colors, fast, nfreqs, nreals, nskies, nloudest,)\n", " \n", - " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", - " ii=8\n", - " ax = axs.flatten()[ii]\n", - " ax.set_ylabel(labels[ii])\n", - " print('plotting', labels[ii])\n", - "\n", - " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " nreals, nskies)\n", + "# # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + "# ii=8\n", + "# ax = axs.flatten()[ii]\n", + "# ax.set_ylabel(labels[ii])\n", + "# print('plotting', labels[ii])\n", + "\n", + "# draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# nreals, nskies)\n", " \n", - " draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", - " fig.tight_layout()\n", - " return fig" + "# draw_sample_text(fig, params, param_names, xx=0.1, yy=-0.05, fontsize=12) \n", + "# fig.tight_layout()\n", + "# return fig" ] }, { @@ -303,14 +308,14 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", - " dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", - " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - " fig=plot_everything_vs_freqs(\n", - " data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", - " dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", - " color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", - " return fig" + "# def plot_everything_vs_freqs_from_data(data, fast=True, color_ss='r', color_bg='k'):\n", + "# dsdata = detect_pspace_model(data['fobs_cents'], data['hc_ss'], data['hc_bg'])\n", + "# sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "# fig=plot_everything_vs_freqs(\n", + "# data['fobs_cents'], data['hc_ss'], data['hc_bg'], sspar, data['bgpar'],\n", + "# dsdata['dp_ss'], dsdata['dp_bg'], dsdata['snr_ss'], dsdata['snr_bg'],\n", + "# color_ss=color_ss, color_bg=color_bg, fast=fast, )\n", + "# return fig" ] }, { @@ -319,89 +324,89 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", - " color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", - " fast=True, show_reals=True): \n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - " shape = snr_ss.shape\n", - " nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", - " xx = fobs_cents*YR\n", - " xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", - " xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", - "\n", - " units = sings.par_units[idx]\n", - " yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", - " yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", - " yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", - " yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", - "\n", - " # plot all pars and hs\n", - " for ii,ax in enumerate(axs.flatten()[:7]):\n", - " draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", - " color_ss, color_bg,)\n", + "# def draw_everything_model(fig, axs, fobs_cents, hc_ss, hc_bg, sspar, bgpar, dp_ss, dp_bg, snr_ss, snr_bg,\n", + "# color_ss='r', color_bg='k', ls_ss = ':', ls_bg = '--', lw_ss = 2, lw_bg = 2, \n", + "# fast=True, show_reals=True): \n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "# shape = snr_ss.shape\n", + "# nfreqs, nreals, nskies, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "# xx = fobs_cents*YR\n", + "# xx_ss = np.repeat(xx, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + "# xx_bg = np.repeat(xx, nreals).reshape(nfreqs, nreals)\n", + "\n", + "# units = sings.par_units[idx]\n", + "# yy_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis] # shape 6, F,R,L\n", + "# yy_ss = np.append(yy_ss, hc_ss).reshape(7, nfreqs, nreals, nloudest) # shape 7, F,R,L\n", + "# yy_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis] # shape 6,F,R\n", + "# yy_bg = np.append(yy_bg, hc_bg).reshape(7, nfreqs, nreals) # shape 7,F,R\n", + "\n", + "# # plot all pars and hs\n", + "# for ii,ax in enumerate(axs.flatten()[:7]):\n", + "# draw_par_vs_freq(ax, xx, xx_ss, yy_ss[ii], xx_bg, yy_bg[ii], \n", + "# color_ss, color_bg,)\n", " \n", - " # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", - " ii=7\n", - " ax = axs.flatten()[ii]\n", - " draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " colors, fast, nfreqs, nreals, nskies, nloudest,)\n", + "# # plot snr, snr_ss = (F,R,L), snr_bg = (R)\n", + "# ii=7\n", + "# ax = axs.flatten()[ii]\n", + "# draw_snr_vs_freqs(ax, xx, snr_ss, snr_bg, \n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# colors, fast, nfreqs, nreals, nskies, nloudest,)\n", " \n", - " # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", - " ii=8\n", - " ax = axs.flatten()[ii]\n", - " draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", - " color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", - " nreals, nskies)\n", + "# # plot detection probability, dp_ss = (R,S), dp_bg = (R)\n", + "# ii=8\n", + "# ax = axs.flatten()[ii]\n", + "# draw_dp_vs_freqs(ax, dp_ss, dp_bg,\n", + "# color_ss, color_bg, ls_ss, ls_bg, lw_ss, lw_bg,\n", + "# nreals, nskies)\n", " \n", - " return fig\n", + "# return fig\n", "\n", "\n", - "def plot_three_models(\n", - " data, params, hard_name, shape, target_param, filename,\n", - " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", - " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", - " datlw = np.array([3,4,5]),\n", - " dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append=''):\n", + "# def plot_three_models(\n", + "# data, params, hard_name, shape, target_param, filename,\n", + "# datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + "# datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + "# datlw = np.array([3,4,5]),\n", + "# dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append=''):\n", " \n", - " fobs_cents = data[0]['fobs_cents']\n", - " fig, axs = holo.plot.figax(\n", - " nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5))\n", - "\n", - " idx = [0,1,2,4,5,6]\n", - " labels = np.append(sings.par_labels[idx], \n", - " np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", - " 'SNR', 'Detection Probability']))\n", + "# fobs_cents = data[0]['fobs_cents']\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=3, ncols=3, sharex=True, figsize=(11.25,7.5))\n", + "\n", + "# idx = [0,1,2,4,5,6]\n", + "# labels = np.append(sings.par_labels[idx], \n", + "# np.array([plot.LABEL_CHARACTERISTIC_STRAIN, \n", + "# 'SNR', 'Detection Probability']))\n", " \n", - " for ax in axs[-1]:\n", - " ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", - " for ii,ax in enumerate(axs.flatten()):\n", - " ax.set_ylabel(labels[ii])\n", - "\n", - "\n", - " for ii, dat in enumerate(data):\n", - " print(f'on dat {ii}')\n", - " dsdat = detect_pspace_model(dat)\n", - " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", - " fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", - " sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", - " dsdat['snr_ss'], dsdat['snr_bg'], \n", - " color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", - " lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", - " yy=dattext_yy[ii], xx=0, fontsize=12)\n", - " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", - " fig.tight_layout()\n", - " if save_dir is not None:\n", - " str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2])\n", - " filename = save_dir+'/%s_allvsfreqs%s_%s.png' % (target_param, save_append, str_shape) \n", - " fig.savefig(filename, dpi=100)\n", - "\n", - " return fig\n", - "\n", - "# fig = plot_three_models(data = data_hard_time, params = params_hard_time,\n", - "# hard_name=hard_name, shape=sam.shape, target_param=target_param)" + "# for ax in axs[-1]:\n", + "# ax.set_xlabel(holo.plot.LABEL_GW_FREQUENCY_YR)\n", + "# for ii,ax in enumerate(axs.flatten()):\n", + "# ax.set_ylabel(labels[ii])\n", + "\n", + "\n", + "# for ii, dat in enumerate(data):\n", + "# print(f'on dat {ii}')\n", + "# dsdat = detect_pspace_model(dat)\n", + "# sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + "# fig = draw_everything_model(fig, axs, fobs_cents, dat['hc_ss'], dat['hc_bg'], \n", + "# sspar, dat['bgpar'], dsdat['dp_ss'], dsdat['dp_bg'],\n", + "# dsdat['snr_ss'], dsdat['snr_bg'], \n", + "# color_ss=datcolor_ss[ii], color_bg=datcolor_bg[ii],\n", + "# lw_bg = datlw[ii], lw_ss = datlw[ii]) \n", + "# draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + "# yy=dattext_yy[ii], xx=0, fontsize=12)\n", + "# fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + "# fig.tight_layout()\n", + "# if save_dir is not None:\n", + "# str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2])\n", + "# filename = save_dir+'/%s_allvsfreqs%s_%s.png' % (target_param, save_append, str_shape) \n", + "# fig.savefig(filename, dpi=100)\n", + "\n", + "# return fig\n", + "\n", + "# # fig = plot_three_models(data = data_hard_time, params = params_hard_time,\n", + "# # hard_name=hard_name, shape=sam.shape, target_param=target_param)" ] }, { @@ -410,56 +415,56 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True,):\n", - " \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", - " colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", - " idx = [0,1,2,4,5,6]\n", - "\n", - " labels = sings.par_labels[idx]\n", - " units = sings.par_units[idx]\n", - " xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", - " xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", - "\n", - " yy_ss = hc_ss\n", - " yy_bg = hc_bg\n", - "\n", - " for ax in axs[:,0]:\n", - " ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", - " for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(labels[ii])\n", - " draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", + "# def draw_hs_vs_binpars(fig, axs, hc_ss, hc_bg, sspar, bgpar, color_ss='r', color_bg='k', fast_ss=True,):\n", + "# \"\"\" plot mtot (0), mrat (1), redz_init (2), dc_final (4), sepa_final(5), angs_final(6)\"\"\"\n", + "# colors = cm.rainbow(np.linspace(0,1,len(hc_ss[0])))\n", + "# idx = [0,1,2,4,5,6]\n", + "\n", + "# labels = sings.par_labels[idx]\n", + "# units = sings.par_units[idx]\n", + "# xx_ss = sspar[idx]*units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "# xx_bg = bgpar[idx]*units[:,np.newaxis,np.newaxis]\n", + "\n", + "# yy_ss = hc_ss\n", + "# yy_bg = hc_bg\n", + "\n", + "# for ax in axs[:,0]:\n", + "# ax.set_ylabel(holo.plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "# for ii, ax in enumerate(axs.flatten()):\n", + "# ax.set_xlabel(labels[ii])\n", + "# draw_hs_vs_par(ax, xx_ss[ii], yy_ss, xx_bg[ii], yy_bg, color_ss, color_bg, fast_ss, colors)\n", " \n", - " return fig\n", - "\n", - "def plot_three_hs_vs_binpars(data, params,\n", - " hard_name, shape, target_param, filename,\n", - " datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", - " datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", - " dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append='',):\n", - " fobs_cents = data[0]['fobs_cents']\n", + "# return fig\n", + "\n", + "# def plot_three_hs_vs_binpars(data, params,\n", + "# hard_name, shape, target_param, filename,\n", + "# datcolor_ss = np.array(['limegreen', 'cornflowerblue', 'tomato']),\n", + "# datcolor_bg = np.array(['#003300', 'darkblue', 'darkred']),\n", + "# dattext_yy = np.array([-0.02, -0.05, -0.08]), save_dir=None, save_append='',):\n", + "# fobs_cents = data[0]['fobs_cents']\n", " \n", - " fig, axs = holo.plot.figax(\n", - " nrows=2, ncols=3, sharey=True, figsize=(9,4)\n", - " )\n", + "# fig, axs = holo.plot.figax(\n", + "# nrows=2, ncols=3, sharey=True, figsize=(9,4)\n", + "# )\n", " \n", - " for ii, dat in enumerate(data):\n", - " sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", + "# for ii, dat in enumerate(data):\n", + "# sspar = sings.all_sspars(fobs_cents, dat['sspar'])\n", " \n", - " draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", - " color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", - " draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", - " yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", - " fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", - " fig.tight_layout()\n", - " if save_dir is not None:\n", - " str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2])\n", - " filename = save_dir+'/%s_hsvsbinpars%s_%s.png' % (target_param, save_append, str_shape) \n", - " fig.savefig(filename, dpi=100)\n", - "\n", - " return fig\n", - "\n", - "# fig = plot_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", - "# hard_name, sam.shape, target_param)\n" + "# draw_hs_vs_binpars(fig, axs, dat['hc_ss'], dat['hc_bg'], sspar, dat['bgpar'], fast_ss=True,\n", + "# color_bg = datcolor_bg[ii], color_ss=datcolor_ss[ii])\n", + "# draw_sample_text(fig, params[ii], param_names, color=datcolor_bg[ii], \n", + "# yy=dattext_yy[ii], xx=0, fontsize=9.5)\n", + "# fig.suptitle(\"%s, %s, Varying '%s'\" % (hard_name, str(shape), target_param))\n", + "# fig.tight_layout()\n", + "# if save_dir is not None:\n", + "# str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2])\n", + "# filename = save_dir+'/%s_hsvsbinpars%s_%s.png' % (target_param, save_append, str_shape) \n", + "# fig.savefig(filename, dpi=100)\n", + "\n", + "# return fig\n", + "\n", + "# # fig = plot_three_hs_vs_binpars(data_hard_time, params_hard_time, \n", + "# # hard_name, sam.shape, target_param)\n" ] }, { @@ -489,8 +494,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_phi0 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_phi0, save_dir=save_dir, save_append='_p.5')\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_phi0, save_dir=save_dir, save_append='_p.5')" + "fig = anat.plot_three_models(*rv_gsmf_phi0, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_phi0, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -512,8 +517,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_gsmf_mchar0_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_gsmf_mchar0_log10, save_dir=save_dir, save_append='_p.5')\n", - "fig = plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10, save_dir=save_dir, save_append='_p.5')" + "fig = anat.plot_three_models(*rv_gsmf_mchar0_log10, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_gsmf_mchar0_log10, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -535,8 +540,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_mamp_log10 = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_mmb_mamp_log10, save_dir=save_dir, save_append='_p.5')\n", - "fig = plot_three_hs_vs_binpars(*rv_mmb_mamp_log10, save_dir=save_dir, save_append='_p.5')" + "fig = anat.plot_three_models(*rv_mmb_mamp_log10, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_mmb_mamp_log10, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { @@ -558,8 +563,8 @@ "npz = np.load(filename, allow_pickle=True)\n", "rv_mmb_scatter_dex = (npz['data'], npz['params'], npz['hard_name'], npz['shape'], \n", " npz['target_param'], filename)\n", - "fig = plot_three_models(*rv_mmb_scatter_dex, save_dir=save_dir, save_append='_p.5')\n", - "fig = plot_three_hs_vs_binpars(*rv_mmb_scatter_dex, save_dir=save_dir, save_append='_p.5')" + "fig = anat.plot_three_models(*rv_mmb_scatter_dex, param_names, save_dir=save_dir, save_append='_p.5')\n", + "fig = anat.plot_three_hs_vs_binpars(*rv_mmb_scatter_dex, param_names, save_dir=save_dir, save_append='_p.5')" ] }, { diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb new file mode 100644 index 00000000..e69de29b From 8447b1008c92133d762491fef270256c204cb7da Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 15:20:42 -0700 Subject: [PATCH 083/291] Added .history for vs code backups to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 04db942c..6db53cc5 100644 --- a/.gitignore +++ b/.gitignore @@ -136,4 +136,5 @@ run_gen_lib_sams__* *.slurm # Mac Desktop Services -.DS_Store \ No newline at end of file +.DS_Store +.history \ No newline at end of file From c14928a26d994e7ef47ba5b26d196fe493f7dfe1 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 16:14:00 -0700 Subject: [PATCH 084/291] Wrote some dadt functions --- .../take8_anatomy_time_vs_sepa.ipynb | 291 ++++++++++++++++++ 1 file changed, 291 insertions(+) diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index e69de29b..75fd7b1f 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -0,0 +1,291 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "a;sfdn" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # use one file to get the shape\n", + "# npz_hard_time = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + "# allow_pickle=True) \n", + "# print(npz_hard_time.files)\n", + "# SHAPE = npz_hard_time['shape']\n", + "# npz_hard_time.close()\n", + "\n", + "# # get param names\n", + "# pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "# param_names = pspace.param_names\n", + "# print(param_names)\n", + "\n", + "# # set directory path\n", + "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "# save_dir=sam_loc+'/figures' " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Vary parameters" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE=20\n", + "NREALS=30\n", + "NFREQS=40\n", + "\n", + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " pars=None, save_dir=None \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, hard_name, sam.shape, target_param, filename)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{data[1].keys()=}\")\n", + "print(f\"{params[1]=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Timescales" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sings.par_names)\n", + "fobs_gw_cents = data['fobs_cents']\n", + "sspar = sings.all_sspars(fobs_gw_cents, data['sspar'])\n", + "bgpar = data['bgpar']\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM()\n", + "print(data.keys())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(bgpar[0].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def tau_from_dadt(dadt, sepa):\n", + " \"\"\" tau = dt/dlna = dt/(da/a) = a*(dt/da) = a/(da/dt)\"\"\"\n", + " tau = (sepa)/dadt\n", + " return tau\n", + "def tau_from_pars(sspar, bgpar, hard=holo.hardening.Hard_GW()):\n", + " \"\"\" pars contain [mtot, mrat, redz_init, redz_final, dcom_final, sepa_final, angs_final]\n", + " each for ss is in shape F,R,L and each for bg is in shape F,R\"\"\"\n", + " dadt_ss = hard.dadt(sspar[0], sspar[1], sspar[5])\n", + " dadt_bg = hard.dadt(bgpar[0], bgpar[1], bgpar[5])\n", + "\n", + " tau_ss = tau_from_dadt(dadt_ss, sspar[5])\n", + " tau_bg = tau_from_dadt(dadt_bg, bgpar[5])\n", + " return tau_ss, tau_bg \n", + "\n", + "tau_ss, tau_bg = tau_from_pars(sspar, bgpar, )\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data2 = rv_hard_time[0][1]\n", + "print(data2.keys())" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot Hardening Time vs. Separation" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sings.par_names)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sepa_idx = np.where(sings.par_names=='sepa_final')[0]\n", + "print(sepa_idx)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data = rv_hard_time[0][1]\n", + "\n", + "\n", + "xlabels = ['Binary Separation [pc]', 'GW Frequency [nHz]']\n", + "ylabels = ['Hardening Time [Gyr]', 'GW Characteristic Strain']\n", + "\n", + "fig, axs = plot.figax(nrows=2, figsize=(5,6)\n", + " )\n", + "for ii,ax in enumerate(axs):\n", + " ax.set_xlabel(xlabels[ii])\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "fig.tight_layout()\n", + "\n", + "\n", + "\n", + "\n", + "x1_bg = bgpar[sepa_idx]\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From a5473db09c6854dcd10ff88687c20d064d239dc2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 16:55:45 -0700 Subject: [PATCH 085/291] Changed holo.sam to holo.sams in init_sam of param_spaces.py. --- holodeck/param_spaces.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/holodeck/param_spaces.py b/holodeck/param_spaces.py index 1e80842f..8dc4f30e 100644 --- a/holodeck/param_spaces.py +++ b/holodeck/param_spaces.py @@ -184,7 +184,7 @@ def _init_hard(cls, sam, settings): @classmethod def _init_sam(cls, sam_shape, settings): - gsmf = holo.sam.GSMF_Schechter( + gsmf = holo.sams.GSMF_Schechter( phi0=settings['gsmf_phi0'], phiz=settings['gsmf_phiz'], mchar0_log10=settings['gsmf_mchar0_log10'], @@ -192,14 +192,14 @@ def _init_sam(cls, sam_shape, settings): alpha0=settings['gsmf_alpha0'], alphaz=settings['gsmf_alphaz'], ) - gpf = holo.sam.GPF_Power_Law( + gpf = holo.sams.GPF_Power_Law( frac_norm_allq=settings['gpf_frac_norm_allq'], malpha=settings['gpf_malpha'], qgamma=settings['gpf_qgamma'], zbeta=settings['gpf_zbeta'], max_frac=settings['gpf_max_frac'], ) - gmt = holo.sam.GMT_Power_Law( + gmt = holo.sams.GMT_Power_Law( time_norm=settings['gmt_norm']*GYR, malpha=settings['gmt_malpha'], qgamma=settings['gmt_qgamma'], @@ -211,7 +211,7 @@ def _init_sam(cls, sam_shape, settings): scatter_dex=settings['mmb_scatter_dex'], ) - sam = holo.sam.Semi_Analytic_Model( + sam = holo.sams.Semi_Analytic_Model( gsmf=gsmf, gpf=gpf, gmt=gmt, mmbulge=mmbulge, shape=sam_shape, ) From a532a2117c18b8dc9e14aa4701886c1835babe76 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 16:56:14 -0700 Subject: [PATCH 086/291] Working on getting dadt, problems with norm. --- .../take8_anatomy_time_vs_sepa.ipynb | 113 +++++------------- 1 file changed, 27 insertions(+), 86 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index 75fd7b1f..f9ad5cc9 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -20,6 +20,7 @@ "import holodeck.single_sources as sings\n", "from holodeck.constants import YR, MSOL, MPC\n", "import holodeck as holo\n", + "from holodeck.sams import sam\n", "\n", "import hasasia.sim as hsim\n", "\n", @@ -33,8 +34,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "\n", - "a;sfdn" + "# Get PSpace Info" ] }, { @@ -43,17 +43,22 @@ "metadata": {}, "outputs": [], "source": [ - "# # use one file to get the shape\n", - "# npz_hard_time = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", - "# allow_pickle=True) \n", - "# print(npz_hard_time.files)\n", - "# SHAPE = npz_hard_time['shape']\n", - "# npz_hard_time.close()\n", - "\n", - "# # get param names\n", - "# pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", - "# param_names = pspace.param_names\n", - "# print(param_names)\n", + "# use one file to get the shape\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True) \n", + "print(npz.files)\n", + "data = npz['data']\n", + "params = npz['params']\n", + "hard_name = npz['hard_name']\n", + "shape = npz['shape']\n", + "target_param = npz['target_param']\n", + "\n", + "npz.close()\n", + "\n", + "# get param names\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=shape, seed=None)\n", + "param_names = pspace.param_names\n", + "print(param_names)\n", "\n", "# # set directory path\n", "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", @@ -65,62 +70,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Vary parameters" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "SHAPE=20\n", - "NREALS=30\n", - "NFREQS=40\n", - "\n", - "def vary_parameter(\n", - " target_param, # the name of the parameter, has to exist in `param_names`\n", - " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", - " pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", - " pars=None, save_dir=None \n", - " ):\n", - " # get the parameter names from this library-space\n", - " param_names = pspace.param_names\n", - " num_pars = len(pspace.param_names)\n", - " print(f\"{num_pars=} :: {param_names=}\")\n", - "\n", - " # choose each parameter to be half-way across the range provided by the library\n", - " if pars is None:\n", - " pars = 0.5 * np.ones(num_pars) \n", - " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", - " # Choose parameter to vary\n", - " param_idx = param_names.index(target_param)\n", - "\n", - " data = []\n", - " params = []\n", - " for ii, par in enumerate(params_list):\n", - " pars[param_idx] = par\n", - " print(f\"{ii=}, {pars=}\")\n", - " # _params = pspace.param_samples[0]*pars\n", - " _params = pspace.normalized_params(pars)\n", - " params.append(_params)\n", - " # construct `sam` and `hard` instances based on these parameters\n", - " sam, hard = pspace.model_for_params(_params)\n", - " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", - " hard_name = 'Fixed Time'\n", - " elif isinstance(hard, holo.hardening.Hard_GW):\n", - " hard_name = 'GW Only'\n", - " # run this model, retrieving binary parameters and the GWB\n", - " _data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, \n", - " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", - " data.append(_data)\n", - " if save_dir is not None:\n", - " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", - " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", - " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", - " print('saved to %s' % filename)\n", - "\n", - " return (data, params, hard_name, sam.shape, target_param, filename)" + "### Make Model" ] }, { @@ -129,8 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(f\"{data[1].keys()=}\")\n", - "print(f\"{params[1]=}\")" + "sam1, hard1 = pspace.model_for_params(params[1])\n" ] }, { @@ -148,27 +97,19 @@ "outputs": [], "source": [ "print(sings.par_names)\n", - "fobs_gw_cents = data['fobs_cents']\n", - "sspar = sings.all_sspars(fobs_gw_cents, data['sspar'])\n", - "bgpar = data['bgpar']\n", - "hard = holo.hardening.Fixed_Time_2PL_SAM()\n", - "print(data.keys())" + "fobs_gw_cents = data[1]['fobs_cents']\n", + "sspar1 = sings.all_sspars(fobs_gw_cents, data[1]['sspar'])\n", + "bgpar1 = data[1]['bgpar']\n", + "print(data[1].keys())" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "print(bgpar[0].shape)" + "print(sspar1.shape)" ] }, { @@ -191,7 +132,7 @@ " tau_bg = tau_from_dadt(dadt_bg, bgpar[5])\n", " return tau_ss, tau_bg \n", "\n", - "tau_ss, tau_bg = tau_from_pars(sspar, bgpar, )\n", + "tau_ss, tau_bg = tau_from_pars(sspar1, bgpar1, hard1)\n", "\n" ] }, @@ -202,7 +143,7 @@ "outputs": [], "source": [ "data2 = rv_hard_time[0][1]\n", - "print(data2.keys())" + "print(data2.keys)" ] }, { From 22b3ee4f2f6e102d5a972d8ad66c97c45727f9e2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 22:19:47 -0700 Subject: [PATCH 087/291] Plotted varying hard_gamma_inner, working on varying hard_tau --- .../take8_anatomy_time_vs_sepa.ipynb | 420 ++++++++++++++++-- 1 file changed, 380 insertions(+), 40 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index f9ad5cc9..40d4b18d 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -18,7 +18,7 @@ "\n", "from holodeck import plot, detstats\n", "import holodeck.single_sources as sings\n", - "from holodeck.constants import YR, MSOL, MPC\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", "import holodeck as holo\n", "from holodeck.sams import sam\n", "\n", @@ -29,6 +29,31 @@ "import anatomy as anat" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Try again" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sams.Semi_Analytic_Model(shape=10)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Nothing below this makes sense" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -59,27 +84,22 @@ "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=shape, seed=None)\n", "param_names = pspace.param_names\n", "print(param_names)\n", + "print(f\"{shape=}\")\n", + "print(f\"{data[0]['hc_ss'].shape}\")\n", + "print(f\"{data[0].keys()=}\")\n", "\n", "# # set directory path\n", "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", "# save_dir=sam_loc+'/figures' " ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Make Model" - ] - }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "sam1, hard1 = pspace.model_for_params(params[1])\n" + "print(data[0]['gwb_params'][0].shape)" ] }, { @@ -87,7 +107,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Timescales" + "### Make Model" ] }, { @@ -96,11 +116,11 @@ "metadata": {}, "outputs": [], "source": [ - "print(sings.par_names)\n", + "sam1, hard1 = pspace.model_for_params(params[1])\n", "fobs_gw_cents = data[1]['fobs_cents']\n", - "sspar1 = sings.all_sspars(fobs_gw_cents, data[1]['sspar'])\n", - "bgpar1 = data[1]['bgpar']\n", - "print(data[1].keys())" + "fobs_gw_edges = data[1]['fobs_edges']\n", + "NFREQS, NREALS, NLOUDEST = [*data[0]['hc_ss'].shape]\n", + "print(f\"{NFREQS=}, {NREALS=}, {NLOUDEST=}\")" ] }, { @@ -109,7 +129,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(sspar1.shape)" + "fobs_orb_cents = fobs_gw_cents/2\n", + "edges, dnum, redz_final, dets = sam1._dynamic_binary_number_at_fobs_consistent(hard1, fobs_orb_cents, details=True)" ] }, { @@ -118,22 +139,17 @@ "metadata": {}, "outputs": [], "source": [ - "def tau_from_dadt(dadt, sepa):\n", - " \"\"\" tau = dt/dlna = dt/(da/a) = a*(dt/da) = a/(da/dt)\"\"\"\n", - " tau = (sepa)/dadt\n", - " return tau\n", - "def tau_from_pars(sspar, bgpar, hard=holo.hardening.Hard_GW()):\n", - " \"\"\" pars contain [mtot, mrat, redz_init, redz_final, dcom_final, sepa_final, angs_final]\n", - " each for ss is in shape F,R,L and each for bg is in shape F,R\"\"\"\n", - " dadt_ss = hard.dadt(sspar[0], sspar[1], sspar[5])\n", - " dadt_bg = hard.dadt(bgpar[0], bgpar[1], bgpar[5])\n", - "\n", - " tau_ss = tau_from_dadt(dadt_ss, sspar[5])\n", - " tau_bg = tau_from_dadt(dadt_bg, bgpar[5])\n", - " return tau_ss, tau_bg \n", - "\n", - "tau_ss, tau_bg = tau_from_pars(sspar1, bgpar1, hard1)\n", - "\n" + "dadt = dets['dadt']\n", + "sepa = dets['sepa']\n", + "tau = dets['tau']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Timescales" ] }, { @@ -142,8 +158,10 @@ "metadata": {}, "outputs": [], "source": [ - "data2 = rv_hard_time[0][1]\n", - "print(data2.keys)" + "# def tau_from_dadt(dadt, sepa):\n", + "# \"\"\" tau = dt/dlna = dt/(da/a) = a*(dt/da) = a/(da/dt)\"\"\"\n", + "# tau = (sepa)/dadt\n", + "# return tau" ] }, { @@ -169,8 +187,33 @@ "metadata": {}, "outputs": [], "source": [ - "sepa_idx = np.where(sings.par_names=='sepa_final')[0]\n", - "print(sepa_idx)" + "print(f\"{sepa.shape=}, {tau.shape=}\")\n", + "print(holo.utils.stats(sepa))\n", + "print(holo.utils.stats(tau))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mm=-1\n", + "qq=-1\n", + "zz=-1\n", + "for mm in [5,50,80]:\n", + " for qq in [5,50, 80]:\n", + " for zz in [5,50,80]:\n", + " plt.plot(fobs_gw_cents, sepa[mm,qq,zz])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sepa.shape)" ] }, { @@ -179,9 +222,6 @@ "metadata": {}, "outputs": [], "source": [ - "data = rv_hard_time[0][1]\n", - "\n", - "\n", "xlabels = ['Binary Separation [pc]', 'GW Frequency [nHz]']\n", "ylabels = ['Hardening Time [Gyr]', 'GW Characteristic Strain']\n", "\n", @@ -193,19 +233,319 @@ "\n", "fig.tight_layout()\n", "\n", + "x1 = sepa/PC\n", + "y1 = dets['tau']/GYR\n", "\n", + "for mm in np.arange(0, 90, 10):\n", + " for qq in np.arange(0,80,10):\n", + " for zz in np.arange(0,100,10):\n", + " axs[0].plot(x1[mm,qq,zz], y1[mm,qq,zz], alpha=0.5)\n", + "# axs[0].set_xlim(10**3, 10**-3)\n", + "\n", + "\n", + "# x2_bg = fobs_gw_cents\n", "\n", "\n", - "x1_bg = bgpar[sepa_idx]\n", "\n" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Let's just copy Luke's notebook" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import tqdm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NSTEPS = 10\n", + "\n", + "mtot_range = [3e8*MSOL, 3e9*MSOL]\n", + "mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", + "mrat_range = [0.2, 1.0]\n", + "redz_range = [0, np.inf]\n", + "\n", + "space = pspace # from above\n", + "\n", + "# hard_time binary lifetimes \n", + "times_list = [params[0]['hard_time'], params[1]['hard_time'], params[2]['hard_time']]\n", + "# hard_gamma_inner power law indices\n", + "inner_list = [params[1]['hard_gamma_inner'], ]\n", + "# range of binary separations to plot\n", + "sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", + "\n", + "time_hcss = []\n", + "time_hcbg = []\n", + "time_taus = []\n", + "time_taus_high = []\n", + "\n", + "# Iterate over target lifetimes\n", + "for tt, time in tqdm.tqdm(enumerate(times_list)):\n", + " _hcss = []\n", + " _hcbg = []\n", + " _taus = []\n", + " _taus_high = []\n", + "\n", + " # iterate over outer power-law indices\n", + " for inner in tqdm.tqdm(inner_list):\n", + " # set custom parameters:\n", + " # using my parameters from above\n", + " params_step = params[1] # midpoints\n", + " params_step['hard_time'] = time\n", + " params_step['hard_gamma_inner'] = inner\n", + " sam, hard = pspace.model_for_params(params_step)\n", + "\n", + " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", + " _hcbg_step, _hcss_step, = sam.gwb(fobs_gw_edges, hard, \n", + " loudest = NLOUDEST, realize=NREALS)\n", + " _hcss.append(_hcss_step)\n", + " _hcbg.append(_hcbg_step)\n", + " \n", + " # _hcss.append(data[tt]['hc_ss'])\n", + " # _hcbg.append(data[tt]['hc_bg'])\n", + " \n", + " # calculate binary properties at target separations\n", + " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", + " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", + " \n", + " # select the bins with target binary parameters\n", + " # I could update this to select out my single source bins\n", + " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", + " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", + " sel = (\n", + " sel_mtot[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " sel_high = (\n", + " sel_himt[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " tau = _details['tau'][sel].T\n", + " tau_high = _details['tau'][sel_high].T\n", + " _taus.append(tau)\n", + " _taus_high.append(tau_high)\n", + "\n", + " time_hcss.append(_hcss)\n", + " time_hcbg.append(_hcbg)\n", + " time_taus.append(_taus)\n", + " time_taus_high.append(_taus_high)\n", + " " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot Results" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], + "source": [ + "fig, axs = plot.figax_single(height=7, nrows=2, hspace=0.35, bottom=0.1)\n", + "\n", + "xx = sepa/PC\n", + "YR_LABEL_PAD = -4\n", + "\n", + "# ------------------------ 1 ----------------------------\n", + "ax = axs[0]\n", + "ax.set(xlabel=plot.LABEL_SEPARATION_PC, ylabel=plot.LABEL_HARDENING_TIME, xscale='log', yscale='log')\n", + "ax.invert_xaxis()\n", + "\n", + "ax.axhline(times_list[1], color='k', alpha=0.65)\n", + "ax.axhline(times_list[0], color='k', ls='--', alpha=0.25)\n", + "\n", + "\n", + "gamma_labels = []\n", + "gamma_handles = []\n", + "time_labels = []\n", + "time_handles = []\n", + "colors = []\n", + "inner_idx = 1\n", + "for ii, tau in enumerate(time_taus[:,inner_idx]):\n", + " yy = tau / GYR\n", + " \n", + " hh = plot.draw_med_conf(ax, xx, yy, fracs=[0.5], filter=True)\n", + " colors.append(hh[0].get_color())\n", + " time_handles.append(hh[0])\n", + " time_labels.append(f\"${times_list[ii]:.1f}$\")\n", + " if ii == 0:\n", + " gamma_labels.append(f\"${inner_list[inner_idx]:+.1f}$\")\n", + " gamma_handles.append(hh)\n", + "\n", + "# time_idx = 0 \n", + "# for ii, tau in enumerate(inner_taus[time_idx]):\n", + "# yy = tau / GYR\n", + "# yy = [np.median(y[y>0.0]) for y in yy]\n", + "# hh, = ax.plot(xx, yy, color=colors[ii], ls='--', alpha=0.35) \n", + "# if ii == 0:\n", + "# time_handles.append(hh)\n", + "# time_labels.append(f\"${times_list[time_idx]:.1f}$\")\n", + "\n", + "# leg = ax.legend(gamma_handles, gamma_labels, loc='lower left', \n", + "# ncol=len(gamma_handles), title='$\\\\nu_\\mathrm{inner}$', title_fontsize=14)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Look at sspar range" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sspar[0].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspar = data[1]['sspar']\n", + "print(holo.utils.stats(sspar[0][...,-1]/MSOL))\n", + "print('min: %e, max:%e' % (np.min(sspar[0][...,-1]) / MSOL, np.max(sspar[0][...,-1])/ MSOL))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax()\n", + "ax.hist(sspar[0].flatten()/MSOL, color='b', alpha=0.5, label='5 loudest',\n", + " bins=100, log=True)\n", + "ax.hist(sspar[0][...,-1].flatten()/MSOL, color='r', alpha=0.5, label='1 loudest', \n", + " bins=100, log=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Varying gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NSTEPS = 10\n", + "\n", + "mtot_range = [3e8*MSOL, 3e9*MSOL]\n", + "mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", + "mrat_range = [0.2, 1.0]\n", + "redz_range = [0, np.inf]\n", + "\n", + "space = pspace # from above\n", + "\n", + "# hard_time binary lifetimes \n", + "times_list = [params[1]['hard_time'],]]\n", + "# hard_gamma_inner power law indices\n", + "inner_list = [params[0]['hard_gamma_inner'], params[1]['hard_gamma_inner'], params[2]['hard_gamma_inner']]\n", + "# range of binary separations to plot\n", + "sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", + "\n", + "inner_hcss = []\n", + "inner_hcbg = []\n", + "inner_taus = []\n", + "inner_taus_high = []\n", + "\n", + "# Iterate over target lifetimes\n", + "for time in tqdm.tqdm(times_list):\n", + " _hcss = []\n", + " _hcbg = []\n", + " _taus = []\n", + " _taus_high = []\n", + "\n", + " # iterate over outer power-law indices\n", + " for inner in tqdm.tqdm(inner_list):\n", + " # set custom parameters:\n", + " # using my parameters from above\n", + " params_step = params[1] # midpoints\n", + " params_step['hard_time'] = time\n", + " params_step['hard_gamma_inner'] = inner\n", + " sam, hard = pspace.model_for_params(params_step)\n", + "\n", + " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", + " _hcbg_step, _hcss_step, = sam.gwb(fobs_gw_edges, hard, \n", + " loudest = NLOUDEST, realize=NREALS)\n", + " _hcss.append(_hcss_step)\n", + " _hcbg.append(_hcbg_step)\n", + " \n", + " # calculate binary properties at target separations\n", + " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", + " hard, sepa, details=True)\n", + " \n", + " # select the bins with target binary parameters\n", + " # I could update this to select out my single source bins\n", + " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", + " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", + " sel = (\n", + " sel_mtot[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " sel_high = (\n", + " sel_himt[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " tau = _details['tau'][sel].T\n", + " tau_high = _details['tau'][sel_high].T\n", + " _taus.append(tau)\n", + " _taus_high.append(tau_high)\n", + "\n", + " inner_hcss.append(_hcss)\n", + " inner_hcbg.append(_hcbg)\n", + " inner_taus.append(_taus)\n", + " inner_taus_high.append(_taus_high)\n", + " " + ] } ], "metadata": { From c063dd7c860aac4ce5e32a91e40b0eeb76557dd2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 22:59:15 -0700 Subject: [PATCH 088/291] made plots of hardening time vs separation for varying hard time --- .../take8_anatomy_time_vs_sepa.ipynb | 220 +++++++++--------- 1 file changed, 112 insertions(+), 108 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index 40d4b18d..37ba0091 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -266,6 +266,25 @@ "import tqdm" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "times_list = [params[0]['hard_time'], params[1]['hard_time'], params[2]['hard_time']]\n", + "print(times_list)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(params))" + ] + }, { "cell_type": "code", "execution_count": null, @@ -282,9 +301,9 @@ "space = pspace # from above\n", "\n", "# hard_time binary lifetimes \n", - "times_list = [params[0]['hard_time'], params[1]['hard_time'], params[2]['hard_time']]\n", + "times_list = []\n", "# hard_gamma_inner power law indices\n", - "inner_list = [params[1]['hard_gamma_inner'], ]\n", + "# inner_list = [params[1]['hard_gamma_inner'], ]\n", "# range of binary separations to plot\n", "sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", "\n", @@ -294,62 +313,62 @@ "time_taus_high = []\n", "\n", "# Iterate over target lifetimes\n", - "for tt, time in tqdm.tqdm(enumerate(times_list)):\n", - " _hcss = []\n", - " _hcbg = []\n", - " _taus = []\n", - " _taus_high = []\n", - "\n", - " # iterate over outer power-law indices\n", - " for inner in tqdm.tqdm(inner_list):\n", - " # set custom parameters:\n", - " # using my parameters from above\n", - " params_step = params[1] # midpoints\n", - " params_step['hard_time'] = time\n", - " params_step['hard_gamma_inner'] = inner\n", - " sam, hard = pspace.model_for_params(params_step)\n", - "\n", - " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", - " _hcbg_step, _hcss_step, = sam.gwb(fobs_gw_edges, hard, \n", - " loudest = NLOUDEST, realize=NREALS)\n", - " _hcss.append(_hcss_step)\n", - " _hcbg.append(_hcbg_step)\n", + "for tt in tqdm.tqdm(range(len(params))):\n", + "\n", + " # set custom parameters:\n", + " # using my parameters from above\n", + " _params = params[tt] # midpoints\n", + " times_list.append(_params['hard_time'])\n", + " # params_step['hard_time'] = params[tt]['hard_time']\n", + " # params_step['hard_gamma_inner'] = params[tt]['hard_gamma_inner']\n", + " sam, hard = pspace.model_for_params(_params)\n", + "\n", + " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", + " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", + " loudest = NLOUDEST, realize=NREALS)\n", + " time_hcss.append(_hcss_step)\n", + " time_hcbg.append(_hcbg_step)\n", + "\n", + " # _hcss.append(data[tt]['hc_ss'])\n", + " # _hcbg.append(data[tt]['hc_bg'])\n", + "\n", + " # calculate binary properties at target separations\n", + " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", + " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", " \n", - " # _hcss.append(data[tt]['hc_ss'])\n", - " # _hcbg.append(data[tt]['hc_bg'])\n", - " \n", - " # calculate binary properties at target separations\n", - " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", - " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", - " \n", - " # select the bins with target binary parameters\n", - " # I could update this to select out my single source bins\n", - " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", - " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", - " sel = (\n", - " sel_mtot[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", - "\n", - " sel_high = (\n", - " sel_himt[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", - "\n", - " tau = _details['tau'][sel].T\n", - " tau_high = _details['tau'][sel_high].T\n", - " _taus.append(tau)\n", - " _taus_high.append(tau_high)\n", - "\n", - " time_hcss.append(_hcss)\n", - " time_hcbg.append(_hcbg)\n", - " time_taus.append(_taus)\n", - " time_taus_high.append(_taus_high)\n", - " " + " # select the bins with target binary parameters\n", + " # I could update this to select out my single source bins\n", + " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", + " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", + " sel = (\n", + " sel_mtot[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " sel_high = (\n", + " sel_himt[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " tau = _details['tau'][sel].T\n", + " tau_high = _details['tau'][sel_high].T\n", + " time_taus.append(tau)\n", + " time_taus_high.append(tau_high)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(time_taus))\n", + "print(times_list)\n", + "print(f\"{time_hcbg[0].shape=}, {time_hcss[0].shape=}\")" ] }, { @@ -370,6 +389,7 @@ "\n", "xx = sepa/PC\n", "YR_LABEL_PAD = -4\n", + "colors = ['tab:green', 'tab:blue', 'tab:orange']\n", "\n", "# ------------------------ 1 ----------------------------\n", "ax = axs[0]\n", @@ -384,18 +404,19 @@ "gamma_handles = []\n", "time_labels = []\n", "time_handles = []\n", - "colors = []\n", - "inner_idx = 1\n", - "for ii, tau in enumerate(time_taus[:,inner_idx]):\n", + "# colors = []\n", + "# inner_idx = 0\n", + "for ii, tau in enumerate(time_taus):\n", + " print(ii)\n", " yy = tau / GYR\n", " \n", - " hh = plot.draw_med_conf(ax, xx, yy, fracs=[0.5], filter=True)\n", - " colors.append(hh[0].get_color())\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=True, color=colors[ii])\n", + " # colors.append(hh[0].get_color())\n", " time_handles.append(hh[0])\n", " time_labels.append(f\"${times_list[ii]:.1f}$\")\n", - " if ii == 0:\n", - " gamma_labels.append(f\"${inner_list[inner_idx]:+.1f}$\")\n", - " gamma_handles.append(hh)\n", + "\n", + "gamma_labels.append(f\"${params[0]['hard_gamma_inner']:+.1f}$\")\n", + "gamma_handles.append(hh)\n", "\n", "# time_idx = 0 \n", "# for ii, tau in enumerate(inner_taus[time_idx]):\n", @@ -406,8 +427,32 @@ "# time_handles.append(hh)\n", "# time_labels.append(f\"${times_list[time_idx]:.1f}$\")\n", "\n", - "# leg = ax.legend(gamma_handles, gamma_labels, loc='lower left', \n", - "# ncol=len(gamma_handles), title='$\\\\nu_\\mathrm{inner}$', title_fontsize=14)" + "leg = ax.legend(time_handles, time_labels, loc='lower left', \n", + " ncol=len(time_handles), title='$\\\\tau_\\mathrm{hard}$', title_fontsize=14)\n", + "\n", + "# ----------------------------- Ax 1 --------------------------------\n", + "\n", + "ax = axs[1]\n", + "ax.set(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN, xscale='log', yscale='log')\n", + "\n", + "xx = fobs_gw_cents*1e9 # nHz\n", + "\n", + "gamma_labels = []\n", + "gamma_handles = []\n", + "time_labels = []\n", + "time_handles = []\n", + "# colors = []\n", + "\n", + "for ii, yy in enumerate(time_hcbg):\n", + " # yy = np.median(yy, axis=-1)\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=False, color=colors[ii])\n", + " # colors.append(hh[0].get_color())\n", + " ss = time_hcss[ii]\n", + " for rr in range(len(ss[0])):\n", + " ax.scatter(xx, ss[:,rr,0], color = colors[ii], alpha=0.5, s=5) # only include loudest of each realization\n", + " # plot.draw_ss_and_gwb(ax, xx, time_hcss[ii], time_hcbg[ii], nsamp=10,\n", + " # color=colors[ii],)\n", + "\n" ] }, { @@ -415,47 +460,6 @@ "metadata": {}, "source": [] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Look at sspar range" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sspar[0].shape)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sspar = data[1]['sspar']\n", - "print(holo.utils.stats(sspar[0][...,-1]/MSOL))\n", - "print('min: %e, max:%e' % (np.min(sspar[0][...,-1]) / MSOL, np.max(sspar[0][...,-1])/ MSOL))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, ax = plot.figax()\n", - "ax.hist(sspar[0].flatten()/MSOL, color='b', alpha=0.5, label='5 loudest',\n", - " bins=100, log=True)\n", - "ax.hist(sspar[0][...,-1].flatten()/MSOL, color='r', alpha=0.5, label='1 loudest', \n", - " bins=100, log=True)" - ] - }, { "attachments": {}, "cell_type": "markdown", From af14a627524c69e361d35a79ecdfaa8600d74e03 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 20 Jun 2023 23:23:16 -0700 Subject: [PATCH 089/291] added color option in draw_med_conf_color --- holodeck/plot.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/holodeck/plot.py b/holodeck/plot.py index f929c76d..6b62ee27 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -748,6 +748,48 @@ def draw_med_conf(ax, xx, vals, fracs=[0.50, 0.90], weights=None, plot={}, fill= return (hh, gg) +def draw_med_conf_color(ax, xx, vals, fracs=[0.50, 0.90], weights=None, plot={}, fill={}, filter=False, color=None): + plot.setdefault('alpha', 0.75) + fill.setdefault('alpha', 0.2) + percs = np.atleast_1d(fracs) + assert np.all((0.0 <= percs) & (percs <= 1.0)) + + # center the target percentages into pairs around 50%, e.g. 68 ==> [16,84] + inter_percs = [[0.5-pp/2, 0.5+pp/2] for pp in percs] + # Add the median value (50%) + inter_percs = [0.5, ] + np.concatenate(inter_percs).tolist() + # Get percentiles; they go along the last axis + if filter: + rv = [ + kale.utils.quantiles(vv[vv > 0.0], percs=inter_percs, weights=weights) + for vv in vals + ] + rv = np.asarray(rv) + else: + rv = kale.utils.quantiles(vals, percs=inter_percs, weights=weights, axis=-1) + + med, *conf = rv.T + + # plot median + if color is not None: + hh, = ax.plot(xx, med, color=color, **plot) + else: + hh, = ax.plot(xx, med, **plot) + + # Reshape confidence intervals to nice plotting shape + # 2*P, X ==> (P, 2, X) + conf = np.array(conf).reshape(len(percs), 2, xx.size) + + kw = dict(color=hh.get_color()) + kw.update(fill) + fill = kw + + # plot each confidence interval + for lo, hi in conf: + gg = ax.fill_between(xx, lo, hi, **fill) + + return (hh, gg) + def smooth_spectra(xx, gwb, smooth=(20, 4), interp=100): assert np.shape(xx) == (np.shape(gwb)[0],) From 7df31904c2e0d274a7d51a0e0d2827f148e9fffb Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 00:20:25 -0700 Subject: [PATCH 090/291] Calculated time evolution for hard_time, gamma_inner, and mmb_mamp. Made a function and reconstruct flag --- .../take8_anatomy_time_vs_sepa.ipynb | 688 +++++++++++++----- 1 file changed, 501 insertions(+), 187 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index 37ba0091..3eb4fd81 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -29,6 +29,15 @@ "import anatomy as anat" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "RECONSTRUCT_FLAG = False" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -257,13 +266,98 @@ "# Let's just copy Luke's notebook" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### function to construct evolution data" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "import tqdm" + "def construct_evolution(params, nsteps):\n", + " mtot_range = [3e8*MSOL, 3e9*MSOL]\n", + " mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", + " mrat_range = [0.2, 1.0]\n", + " redz_range = [0, np.inf]\n", + "\n", + " space = pspace # from above\n", + "\n", + " # Whatever param we're varying\n", + " target_param_list = []\n", + " # range of binary separations to plot\n", + " sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", + "\n", + " hcss = []\n", + " hcbg = []\n", + " taus = []\n", + " taus_high = []\n", + "\n", + " # Iterate over target lifetimes\n", + " for tt in tqdm.tqdm(range(len(params))):\n", + "\n", + " # using my parameters from above\n", + " _params = params[tt] # midpoints\n", + " target_param_list.append(_params[target_param])\n", + "\n", + " sam, hard = pspace.model_for_params(_params)\n", + "\n", + " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", + " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", + " loudest = NLOUDEST, realize=NREALS)\n", + " hcss.append(_hcss_step)\n", + " hcbg.append(_hcbg_step)\n", + "\n", + " # _hcss.append(data[tt]['hc_ss'])\n", + " # _hcbg.append(data[tt]['hc_bg'])\n", + "\n", + " # calculate binary properties at target separations\n", + " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", + " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", + " \n", + " # select the bins with target binary parameters\n", + " # I could update this to select out my single source bins\n", + " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_hirng[1])\n", + " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", + " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", + " sel = (\n", + " sel_mtot[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " sel_high = (\n", + " sel_himt[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " _tau = _details['tau'][sel].T\n", + " _tau_high = _details['tau'][sel_high].T\n", + " taus.append(_tau)\n", + " taus_high.append(_tau_high)\n", + "\n", + " # save results\n", + " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + " filename = fileloc+'evol_%s_%dsteps.npz' % (target_param, nsteps)\n", + " print(f\"{filename=}\")\n", + " np.savez(filename, taus=taus, taus_high=taus_high, target_param_list=target_param_list,\n", + " hcss=hcss, hcbg=hcbg, nsteps=nsteps, sepa=sepa,\n", + " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Varying Hard Time" ] }, { @@ -272,8 +366,13 @@ "metadata": {}, "outputs": [], "source": [ - "times_list = [params[0]['hard_time'], params[1]['hard_time'], params[2]['hard_time']]\n", - "print(times_list)" + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True) \n", + "print(npz.files)\n", + "# data = npz['data']\n", + "params = npz['params']\n", + "fobs_gw_cents = npz['data'][0]['fobs_cents']\n", + "npz.close()" ] }, { @@ -282,7 +381,82 @@ "metadata": {}, "outputs": [], "source": [ - "print(len(params))" + "if RECONSTRUCT_FLAG:\n", + " NSTEPS = 20\n", + "\n", + " mtot_range = [3e8*MSOL, 3e9*MSOL]\n", + " mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", + " mrat_range = [0.2, 1.0]\n", + " redz_range = [0, np.inf]\n", + "\n", + " space = pspace # from above\n", + "\n", + " # hard_time binary lifetimes \n", + " times_list = []\n", + " # hard_gamma_inner power law indices\n", + " # inner_list = [params[1]['hard_gamma_inner'], ]\n", + " # range of binary separations to plot\n", + " sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", + "\n", + " time_hcss = []\n", + " time_hcbg = []\n", + " time_taus = []\n", + " time_taus_high = []\n", + "\n", + " # Iterate over target lifetimes\n", + " for tt in tqdm.tqdm(range(len(params))):\n", + "\n", + " # set custom parameters:\n", + " # using my parameters from above\n", + " _params = params[tt] # midpoints\n", + " times_list.append(_params['hard_time'])\n", + " # params_step['hard_time'] = params[tt]['hard_time']\n", + " # params_step['hard_gamma_inner'] = params[tt]['hard_gamma_inner']\n", + " sam, hard = pspace.model_for_params(_params)\n", + "\n", + " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", + " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", + " loudest = NLOUDEST, realize=NREALS)\n", + " time_hcss.append(_hcss_step)\n", + " time_hcbg.append(_hcbg_step)\n", + "\n", + " # _hcss.append(data[tt]['hc_ss'])\n", + " # _hcbg.append(data[tt]['hc_bg'])\n", + "\n", + " # calculate binary properties at target separations\n", + " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", + " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", + " \n", + " # select the bins with target binary parameters\n", + " # I could update this to select out my single source bins\n", + " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_hirng[1])\n", + " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", + " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", + " sel = (\n", + " sel_mtot[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " sel_high = (\n", + " sel_himt[:, np.newaxis, np.newaxis] *\n", + " sel_mrat[np.newaxis, :, np.newaxis] * \n", + " sel_redz[np.newaxis, np.newaxis, :]\n", + " )\n", + "\n", + " tau = _details['tau'][sel].T\n", + " tau_high = _details['tau'][sel_high].T\n", + " time_taus.append(tau)\n", + " time_taus_high.append(tau_high)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## save results" ] }, { @@ -291,73 +465,20 @@ "metadata": {}, "outputs": [], "source": [ - "NSTEPS = 10\n", - "\n", - "mtot_range = [3e8*MSOL, 3e9*MSOL]\n", - "mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", - "mrat_range = [0.2, 1.0]\n", - "redz_range = [0, np.inf]\n", - "\n", - "space = pspace # from above\n", - "\n", - "# hard_time binary lifetimes \n", - "times_list = []\n", - "# hard_gamma_inner power law indices\n", - "# inner_list = [params[1]['hard_gamma_inner'], ]\n", - "# range of binary separations to plot\n", - "sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", - "\n", - "time_hcss = []\n", - "time_hcbg = []\n", - "time_taus = []\n", - "time_taus_high = []\n", - "\n", - "# Iterate over target lifetimes\n", - "for tt in tqdm.tqdm(range(len(params))):\n", - "\n", - " # set custom parameters:\n", - " # using my parameters from above\n", - " _params = params[tt] # midpoints\n", - " times_list.append(_params['hard_time'])\n", - " # params_step['hard_time'] = params[tt]['hard_time']\n", - " # params_step['hard_gamma_inner'] = params[tt]['hard_gamma_inner']\n", - " sam, hard = pspace.model_for_params(_params)\n", - "\n", - " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", - " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", - " loudest = NLOUDEST, realize=NREALS)\n", - " time_hcss.append(_hcss_step)\n", - " time_hcbg.append(_hcbg_step)\n", - "\n", - " # _hcss.append(data[tt]['hc_ss'])\n", - " # _hcbg.append(data[tt]['hc_bg'])\n", - "\n", - " # calculate binary properties at target separations\n", - " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", - " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", - " \n", - " # select the bins with target binary parameters\n", - " # I could update this to select out my single source bins\n", - " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", - " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", - " sel = (\n", - " sel_mtot[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", - "\n", - " sel_high = (\n", - " sel_himt[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", - "\n", - " tau = _details['tau'][sel].T\n", - " tau_high = _details['tau'][sel_high].T\n", - " time_taus.append(tau)\n", - " time_taus_high.append(tau_high)" + "if RECONSTRUCT_FLAG:\n", + " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + " filename = 'evol_hard_time_%dsteps.npz' % NSTEPS\n", + " np.savez(filename, taus=time_taus, taus_high=time_taus_high, target_param_list=times_list,\n", + " hcss=time_hcss, hcbg=time_hcbg, nsteps=NSTEPS, sepa=sepa,\n", + " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## load hard time results" ] }, { @@ -366,9 +487,23 @@ "metadata": {}, "outputs": [], "source": [ - "print(len(time_taus))\n", - "print(times_list)\n", - "print(f\"{time_hcbg[0].shape=}, {time_hcss[0].shape=}\")" + "target_param='hard_time'\n", + "NSTEPS = 20\n", + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", + "file = np.load(filename)\n", + "taus=file['taus']\n", + "taus_high=file['taus_high'] \n", + "target_param_list=file['target_param_list']\n", + "hcss=file['hcss']\n", + "hcbg=file['hcbg']\n", + "nsteps=file['nsteps']\n", + "sepa=file['sepa']\n", + "mtot_range=file['mtot_range'] \n", + "mtot_hirng=file['mtot_hirng']\n", + "mrat_range=file['mrat_range']\n", + "redz_range=file['redz_range']\n", + "file.close()" ] }, { @@ -376,7 +511,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Plot Results" + "## Plot Results" ] }, { @@ -385,73 +520,76 @@ "metadata": {}, "outputs": [], "source": [ - "fig, axs = plot.figax_single(height=7, nrows=2, hspace=0.35, bottom=0.1)\n", - "\n", - "xx = sepa/PC\n", - "YR_LABEL_PAD = -4\n", - "colors = ['tab:green', 'tab:blue', 'tab:orange']\n", - "\n", - "# ------------------------ 1 ----------------------------\n", - "ax = axs[0]\n", - "ax.set(xlabel=plot.LABEL_SEPARATION_PC, ylabel=plot.LABEL_HARDENING_TIME, xscale='log', yscale='log')\n", - "ax.invert_xaxis()\n", - "\n", - "ax.axhline(times_list[1], color='k', alpha=0.65)\n", - "ax.axhline(times_list[0], color='k', ls='--', alpha=0.25)\n", - "\n", - "\n", - "gamma_labels = []\n", - "gamma_handles = []\n", - "time_labels = []\n", - "time_handles = []\n", - "# colors = []\n", - "# inner_idx = 0\n", - "for ii, tau in enumerate(time_taus):\n", - " print(ii)\n", - " yy = tau / GYR\n", - " \n", - " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=True, color=colors[ii])\n", - " # colors.append(hh[0].get_color())\n", - " time_handles.append(hh[0])\n", - " time_labels.append(f\"${times_list[ii]:.1f}$\")\n", - "\n", - "gamma_labels.append(f\"${params[0]['hard_gamma_inner']:+.1f}$\")\n", - "gamma_handles.append(hh)\n", - "\n", - "# time_idx = 0 \n", - "# for ii, tau in enumerate(inner_taus[time_idx]):\n", - "# yy = tau / GYR\n", - "# yy = [np.median(y[y>0.0]) for y in yy]\n", - "# hh, = ax.plot(xx, yy, color=colors[ii], ls='--', alpha=0.35) \n", - "# if ii == 0:\n", - "# time_handles.append(hh)\n", - "# time_labels.append(f\"${times_list[time_idx]:.1f}$\")\n", - "\n", - "leg = ax.legend(time_handles, time_labels, loc='lower left', \n", - " ncol=len(time_handles), title='$\\\\tau_\\mathrm{hard}$', title_fontsize=14)\n", - "\n", - "# ----------------------------- Ax 1 --------------------------------\n", - "\n", - "ax = axs[1]\n", - "ax.set(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN, xscale='log', yscale='log')\n", - "\n", - "xx = fobs_gw_cents*1e9 # nHz\n", - "\n", - "gamma_labels = []\n", - "gamma_handles = []\n", - "time_labels = []\n", - "time_handles = []\n", - "# colors = []\n", - "\n", - "for ii, yy in enumerate(time_hcbg):\n", - " # yy = np.median(yy, axis=-1)\n", - " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=False, color=colors[ii])\n", - " # colors.append(hh[0].get_color())\n", - " ss = time_hcss[ii]\n", - " for rr in range(len(ss[0])):\n", - " ax.scatter(xx, ss[:,rr,0], color = colors[ii], alpha=0.5, s=5) # only include loudest of each realization\n", - " # plot.draw_ss_and_gwb(ax, xx, time_hcss[ii], time_hcbg[ii], nsamp=10,\n", - " # color=colors[ii],)\n", + "def plot_current():\n", + " fig, axs = plot.figax_double(height=7, nrows=2, ncols=2, hspace=0.35, bottom=0.1)\n", + "\n", + " xx = sepa/PC\n", + " YR_LABEL_PAD = -4\n", + " colors = ['tab:green', 'tab:blue', 'tab:orange']\n", + "\n", + " # ------------------------ Ax Row 0 ----------------------------\n", + " ax = axs[0,0]\n", + " ax1 = axs[0,1]\n", + "\n", + " ax.set_title(f'Mass Range: {mtot_range/MSOL}')\n", + " ax1.set_title(f\"Mass Range: {mtot_hirng/MSOL}\")\n", + " ax1.sharex(ax)\n", + " ax1.sharey(ax)\n", + "\n", + " for axis in [ax, ax1]:\n", + " axis.set(xlabel=plot.LABEL_SEPARATION_PC, ylabel=plot.LABEL_HARDENING_TIME, xscale='log', yscale='log')\n", + " axis.invert_xaxis()\n", + "\n", + " # axis.axhline(times_list[1], color='k', alpha=0.65)\n", + " # axis.axhline(times_list[0], color='k', ls='--', alpha=0.25)\n", + "\n", + "\n", + " labels = []\n", + " handles = []\n", + " for ii, tau in enumerate(taus):\n", + " print(ii)\n", + " yy = tau / GYR\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=True, color=colors[ii])\n", + " # colors.append(hh[0].get_color())\n", + " handles.append(hh[0])\n", + " labels.append(f\"${target_param_list[ii]:.1f}$\")\n", + "\n", + " y1 = taus_high[ii]/GYR \n", + " plot.draw_med_conf_color(ax1, xx, y1, fracs=[0.5], filter=True, color=colors[ii])\n", + "\n", + "\n", + "\n", + " leg = ax.legend(handles, labels, loc='lower left', \n", + " ncol=len(handles), title=target_param, title_fontsize=14)\n", + "\n", + " # ----------------------------- Ax Row 1 --------------------------------\n", + "\n", + " ax = axs[1,0]\n", + " ax1 = axs[1,1]\n", + "\n", + " ax1.sharex(ax)\n", + " ax1.sharey(ax)\n", + "\n", + " for axis in [ax, ax1]:\n", + " axis.set(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN, xscale='log', yscale='log')\n", + "\n", + " xx = fobs_gw_cents*1e9 # nHz\n", + "\n", + " labels=[]\n", + " handles=[]\n", + " # colors = []\n", + "\n", + " for ii, yy in enumerate(hcbg):\n", + " # yy = np.median(yy, axis=-1)\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=False, color=colors[ii])\n", + " # colors.append(hh[0].get_color())\n", + " ss = hcss[ii]\n", + " for rr in range(len(ss[0])):\n", + " ax.scatter(xx, ss[:,rr,0], color = colors[ii], alpha=0.5, s=5) # only single include loudest of each realization\n", + "\n", + " return fig\n", + "\n", + "fig = plot_current()\n", "\n" ] }, @@ -474,57 +612,172 @@ "metadata": {}, "outputs": [], "source": [ - "NSTEPS = 10\n", + "target_param = 'hard_gamma_inner'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + " % target_param,\n", + " allow_pickle=True) \n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "if RECONSTRUCT_FLAG:\n", + " NSTEPS = 20\n", + " construct_evolution(params, nsteps)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## save results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if RECONSTRUCT_FLAG:\n", + " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + " filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", + " print(f\"{filename=}\")\n", + " np.savez(filename, taus=taus, taus_high=taus_high, target_param_list=target_param_list,\n", + " hcss=hcss, hcbg=hcbg, nsteps=NSTEPS, sepa=sepa,\n", + " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## load gamma_inner results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target_param='hard_gamma_inner'\n", + "NSTEPS = 20\n", + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", + "file = np.load(filename)\n", + "taus=file['taus']\n", + "taus_high=file['taus_high'] \n", + "target_param_list=file['target_param_list']\n", + "hcss=file['hcss']\n", + "hcbg=file['hcbg']\n", + "nsteps=file['nsteps']\n", + "sepa=file['sepa']\n", + "mtot_range=file['mtot_range'] \n", + "mtot_hirng=file['mtot_hirng']\n", + "mrat_range=file['mrat_range']\n", + "redz_range=file['redz_range']\n", + "file.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_current()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Varying mmb_mamp_log10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target_param = 'mmb_mamp_log10'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + " % target_param,\n", + " allow_pickle=True) \n", + "params = npz['params']\n", + "npz.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if RECONSTRUCT_FLAG:\n", + " NSTEPS = 20\n", "\n", - "mtot_range = [3e8*MSOL, 3e9*MSOL]\n", - "mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", - "mrat_range = [0.2, 1.0]\n", - "redz_range = [0, np.inf]\n", + " mtot_range = [3e8*MSOL, 3e9*MSOL]\n", + " mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", + " mrat_range = [0.2, 1.0]\n", + " redz_range = [0, np.inf]\n", "\n", - "space = pspace # from above\n", + " space = pspace # from above\n", "\n", - "# hard_time binary lifetimes \n", - "times_list = [params[1]['hard_time'],]]\n", - "# hard_gamma_inner power law indices\n", - "inner_list = [params[0]['hard_gamma_inner'], params[1]['hard_gamma_inner'], params[2]['hard_gamma_inner']]\n", - "# range of binary separations to plot\n", - "sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", + " # Whatever param we're varying\n", + " target_param_list = []\n", + " # range of binary separations to plot\n", + " sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", "\n", - "inner_hcss = []\n", - "inner_hcbg = []\n", - "inner_taus = []\n", - "inner_taus_high = []\n", + " hcss = []\n", + " hcbg = []\n", + " taus = []\n", + " taus_high = []\n", "\n", - "# Iterate over target lifetimes\n", - "for time in tqdm.tqdm(times_list):\n", - " _hcss = []\n", - " _hcbg = []\n", - " _taus = []\n", - " _taus_high = []\n", + " # Iterate over target lifetimes\n", + " for tt in tqdm.tqdm(range(len(params))):\n", "\n", - " # iterate over outer power-law indices\n", - " for inner in tqdm.tqdm(inner_list):\n", - " # set custom parameters:\n", " # using my parameters from above\n", - " params_step = params[1] # midpoints\n", - " params_step['hard_time'] = time\n", - " params_step['hard_gamma_inner'] = inner\n", - " sam, hard = pspace.model_for_params(params_step)\n", + " _params = params[tt] # midpoints\n", + " target_param_list.append(_params[target_param])\n", + "\n", + " sam, hard = pspace.model_for_params(_params)\n", "\n", " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", - " _hcbg_step, _hcss_step, = sam.gwb(fobs_gw_edges, hard, \n", + " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", " loudest = NLOUDEST, realize=NREALS)\n", - " _hcss.append(_hcss_step)\n", - " _hcbg.append(_hcbg_step)\n", - " \n", + " hcss.append(_hcss_step)\n", + " hcbg.append(_hcbg_step)\n", + "\n", + " # _hcss.append(data[tt]['hc_ss'])\n", + " # _hcbg.append(data[tt]['hc_bg'])\n", + "\n", " # calculate binary properties at target separations\n", " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", - " hard, sepa, details=True)\n", + " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", " \n", " # select the bins with target binary parameters\n", " # I could update this to select out my single source bins\n", " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", + " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_hirng[1])\n", " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", " sel = (\n", @@ -539,17 +792,78 @@ " sel_redz[np.newaxis, np.newaxis, :]\n", " )\n", "\n", - " tau = _details['tau'][sel].T\n", - " tau_high = _details['tau'][sel_high].T\n", - " _taus.append(tau)\n", - " _taus_high.append(tau_high)\n", - "\n", - " inner_hcss.append(_hcss)\n", - " inner_hcbg.append(_hcbg)\n", - " inner_taus.append(_taus)\n", - " inner_taus_high.append(_taus_high)\n", - " " + " _tau = _details['tau'][sel].T\n", + " _tau_high = _details['tau'][sel_high].T\n", + " taus.append(_tau)\n", + " taus_high.append(_tau_high)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## save results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if RECONSTRUCT_FLAG:\n", + " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + " filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", + " print(f\"{filename=}\")\n", + " np.savez(filename, taus=taus, taus_high=taus_high, target_param_list=target_param_list,\n", + " hcss=hcss, hcbg=hcbg, nsteps=NSTEPS,\n", + " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_current()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vary mmb_scatter_dex" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target_param = 'mmb_scatter_dex'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + " % target_param,\n", + " allow_pickle=True) \n", + "params = npz['params']\n", + "npz.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From c3df3dd66cb2995444f65ae60ef7bde51688d939 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 00:44:50 -0700 Subject: [PATCH 091/291] Running constuct evolution on rest of parameters. --- .../take8_anatomy_time_vs_sepa.ipynb | 675 ++++++++---------- 1 file changed, 309 insertions(+), 366 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index 3eb4fd81..0dcec791 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -14,6 +14,7 @@ "import matplotlib.pyplot as plt\n", "import matplotlib.cm as cm\n", "import h5py\n", + "import tqdm\n", "\n", "\n", "from holodeck import plot, detstats\n", @@ -35,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "RECONSTRUCT_FLAG = False" + "RECONSTRUCT_FLAG = True" ] }, { @@ -55,14 +56,6 @@ "sam = holo.sams.Semi_Analytic_Model(shape=10)" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Nothing below this makes sense" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -81,11 +74,14 @@ "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", " allow_pickle=True) \n", "print(npz.files)\n", - "data = npz['data']\n", - "params = npz['params']\n", - "hard_name = npz['hard_name']\n", + "hc_ss = npz['data'][0]['hc_ss']\n", + "NFREQS, NREALS, NLOUDEST = [*hc_ss.shape]\n", + "# params = npz['params']\n", + "# hard_name = npz['hard_name']\n", "shape = npz['shape']\n", - "target_param = npz['target_param']\n", + "# target_param = npz['target_param']\n", + "fobs_gw_cents = npz['data'][0]['fobs_cents']\n", + "fobs_gw_edges = npz['data'][0]['fobs_edges']\n", "\n", "npz.close()\n", "\n", @@ -94,85 +90,15 @@ "param_names = pspace.param_names\n", "print(param_names)\n", "print(f\"{shape=}\")\n", - "print(f\"{data[0]['hc_ss'].shape}\")\n", - "print(f\"{data[0].keys()=}\")\n", + "print(f\"{NFREQS=}, {NREALS=}, {NLOUDEST=},\")\n", + "# print(f\"{data[0]['hc_ss'].shape}\")\n", + "# print(f\"{data[0].keys()=}\")\n", "\n", "# # set directory path\n", "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", "# save_dir=sam_loc+'/figures' " ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(data[0]['gwb_params'][0].shape)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Make Model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sam1, hard1 = pspace.model_for_params(params[1])\n", - "fobs_gw_cents = data[1]['fobs_cents']\n", - "fobs_gw_edges = data[1]['fobs_edges']\n", - "NFREQS, NREALS, NLOUDEST = [*data[0]['hc_ss'].shape]\n", - "print(f\"{NFREQS=}, {NREALS=}, {NLOUDEST=}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fobs_orb_cents = fobs_gw_cents/2\n", - "edges, dnum, redz_final, dets = sam1._dynamic_binary_number_at_fobs_consistent(hard1, fobs_orb_cents, details=True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "dadt = dets['dadt']\n", - "sepa = dets['sepa']\n", - "tau = dets['tau']" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Timescales" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# def tau_from_dadt(dadt, sepa):\n", - "# \"\"\" tau = dt/dlna = dt/(da/a) = a*(dt/da) = a/(da/dt)\"\"\"\n", - "# tau = (sepa)/dadt\n", - "# return tau" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -187,7 +113,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(sings.par_names)" + "# print(sings.par_names)" ] }, { @@ -196,9 +122,9 @@ "metadata": {}, "outputs": [], "source": [ - "print(f\"{sepa.shape=}, {tau.shape=}\")\n", - "print(holo.utils.stats(sepa))\n", - "print(holo.utils.stats(tau))" + "# print(f\"{sepa.shape=}, {tau.shape=}\")\n", + "# print(holo.utils.stats(sepa))\n", + "# print(holo.utils.stats(tau))" ] }, { @@ -207,13 +133,13 @@ "metadata": {}, "outputs": [], "source": [ - "mm=-1\n", - "qq=-1\n", - "zz=-1\n", - "for mm in [5,50,80]:\n", - " for qq in [5,50, 80]:\n", - " for zz in [5,50,80]:\n", - " plt.plot(fobs_gw_cents, sepa[mm,qq,zz])" + "# mm=-1\n", + "# qq=-1\n", + "# zz=-1\n", + "# for mm in [5,50,80]:\n", + "# for qq in [5,50, 80]:\n", + "# for zz in [5,50,80]:\n", + "# plt.plot(fobs_gw_cents, sepa[mm,qq,zz])" ] }, { @@ -222,7 +148,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(sepa.shape)" + "# print(sepa.shape)" ] }, { @@ -231,28 +157,28 @@ "metadata": {}, "outputs": [], "source": [ - "xlabels = ['Binary Separation [pc]', 'GW Frequency [nHz]']\n", - "ylabels = ['Hardening Time [Gyr]', 'GW Characteristic Strain']\n", + "# xlabels = ['Binary Separation [pc]', 'GW Frequency [nHz]']\n", + "# ylabels = ['Hardening Time [Gyr]', 'GW Characteristic Strain']\n", "\n", - "fig, axs = plot.figax(nrows=2, figsize=(5,6)\n", - " )\n", - "for ii,ax in enumerate(axs):\n", - " ax.set_xlabel(xlabels[ii])\n", - " ax.set_ylabel(ylabels[ii])\n", + "# fig, axs = plot.figax(nrows=2, figsize=(5,6)\n", + "# )\n", + "# for ii,ax in enumerate(axs):\n", + "# ax.set_xlabel(xlabels[ii])\n", + "# ax.set_ylabel(ylabels[ii])\n", "\n", - "fig.tight_layout()\n", + "# fig.tight_layout()\n", "\n", - "x1 = sepa/PC\n", - "y1 = dets['tau']/GYR\n", + "# x1 = sepa/PC\n", + "# y1 = dets['tau']/GYR\n", "\n", - "for mm in np.arange(0, 90, 10):\n", - " for qq in np.arange(0,80,10):\n", - " for zz in np.arange(0,100,10):\n", - " axs[0].plot(x1[mm,qq,zz], y1[mm,qq,zz], alpha=0.5)\n", - "# axs[0].set_xlim(10**3, 10**-3)\n", + "# for mm in np.arange(0, 90, 10):\n", + "# for qq in np.arange(0,80,10):\n", + "# for zz in np.arange(0,100,10):\n", + "# axs[0].plot(x1[mm,qq,zz], y1[mm,qq,zz], alpha=0.5)\n", + "# # axs[0].set_xlim(10**3, 10**-3)\n", "\n", "\n", - "# x2_bg = fobs_gw_cents\n", + "# # x2_bg = fobs_gw_cents\n", "\n", "\n", "\n" @@ -280,7 +206,7 @@ "metadata": {}, "outputs": [], "source": [ - "def construct_evolution(params, nsteps):\n", + "def construct_evolution(target_param, params, NSTEPS):\n", " mtot_range = [3e8*MSOL, 3e9*MSOL]\n", " mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", " mrat_range = [0.2, 1.0]\n", @@ -345,10 +271,10 @@ "\n", " # save results\n", " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - " filename = fileloc+'evol_%s_%dsteps.npz' % (target_param, nsteps)\n", + " filename = fileloc+'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", " print(f\"{filename=}\")\n", " np.savez(filename, taus=taus, taus_high=taus_high, target_param_list=target_param_list,\n", - " hcss=hcss, hcbg=hcbg, nsteps=nsteps, sepa=sepa,\n", + " hcss=hcss, hcbg=hcbg, nsteps=NSTEPS, sepa=sepa,\n", " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" ] }, @@ -357,22 +283,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Varying Hard Time" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", - " allow_pickle=True) \n", - "print(npz.files)\n", - "# data = npz['data']\n", - "params = npz['params']\n", - "fobs_gw_cents = npz['data'][0]['fobs_cents']\n", - "npz.close()" + "# Plot current function" ] }, { @@ -381,74 +292,74 @@ "metadata": {}, "outputs": [], "source": [ - "if RECONSTRUCT_FLAG:\n", - " NSTEPS = 20\n", + "def plot_current():\n", + " fig, axs = plot.figax_double(height=7, nrows=2, ncols=2, hspace=0.35, bottom=0.1)\n", "\n", - " mtot_range = [3e8*MSOL, 3e9*MSOL]\n", - " mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", - " mrat_range = [0.2, 1.0]\n", - " redz_range = [0, np.inf]\n", + " xx = sepa/PC\n", + " YR_LABEL_PAD = -4\n", + " colors = ['tab:green', 'tab:blue', 'tab:orange']\n", "\n", - " space = pspace # from above\n", + " # ------------------------ Ax Row 0 ----------------------------\n", + " ax = axs[0,0]\n", + " ax1 = axs[0,1]\n", "\n", - " # hard_time binary lifetimes \n", - " times_list = []\n", - " # hard_gamma_inner power law indices\n", - " # inner_list = [params[1]['hard_gamma_inner'], ]\n", - " # range of binary separations to plot\n", - " sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", + " ax.set_title(f'Mass Range: {mtot_range/MSOL}')\n", + " ax1.set_title(f\"Mass Range: {mtot_hirng/MSOL}\")\n", + " ax1.sharex(ax)\n", + " ax1.sharey(ax)\n", "\n", - " time_hcss = []\n", - " time_hcbg = []\n", - " time_taus = []\n", - " time_taus_high = []\n", + " for axis in [ax, ax1]:\n", + " axis.set(xlabel=plot.LABEL_SEPARATION_PC, ylabel=plot.LABEL_HARDENING_TIME, xscale='log', yscale='log')\n", + " axis.invert_xaxis()\n", "\n", - " # Iterate over target lifetimes\n", - " for tt in tqdm.tqdm(range(len(params))):\n", + " # axis.axhline(times_list[1], color='k', alpha=0.65)\n", + " # axis.axhline(times_list[0], color='k', ls='--', alpha=0.25)\n", "\n", - " # set custom parameters:\n", - " # using my parameters from above\n", - " _params = params[tt] # midpoints\n", - " times_list.append(_params['hard_time'])\n", - " # params_step['hard_time'] = params[tt]['hard_time']\n", - " # params_step['hard_gamma_inner'] = params[tt]['hard_gamma_inner']\n", - " sam, hard = pspace.model_for_params(_params)\n", "\n", - " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", - " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", - " loudest = NLOUDEST, realize=NREALS)\n", - " time_hcss.append(_hcss_step)\n", - " time_hcbg.append(_hcbg_step)\n", + " labels = []\n", + " handles = []\n", + " for ii, tau in enumerate(taus):\n", + " print(ii)\n", + " yy = tau / GYR\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=True, color=colors[ii])\n", + " # colors.append(hh[0].get_color())\n", + " handles.append(hh[0])\n", + " labels.append(f\"${target_param_list[ii]:.1f}$\")\n", "\n", - " # _hcss.append(data[tt]['hc_ss'])\n", - " # _hcbg.append(data[tt]['hc_bg'])\n", + " y1 = taus_high[ii]/GYR \n", + " plot.draw_med_conf_color(ax1, xx, y1, fracs=[0.5], filter=True, color=colors[ii])\n", "\n", - " # calculate binary properties at target separations\n", - " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", - " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", - " \n", - " # select the bins with target binary parameters\n", - " # I could update this to select out my single source bins\n", - " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_hirng[1])\n", - " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", - " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", - " sel = (\n", - " sel_mtot[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", "\n", - " sel_high = (\n", - " sel_himt[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", "\n", - " tau = _details['tau'][sel].T\n", - " tau_high = _details['tau'][sel_high].T\n", - " time_taus.append(tau)\n", - " time_taus_high.append(tau_high)" + " leg = ax.legend(handles, labels, loc='lower left', \n", + " ncol=len(handles), title=target_param, title_fontsize=14)\n", + "\n", + " # ----------------------------- Ax Row 1 --------------------------------\n", + "\n", + " ax = axs[1,0]\n", + " ax1 = axs[1,1]\n", + "\n", + " ax1.sharex(ax)\n", + " ax1.sharey(ax)\n", + "\n", + " for axis in [ax, ax1]:\n", + " axis.set(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN, xscale='log', yscale='log')\n", + "\n", + " xx = fobs_gw_cents*1e9 # nHz\n", + "\n", + " labels=[]\n", + " handles=[]\n", + " # colors = []\n", + "\n", + " for ii, yy in enumerate(hcbg):\n", + " # yy = np.median(yy, axis=-1)\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=False, color=colors[ii])\n", + " # colors.append(hh[0].get_color())\n", + " ss = hcss[ii]\n", + " for rr in range(len(ss[0])):\n", + " ax.scatter(xx, ss[:,rr,0], color = colors[ii], alpha=0.5, s=5) # only single include loudest of each realization\n", + "\n", + " return fig" ] }, { @@ -456,7 +367,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## save results" + "# hard_time" ] }, { @@ -465,12 +376,15 @@ "metadata": {}, "outputs": [], "source": [ + "target_param='hard_time'\n", + "nsteps=20\n", + "\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + " % target_param, allow_pickle=True) \n", + "params = npz['params']\n", + "npz.close()\n", "if RECONSTRUCT_FLAG:\n", - " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - " filename = 'evol_hard_time_%dsteps.npz' % NSTEPS\n", - " np.savez(filename, taus=time_taus, taus_high=time_taus_high, target_param_list=times_list,\n", - " hcss=time_hcss, hcbg=time_hcbg, nsteps=NSTEPS, sepa=sepa,\n", - " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + " construct_evolution(target_param=target_param, params=params, NSTEPS=nsteps)" ] }, { @@ -488,9 +402,8 @@ "outputs": [], "source": [ "target_param='hard_time'\n", - "NSTEPS = 20\n", - "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - "filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape'\n", + "filename = fileloc+'/evol_%s_%dsteps.npz' % (target_param, nsteps)\n", "file = np.load(filename)\n", "taus=file['taus']\n", "taus_high=file['taus_high'] \n", @@ -520,77 +433,7 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_current():\n", - " fig, axs = plot.figax_double(height=7, nrows=2, ncols=2, hspace=0.35, bottom=0.1)\n", - "\n", - " xx = sepa/PC\n", - " YR_LABEL_PAD = -4\n", - " colors = ['tab:green', 'tab:blue', 'tab:orange']\n", - "\n", - " # ------------------------ Ax Row 0 ----------------------------\n", - " ax = axs[0,0]\n", - " ax1 = axs[0,1]\n", - "\n", - " ax.set_title(f'Mass Range: {mtot_range/MSOL}')\n", - " ax1.set_title(f\"Mass Range: {mtot_hirng/MSOL}\")\n", - " ax1.sharex(ax)\n", - " ax1.sharey(ax)\n", - "\n", - " for axis in [ax, ax1]:\n", - " axis.set(xlabel=plot.LABEL_SEPARATION_PC, ylabel=plot.LABEL_HARDENING_TIME, xscale='log', yscale='log')\n", - " axis.invert_xaxis()\n", - "\n", - " # axis.axhline(times_list[1], color='k', alpha=0.65)\n", - " # axis.axhline(times_list[0], color='k', ls='--', alpha=0.25)\n", - "\n", - "\n", - " labels = []\n", - " handles = []\n", - " for ii, tau in enumerate(taus):\n", - " print(ii)\n", - " yy = tau / GYR\n", - " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=True, color=colors[ii])\n", - " # colors.append(hh[0].get_color())\n", - " handles.append(hh[0])\n", - " labels.append(f\"${target_param_list[ii]:.1f}$\")\n", - "\n", - " y1 = taus_high[ii]/GYR \n", - " plot.draw_med_conf_color(ax1, xx, y1, fracs=[0.5], filter=True, color=colors[ii])\n", - "\n", - "\n", - "\n", - " leg = ax.legend(handles, labels, loc='lower left', \n", - " ncol=len(handles), title=target_param, title_fontsize=14)\n", - "\n", - " # ----------------------------- Ax Row 1 --------------------------------\n", - "\n", - " ax = axs[1,0]\n", - " ax1 = axs[1,1]\n", - "\n", - " ax1.sharex(ax)\n", - " ax1.sharey(ax)\n", - "\n", - " for axis in [ax, ax1]:\n", - " axis.set(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN, xscale='log', yscale='log')\n", - "\n", - " xx = fobs_gw_cents*1e9 # nHz\n", - "\n", - " labels=[]\n", - " handles=[]\n", - " # colors = []\n", - "\n", - " for ii, yy in enumerate(hcbg):\n", - " # yy = np.median(yy, axis=-1)\n", - " hh = plot.draw_med_conf_color(ax, xx, yy, fracs=[0.5], filter=False, color=colors[ii])\n", - " # colors.append(hh[0].get_color())\n", - " ss = hcss[ii]\n", - " for rr in range(len(ss[0])):\n", - " ax.scatter(xx, ss[:,rr,0], color = colors[ii], alpha=0.5, s=5) # only single include loudest of each realization\n", - "\n", - " return fig\n", - "\n", - "fig = plot_current()\n", - "\n" + "fig = plot_current()" ] }, { @@ -603,7 +446,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Varying gamma_inner" + "# gamma_inner" ] }, { @@ -613,15 +456,24 @@ "outputs": [], "source": [ "target_param = 'hard_gamma_inner'\n", + "nsteps = 20\n", "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", " % target_param,\n", " allow_pickle=True) \n", "params = npz['params']\n", "npz.close()\n", "\n", - "if RECONSTRUCT_FLAG:\n", + "if False: #RECONSTRUCT_FLAG:\n", " NSTEPS = 20\n", - " construct_evolution(params, nsteps)" + " construct_evolution(target_param, params, nsteps)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## load gamma_inner results" ] }, { @@ -629,14 +481,47 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "filename = fileloc+'evol_%s_%dsteps.npz' % (target_param, nsteps)\n", + "file = np.load(filename)\n", + "taus=file['taus']\n", + "taus_high=file['taus_high'] \n", + "target_param_list=file['target_param_list']\n", + "hcss=file['hcss']\n", + "hcbg=file['hcbg']\n", + "nsteps=file['nsteps']\n", + "sepa=file['sepa']\n", + "mtot_range=file['mtot_range'] \n", + "mtot_hirng=file['mtot_hirng']\n", + "mrat_range=file['mrat_range']\n", + "redz_range=file['redz_range']\n", + "file.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_current()" + ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "## save results" + "# mmb_mamp_log10" ] }, { @@ -645,13 +530,15 @@ "metadata": {}, "outputs": [], "source": [ + "target_param = 'mmb_mamp_log10'\n", + "nsteps = 20\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + " % target_param,\n", + " allow_pickle=True) \n", + "params = npz['params']\n", + "npz.close()\n", "if RECONSTRUCT_FLAG:\n", - " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - " filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", - " print(f\"{filename=}\")\n", - " np.savez(filename, taus=taus, taus_high=taus_high, target_param_list=target_param_list,\n", - " hcss=hcss, hcbg=hcbg, nsteps=NSTEPS, sepa=sepa,\n", - " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + " construct_evolution(target_param=target_param, params=params, NSTEPS=nsteps)" ] }, { @@ -659,7 +546,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## load gamma_inner results" + "## load mmb_mamp_log10 results" ] }, { @@ -668,10 +555,8 @@ "metadata": {}, "outputs": [], "source": [ - "target_param='hard_gamma_inner'\n", - "NSTEPS = 20\n", - "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - "filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape'\n", + "filename = fileloc+'/evol_%s_%dsteps.npz' % (target_param, nsteps)\n", "file = np.load(filename)\n", "taus=file['taus']\n", "taus_high=file['taus_high'] \n", @@ -688,7 +573,6 @@ ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -709,7 +593,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Varying mmb_mamp_log10" + "# mmb_scatter_dex" ] }, { @@ -718,12 +602,22 @@ "metadata": {}, "outputs": [], "source": [ - "target_param = 'mmb_mamp_log10'\n", + "target_param = 'mmb_scatter_dex'\n", + "nsteps=20\n", "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", - " % target_param,\n", - " allow_pickle=True) \n", + " % target_param, allow_pickle=True) \n", "params = npz['params']\n", - "npz.close()" + "npz.close()\n", + "if RECONSTRUCT_FLAG:\n", + " construct_evolution(target_param, params, nsteps)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## load mmb_scatter_dex results" ] }, { @@ -732,77 +626,46 @@ "metadata": {}, "outputs": [], "source": [ - "if RECONSTRUCT_FLAG:\n", - " NSTEPS = 20\n", - "\n", - " mtot_range = [3e8*MSOL, 3e9*MSOL]\n", - " mtot_hirng = [3e9*MSOL, 3e10*MSOL]\n", - " mrat_range = [0.2, 1.0]\n", - " redz_range = [0, np.inf]\n", - "\n", - " space = pspace # from above\n", - "\n", - " # Whatever param we're varying\n", - " target_param_list = []\n", - " # range of binary separations to plot\n", - " sepa = np.logspace(-3, 3, NSTEPS)[::-1] * PC\n", - "\n", - " hcss = []\n", - " hcbg = []\n", - " taus = []\n", - " taus_high = []\n", - "\n", - " # Iterate over target lifetimes\n", - " for tt in tqdm.tqdm(range(len(params))):\n", - "\n", - " # using my parameters from above\n", - " _params = params[tt] # midpoints\n", - " target_param_list.append(_params[target_param])\n", - "\n", - " sam, hard = pspace.model_for_params(_params)\n", - "\n", - " # calculate hc_bg and hc_ss at bin centers, between the given bin edges\n", - " _hcss_step, _hcbg_step, = sam.gwb(fobs_gw_edges, hard, \n", - " loudest = NLOUDEST, realize=NREALS)\n", - " hcss.append(_hcss_step)\n", - " hcbg.append(_hcbg_step)\n", - "\n", - " # _hcss.append(data[tt]['hc_ss'])\n", - " # _hcbg.append(data[tt]['hc_bg'])\n", - "\n", - " # calculate binary properties at target separations\n", - " _edges, _dnum, _redz_final, _details = sam._dynamic_binary_number_at_sepa_consistent(\n", - " hard, sepa, details=True) # it would be better if I saved these details when I first calculated them!\n", - " \n", - " # select the bins with target binary parameters\n", - " # I could update this to select out my single source bins\n", - " sel_mtot = (mtot_range[0] < sam.mtot) & (sam.mtot <= mtot_range[1])\n", - " sel_himt = (mtot_hirng[0] < sam.mtot) & (sam.mtot <= mtot_hirng[1])\n", - " sel_mrat = (mrat_range[0] < sam.mrat) & (sam.mrat <= mrat_range[1])\n", - " sel_redz = (redz_range[0] < sam.redz) & (sam.redz <= redz_range[1])\n", - " sel = (\n", - " sel_mtot[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", - "\n", - " sel_high = (\n", - " sel_himt[:, np.newaxis, np.newaxis] *\n", - " sel_mrat[np.newaxis, :, np.newaxis] * \n", - " sel_redz[np.newaxis, np.newaxis, :]\n", - " )\n", - "\n", - " _tau = _details['tau'][sel].T\n", - " _tau_high = _details['tau'][sel_high].T\n", - " taus.append(_tau)\n", - " taus_high.append(_tau_high)" + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape'\n", + "filename = fileloc+'/evol_%s_%dsteps.npz' % (target_param, nsteps)\n", + "file = np.load(filename)\n", + "taus=file['taus']\n", + "taus_high=file['taus_high'] \n", + "target_param_list=file['target_param_list']\n", + "hcss=file['hcss']\n", + "hcbg=file['hcbg']\n", + "nsteps=file['nsteps']\n", + "sepa=file['sepa']\n", + "mtot_range=file['mtot_range'] \n", + "mtot_hirng=file['mtot_hirng']\n", + "mrat_range=file['mrat_range']\n", + "redz_range=file['redz_range']\n", + "file.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_current()" ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "## save results" + "# gsmf_phi0" ] }, { @@ -811,13 +674,46 @@ "metadata": {}, "outputs": [], "source": [ + "target_param = 'gsmf_phi0'\n", + "nsteps = 20\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", + " % target_param,\n", + " allow_pickle=True) \n", + "params = npz['params']\n", + "npz.close()\n", "if RECONSTRUCT_FLAG:\n", - " fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - " filename = 'evol_%s_%dsteps.npz' % (target_param, NSTEPS)\n", - " print(f\"{filename=}\")\n", - " np.savez(filename, taus=taus, taus_high=taus_high, target_param_list=target_param_list,\n", - " hcss=hcss, hcbg=hcbg, nsteps=NSTEPS,\n", - " mtot_range=mtot_range, mtot_hirng=mtot_hirng, mrat_range=mrat_range, redz_range=redz_range)\n" + " construct_evolution(target_param=target_param, params=params, NSTEPS=nsteps)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## load gsmf_phi0 results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape'\n", + "filename = fileloc+'/evol_%s_%dsteps.npz' % (target_param, nsteps)\n", + "file = np.load(filename)\n", + "taus=file['taus']\n", + "taus_high=file['taus_high'] \n", + "target_param_list=file['target_param_list']\n", + "hcss=file['hcss']\n", + "hcbg=file['hcbg']\n", + "nsteps=file['nsteps']\n", + "sepa=file['sepa']\n", + "mtot_range=file['mtot_range'] \n", + "mtot_hirng=file['mtot_hirng']\n", + "mrat_range=file['mrat_range']\n", + "redz_range=file['redz_range']\n", + "file.close()" ] }, { @@ -841,7 +737,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Vary mmb_scatter_dex" + "# gsmf_mchar0_log10" ] }, { @@ -850,12 +746,22 @@ "metadata": {}, "outputs": [], "source": [ - "target_param = 'mmb_scatter_dex'\n", + "target_param = 'gsmf_'\n", + "nsteps = 20\n", "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", " % target_param,\n", " allow_pickle=True) \n", "params = npz['params']\n", - "npz.close()" + "npz.close()\n", + "if RECONSTRUCT_FLAG:\n", + " construct_evolution(target_param=target_param, params=params, NSTEPS=nsteps)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## load gsmf_phi0 results" ] }, { @@ -863,6 +769,43 @@ "execution_count": null, "metadata": {}, "outputs": [], + "source": [ + "fileloc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape'\n", + "filename = fileloc+'/evol_%s_%dsteps.npz' % (target_param, nsteps)\n", + "file = np.load(filename)\n", + "taus=file['taus']\n", + "taus_high=file['taus_high'] \n", + "target_param_list=file['target_param_list']\n", + "hcss=file['hcss']\n", + "hcbg=file['hcbg']\n", + "nsteps=file['nsteps']\n", + "sepa=file['sepa']\n", + "mtot_range=file['mtot_range'] \n", + "mtot_hirng=file['mtot_hirng']\n", + "mrat_range=file['mrat_range']\n", + "redz_range=file['redz_range']\n", + "file.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot_current()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, "source": [] } ], From df66a933b499a469fd13a97d8c6eba0d375f3535 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 10:42:08 -0700 Subject: [PATCH 092/291] Added bbox_inches setting to savefig for anatomy plots --- ecg-notebooks/parameter_investigation/anatomy.py | 4 ++-- .../take8_anatomy_time_vs_sepa.ipynb | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/anatomy.py b/ecg-notebooks/parameter_investigation/anatomy.py index 2304597c..063897ec 100644 --- a/ecg-notebooks/parameter_investigation/anatomy.py +++ b/ecg-notebooks/parameter_investigation/anatomy.py @@ -298,7 +298,7 @@ def plot_three_models( if save_dir is not None: str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2]) filename = save_dir+'/%s_allvsfreqs%s_%s.png' % (target_param, save_append, str_shape) - fig.savefig(filename, dpi=100) + fig.savefig(filename, dpi=100, bbox_inches='tight') return fig @@ -347,7 +347,7 @@ def plot_three_hs_vs_binpars(data, params, if save_dir is not None: str_shape = 's%d_%d_%d' % (shape[0], shape[1], shape[2]) filename = save_dir+'/%s_hsvsbinpars%s_%s.png' % (target_param, save_append, str_shape) - fig.savefig(filename, dpi=100) + fig.savefig(filename, dpi=100, bbox_inches='tight') return fig diff --git a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb index 0dcec791..5e129d20 100644 --- a/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb +++ b/ecg-notebooks/parameter_investigation/take8_anatomy_time_vs_sepa.ipynb @@ -36,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "RECONSTRUCT_FLAG = True" + "RECONSTRUCT_FLAG = False" ] }, { @@ -310,7 +310,7 @@ "\n", " for axis in [ax, ax1]:\n", " axis.set(xlabel=plot.LABEL_SEPARATION_PC, ylabel=plot.LABEL_HARDENING_TIME, xscale='log', yscale='log')\n", - " axis.invert_xaxis()\n", + " axis.invert_xaxis()\n", "\n", " # axis.axhline(times_list[1], color='k', alpha=0.65)\n", " # axis.axhline(times_list[0], color='k', ls='--', alpha=0.25)\n", @@ -746,11 +746,10 @@ "metadata": {}, "outputs": [], "source": [ - "target_param = 'gsmf_'\n", + "target_param = 'gsmf_mchar0_log10'\n", "nsteps = 20\n", "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz'\n", - " % target_param,\n", - " allow_pickle=True) \n", + " % target_param, allow_pickle=True) \n", "params = npz['params']\n", "npz.close()\n", "if RECONSTRUCT_FLAG:\n", From 4402788e121b5844f16a2a50e74b0c3fa9a808b6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 13:18:11 -0700 Subject: [PATCH 093/291] Made color map for masses, bg freqs, found bug in allowing single source distances to be negative. --- .../take9_numberdensity_mass_dist.ipynb | 334 ++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb diff --git a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb new file mode 100644 index 00000000..72679f10 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb @@ -0,0 +1,334 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# use one file to get the shape\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True) \n", + "print(f\"{npz.files=}\")\n", + "data = npz['data']\n", + "print(f\"{data[0].keys()=}\")\n", + "\n", + "# params = npz['params']\n", + "# hard_name = npz['hard_name']\n", + "shape = npz['shape']\n", + "print(f\"{shape=}\")\n", + "# target_param = npz['target_param']\n", + "fobs_gw_cents = npz['data'][0]['fobs_cents']\n", + "fobs_gw_edges = npz['data'][0]['fobs_edges']\n", + "\n", + "npz.close()\n", + "\n", + "# get param names\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=shape, seed=None)\n", + "param_names = pspace.param_names\n", + "print(f\"{param_names=}\")\n", + "\n", + "\n", + "hc_ss = data[1]['hc_ss']\n", + "hc_bg = data[1]['hc_bg']\n", + "bgpar = data[1]['bgpar']\n", + "sspar = data[1]['sspar']\n", + "sspar = sings.all_sspars(fobs_gw_cents=fobs_gw_cents, sspar=sspar)\n", + "print(f\"{sings.par_names=}\")\n", + "nfreqs, nreals, nloudest = [*hc_ss.shape]\n", + "print(f\"{nfreqs=}, {nreals=}, {nloudest=},\")\n", + "\n", + "# # set directory path\n", + "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "# save_dir=sam_loc+'/figures' " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Dev" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax(ncols=2, xlabel=['mtot', 'final dcom'], figsize=(8,3),\n", + " )\n", + "\n", + "idx = [0, 4]\n", + "\n", + "hist, bins, = np.histogram(sspar[idx[0]].flatten()/MSOL, )\n", + "plot.draw_hist_steps(axs[0], bins, hist)\n", + "\n", + "hist, bins, = np.histogram(sspar[idx[1]].flatten(), )\n", + "plot.draw_hist_steps(axs[1], bins, hist)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sings.par_units)\n", + "print(sings.par_labels)\n", + "print(1/MPC)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mtot = bgpar[0].flatten()/MSOL\n", + "dcom = bgpar[np.where(sings.par_names=='dcom_final')].flatten()/MPC\n", + "\n", + "nbins=30\n", + "mt_edges = np.logspace(np.log10(np.nanmin(mtot)), np.log10(np.nanmax(mtot)), nbins)\n", + "print(np.min(mtot), np.max(mtot))\n", + "print(mt_edges)\n", + "dc_edges = np.logspace(np.log10(np.min(dcom)), np.log10(np.max(dcom)), nbins)\n", + "hist, mtbins, dcbins = np.histogram2d(mtot, dcom, bins=(mt_edges, dc_edges))\n", + "\n", + "MT, DC = np.meshgrid(mtbins, dcbins)\n", + "\n", + "fig, ax = plot.figax(xlabel=sings.par_labels[0],\n", + " ylabel=sings.par_labels[4])\n", + "ax.pcolormesh(MT, DC, hist)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plotting function" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print([8,]+[*sspar.shape[1:]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def append_pars(data=data[1]):\n", + " hc_ss=data['hc_ss']\n", + " hc_bg=data['hc_bg']\n", + "\n", + " sspar = data['sspar']\n", + " sspar = sings.all_sspars(fobs_gw_cents, sspar)\n", + " bgpar = data['bgpar']\n", + "\n", + "\n", + " # Add frequency to pars\n", + " _freqs = np.repeat(fobs_gw_cents, hc_ss[0].size).reshape(hc_ss.shape)\n", + " sspar = np.append(sspar, _freqs).reshape([8,]+[*sspar.shape[1:]])\n", + " _freqs = np.repeat(fobs_gw_cents, hc_bg[0].size).reshape(hc_bg.shape)\n", + " bgpar = np.append(bgpar, _freqs).reshape([8,]+[*bgpar.shape[1:]])\n", + "\n", + " par_names = np.append(sings.par_names, 'freqs')\n", + " par_units = np.append(sings.par_units, YR)\n", + " par_labels = np.append(sings.par_labels, 'GW Frequency $f_\\mathrm{obs}\\ \\mathrm{yr}^{-1}$')\n", + "\n", + " print(f\"{par_names=}\\n{par_units=}\\n{par_labels=}\")\n", + "\n", + " pardat= dict(sspar=sspar, bgpar=bgpar, par_names=par_names, par_units=par_units, par_labels=par_labels)\n", + "\n", + " return pardat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pardat = append_pars(data[1])\n", + "\n", + "par_names=pardat['par_names']\n", + "par_units=pardat['par_units']\n", + "par_labels=pardat['par_labels']\n", + "sspar=pardat['sspar']\n", + "bgpar=pardat['bgpar']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "assert np.all(sspar[-1,:,0,0] == sspar[-1,:,1,1]), 'appending freqs failed'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.scatter(np.arange(sspar[-1].size), sspar[-1].flatten())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.where(sspar[4]==np.nan))\n", + "print(np.log10(np.nanmin(sspar[-1,...,0])))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.log10(-20))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_2D_hist(ax, xx, yy, nbins,):\n", + " xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", + " ymin = np.nanmin(yy)\n", + " print(f\"{ymin=}\")\n", + " ymin, ymax = np.log10(ymin), np.log10(np.nanmax(yy))\n", + " print(f\"{ymin=}, {ymax=}\")\n", + " yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", + " print(f\"{holo.utils.stats(yy_edges)=}\")\n", + " hist, yy_edges, xx_edges, = np.histogram2d(yy.flatten(), xx.flatten(), bins = (yy_edges, xx_edges))\n", + " print(f\"{holo.utils.stats(xx_edges)=}, {holo.utils.stats(yy_edges)=}\")\n", + "\n", + " xgrid, ygrid = np.meshgrid(xx_edges, yy_edges)\n", + " print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", + " ax.pcolormesh(xgrid, ygrid, hist)\n", + "\n", + "def plot_number_densities(sspar, bgpar, xx_idx = [0], yy_idx=[4,7], nbins=25,\n", + " par_names=par_names, par_units=par_units, par_labels=par_labels):\n", + " ncols = 2\n", + " nrows = len(yy_idx)\n", + "\n", + " xlabel = par_labels[xx_idx]\n", + " ylabel = par_labels[yy_idx]\n", + "\n", + " fig, axs = plot.figax_double(nrows=nrows, ncols=ncols, \n", + " sharex=True)\n", + " axs[0,0].set_title('$h_c^2$-weighted background')\n", + " axs[0,1].set_title('single sources')\n", + " axs[0,0].set_ylabel(ylabel[0])\n", + " axs[1,0].set_ylabel(ylabel[1])\n", + " for ii,ax in enumerate(axs[1,:]):\n", + " ax.set_xlabel(xlabel[0])\n", + " for ii,ax in enumerate(axs[:,1]):\n", + " ax.sharey(axs[ii,0])\n", + "\n", + " # draw background\n", + " xx = (bgpar[xx_idx]*par_units[xx_idx])\n", + " print(xx.shape)\n", + " for ii, yy in enumerate(bgpar[yy_idx]):\n", + " yy = yy*par_units[yy_idx[ii]]\n", + " print(f\"bg {xx.shape}, {yy.shape=}\")\n", + " draw_2D_hist(axs[ii,0], xx, yy, nbins)\n", + "\n", + " # draw single sources\n", + " xx = (sspar[xx_idx][0,...]*par_units[xx_idx]).flatten()\n", + " print(f\"xx: {xx.shape=}\")\n", + " print(np.sum(np.isinf(xx)))\n", + " # for ii, yy in enumerate(sspar[yy_idx,...,0]):\n", + " for ii in[1,0]:\n", + " yy = sspar[yy_idx[ii]]\n", + " yy = (yy*par_units[yy_idx[ii]]).flatten()\n", + " print(np.sum(np.isinf(yy)))\n", + " print(f\"ss {xx.shape}, {yy.shape=}\")\n", + " draw_2D_hist(axs[ii,1], xx, yy, nbins)\n", + "\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_number_densities(sspar, bgpar)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 9f6e9e33bf5f078201fdc5c014455e8df4854b2d Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 13:38:48 -0700 Subject: [PATCH 094/291] Added workaround for negative ss dcom_final and cleaned up append_freqs_to_pars function. --- .../take9_numberdensity_mass_dist.ipynb | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb index 72679f10..4f44887f 100644 --- a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb +++ b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb @@ -157,12 +157,13 @@ "metadata": {}, "outputs": [], "source": [ - "def append_pars(data=data[1]):\n", + "def _append_freqs_to_pars(data=data[1]):\n", " hc_ss=data['hc_ss']\n", " hc_bg=data['hc_bg']\n", "\n", " sspar = data['sspar']\n", " sspar = sings.all_sspars(fobs_gw_cents, sspar)\n", + " # sspar[sspar<0]=0\n", " bgpar = data['bgpar']\n", "\n", "\n", @@ -183,58 +184,6 @@ " return pardat" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "pardat = append_pars(data[1])\n", - "\n", - "par_names=pardat['par_names']\n", - "par_units=pardat['par_units']\n", - "par_labels=pardat['par_labels']\n", - "sspar=pardat['sspar']\n", - "bgpar=pardat['bgpar']" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "assert np.all(sspar[-1,:,0,0] == sspar[-1,:,1,1]), 'appending freqs failed'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "plt.scatter(np.arange(sspar[-1].size), sspar[-1].flatten())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.where(sspar[4]==np.nan))\n", - "print(np.log10(np.nanmin(sspar[-1,...,0])))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.log10(-20))" - ] - }, { "cell_type": "code", "execution_count": null, @@ -256,8 +205,17 @@ " print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", " ax.pcolormesh(xgrid, ygrid, hist)\n", "\n", - "def plot_number_densities(sspar, bgpar, xx_idx = [0], yy_idx=[4,7], nbins=25,\n", + "def plot_number_densities(data, xx_idx = [0], yy_idx=[4,7], nbins=25,\n", " par_names=par_names, par_units=par_units, par_labels=par_labels):\n", + " \n", + " # add frequencies to par arrays\n", + " par_dat = _append_freqs_to_pars(data)\n", + " par_names=pardat['par_names']\n", + " par_units=pardat['par_units']\n", + " par_labels=pardat['par_labels']\n", + " sspar=pardat['sspar']\n", + " bgpar=pardat['bgpar']\n", + "\n", " ncols = 2\n", " nrows = len(yy_idx)\n", "\n", @@ -283,23 +241,65 @@ " print(f\"bg {xx.shape}, {yy.shape=}\")\n", " draw_2D_hist(axs[ii,0], xx, yy, nbins)\n", "\n", - " # draw single sources\n", - " xx = (sspar[xx_idx][0,...]*par_units[xx_idx]).flatten()\n", - " print(f\"xx: {xx.shape=}\")\n", - " print(np.sum(np.isinf(xx)))\n", - " # for ii, yy in enumerate(sspar[yy_idx,...,0]):\n", - " for ii in[1,0]:\n", - " yy = sspar[yy_idx[ii]]\n", - " yy = (yy*par_units[yy_idx[ii]]).flatten()\n", - " print(np.sum(np.isinf(yy)))\n", + " # draw background\n", + " xx = (sspar[xx_idx]*par_units[xx_idx])\n", + " print(xx.shape)\n", + " for ii, yy in enumerate(sspar[yy_idx]):\n", + " yy = yy*par_units[yy_idx[ii]]\n", + " yy[yy<0] = np.min(yy[yy>0])\n", " print(f\"ss {xx.shape}, {yy.shape=}\")\n", " draw_2D_hist(axs[ii,1], xx, yy, nbins)\n", "\n", - "\n", " fig.tight_layout()\n", " return fig\n", "\n", - "fig = plot_number_densities(sspar, bgpar)" + "fig = plot_number_densities(data[1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sspar.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "idx = np.where(sings.par_names=='redz_final')\n", + "print(np.sum(sspar[idx]<0), 'out of %d sources have z_final<0' % sspar[0].size)\n", + "print((sspar[idx])[sspar[idx]<0])\n", + "\n", + "idx = np.where(sings.par_names=='dcom_final')\n", + "print(np.sum(sspar[idx]<0), 'out of %d sources have dcom_final<0' % sspar[0].size)\n", + "print((sspar[idx])[sspar[idx]<0]/MPC)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(sspar[idx]/MPC))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "idx = np.where(sings.par_names=='mtot')\n", + "print(np.sum(sspar[idx]<0), 'out of %d sources have mtot<0' % sspar[0].size)\n", + "print((sspar[idx])[sspar[idx]<0]/MPC)" ] }, { From dbf0a704c7cdd3389e56bdf0bdf591fbcf685851 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 21:22:33 -0700 Subject: [PATCH 095/291] New mollview maps --- .../anisotropy/plot-notebooks/sim_map.ipynb | 375 ++++++++++++++++++ 1 file changed, 375 insertions(+) create mode 100644 ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb diff --git a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb new file mode 100644 index 00000000..4d4b588c --- /dev/null +++ b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb @@ -0,0 +1,375 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "\n", + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats, anisotropy\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib as mpl\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load and concatenate pixel strains and harmonic coefficients for NSIDE 32" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NBEST = 5\n", + "\n", + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ss info\n", + "shape = file1['ss_shape']\n", + "nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "fobs = file1['fobs']\n", + "\n", + "# load ranking info\n", + "nsort = file1['nsort'][:NBEST]\n", + "fidx = file1['fidx']\n", + "hc_ref = file1['hc_ref']\n", + "\n", + "# load harmonics info\n", + "nside = file1['nside']\n", + "lmax = file1['lmax']\n", + "\n", + "# load map and harmonics from 1st split chunk\n", + "moll_hc_best1 = file1['moll_hc_best'][:NBEST]\n", + "Cl_best1 = file1['Cl_best'][:NBEST]\n", + "nbest1 = len(moll_hc_best1)\n", + "\n", + "file1.close()\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(fobs[1]*10**9)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll_hc = moll_hc_best1[0]\n", + "print(f\"{moll_hc.shape}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff=1\n", + "rr=3\n", + "fig, ax = plot.figax()\n", + "hp.mollview(moll_hc[ff,rr], hold=True, title='Simulated %.2f yr$^{-1}$ GW Sky' % ( fobs[ff]*YR), \n", + " unit='$h_c^2/\\mathrm{sr}^2$', min = 4e-33, max=1e-30,\n", + " \n", + " )\n", + "# hp.graticule(alpha=0.5)\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff=1\n", + "rr=3\n", + "fig,ax = plot.figax()\n", + "\n", + "smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(1.) )\n", + "\n", + "\n", + "# mpl.rcParams.update({'font.size': 14}) \n", + "hp.mollview(smooth_map, hold=True, title=None, fig=fig,\n", + " unit='$h_c^2($f$=%.2f\\ \\mathrm{yr}^{-1})$' % ( fobs[ff]*YR), \n", + " min = 4e-33, max=8e-31, cbar=False\n", + " )\n", + "# hp.graticule(alpha=0.5)\n", + "\n", + "fig, ax = plt.gcf(), plt.gca()\n", + "image = ax.get_images()[0]\n", + "\n", + "# fig.colorbar(image, orientation='horizontal', \n", + "# label='$h_c^2 (f=%0.2f\\ \\mathrm{yr^{-1}})$' % (fobs[ff]*YR),\n", + "# pad=0.02, shrink=0.6, aspect=30)\n", + "# fig.colorbar()\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "ff=1\n", + "rr=3\n", + "lmax=6\n", + "fig,ax = plot.figax()\n", + "\n", + "\n", + "Cl = hp.anafast(moll_hc[ff,rr], lmax=lmax)\n", + "Cl_map = hp.synfast(Cl, nside, lmax=lmax)\n", + "\n", + "seed = np.random.randint(99999) # get a random number\n", + "print(seed) # print it out so we can reuse it if desired\n", + "seed = 34891\n", + "np.random.seed(seed) \n", + "\n", + "# mpl.rcParams.update({'font.size': 14}) \n", + "hp.mollview(Cl_map, hold=True, title='Reconstructed with $\\ell_\\mathrm{max}=%d$' % lmax, fig=fig,\n", + " unit='$h_c^2($f$=%.2f\\ \\mathrm{yr}^{-1})$' % ( fobs[ff]*YR), \n", + " cbar=False, #min = 4e-33, max=8e-31, \n", + " )\n", + "# hp.graticule(alpha=0.5)\n", + "\n", + "fig, ax = plt.gcf(), plt.gca()\n", + "image = ax.get_images()[0]\n", + "\n", + "# fig.colorbar(image, orientation='horizontal', \n", + "# label='$h_c^2 (f=%0.2f\\ \\mathrm{yr^{-1}})$' % (fobs[ff]*YR),\n", + "# pad=0.02, shrink=0.6, aspect=30)\n", + "# fig.colorbar()\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "ff=1\n", + "rr=3\n", + "lmax=3\n", + "\n", + "\n", + "Cl = hp.anafast(moll_hc[ff,rr], lmax=lmax)\n", + "\n", + "seed = 50158 # get a random number\n", + "print(seed) # print it out so we can reuse it if desired\n", + "np.random.seed(seed) \n", + "\n", + "fig,ax = plot.figax()\n", + "\n", + "\n", + "Cl_map = hp.synfast(Cl, nside, lmax=lmax)\n", + "# mpl.rcParams.update({'font.size': 14}) \n", + "hp.mollview(Cl_map, hold=True, \n", + " title='Reconstructed with $\\ell_\\mathrm{max}=%d$, seed=%d' % (lmax, seed),\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + "fig, ax = plt.gcf(), plt.gca()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "ff=1\n", + "rr=3\n", + "lmax=3\n", + "\n", + "\n", + "Cl = hp.anafast(moll_hc[ff,rr], lmax=lmax)\n", + "\n", + "for ii in range(20):\n", + " seed = np.random.randint(99999) # get a random number\n", + " print(seed) # print it out so we can reuse it if desired\n", + " np.random.seed(seed) \n", + "\n", + " fig,ax = plot.figax()\n", + "\n", + "\n", + " Cl_map = hp.synfast(Cl, nside, lmax=lmax)\n", + " # mpl.rcParams.update({'font.size': 14}) \n", + " hp.mollview(Cl_map, hold=True, \n", + " title='Reconstructed with $\\ell_\\mathrm{max}=%d$, seed=%d' % (lmax, seed),\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + " fig, ax = plt.gcf(), plt.gca()\n", + " # fig.savefig(('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/mollmaps/log_r%df%d_%02ddeg.png'\n", + " # % (rr,ff,deg)))\n", + " # plt.close(fig)\n", + "\n", + " # seed = np.random.randint(99999) # get a random number\n", + " # print(seed) # print it out so we can reuse it if desired\n", + " # np.random.seed(seed) \n", + " # # mpl.rcParams.update({'font.size': 14}) \n", + " # hp.mollview(Cl_map, hold=False, title=None, \n", + " # unit='$h_c^2($f$=%.2f\\ \\mathrm{yr}^{-1})$' % ( fobs[ff]*YR), )\n", + " # fig, ax = plt.gcf(), plt.gca()\n", + " # ax.set_title(', fontsize=12)\n", + " # # fig.colorbar()\n", + " # fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for deg in np.geomspace(5,180,5):\n", + " smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(deg) )\n", + " fig,ax = plot.figax()\n", + "\n", + " # mpl.rcParams.update({'font.size': 14}) \n", + " hp.mollview(smooth_map, hold=True, \n", + " title='Smoothed with fwhm=%d$\\deg$' % (deg),\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + " fig, ax = plt.gcf(), plt.gca()\n", + " # fig.savefig(('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/mollmaps/log_r%df%d_%02ddeg.png'\n", + " # % (rr,ff,deg)))\n", + " # plt.close(fig)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Save varying smoothing" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff=1\n", + "rr=3\n", + "# fig,ax = plot.figax()\n", + "\n", + "\n", + "# deg=30.\n", + "ii=0\n", + "for deg in np.geomspace(180,.01,100):\n", + " ii+=1\n", + " smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(deg) )\n", + " fig,ax = plot.figax()\n", + "\n", + " # mpl.rcParams.update({'font.size': 14}) \n", + " hp.mollview(smooth_map, hold=True, \n", + " title='Smoothed with fwhm=%d$\\deg$' % (deg),\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + " fig, ax = plt.gcf(), plt.gca()\n", + " fig.savefig(('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/mollmaps/log180_ii%d_r%df%d_%03ddeg.png'\n", + " % (ii,rr,ff,deg)))\n", + " plt.close(fig)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ff=1\n", + "rr=3\n", + "fig,ax = plot.figax()\n", + "\n", + "smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(60.) )\n", + "\n", + "\n", + "# mpl.rcParams.update({'font.size': 14}) \n", + "hp.mollview(smooth_map, hold=True, title=None, fig=fig,\n", + " unit='$h_c^2($f$=%.2f\\ \\mathrm{yr}^{-1})$' % ( fobs[ff]*YR), \n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + "# hp.graticule(alpha=0.5)\n", + "\n", + "fig, ax = plt.gcf(), plt.gca()\n", + "image = ax.get_images()[0]\n", + "\n", + "# fig.colorbar(image, orientation='horizontal', \n", + "# label='$h_c^2 (f=%0.2f\\ \\mathrm{yr^{-1}})$' % (fobs[ff]*YR),\n", + "# pad=0.02, shrink=0.6, aspect=30)\n", + "# fig.colorbar()\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 4fc86dcf9d5737a452af6739395aad03206086a0 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 21:38:11 -0700 Subject: [PATCH 096/291] trivial changes --- ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb index 4d4b588c..61edde54 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb @@ -343,6 +343,14 @@ "fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Higher res" + ] + }, { "cell_type": "code", "execution_count": null, From d6ddb3c0cc59093b79d84696293a35aece64aac0 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 21 Jun 2023 22:57:38 -0700 Subject: [PATCH 097/291] checking out negative redz's --- .../negative_redz.ipynb | 137 ++++++++++ .../take9_numberdensity_mass_dist.ipynb | 248 +++++++++++++++--- 2 files changed, 354 insertions(+), 31 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/negative_redz.ipynb diff --git a/ecg-notebooks/parameter_investigation/negative_redz.ipynb b/ecg-notebooks/parameter_investigation/negative_redz.ipynb new file mode 100644 index 00000000..bc78d2a5 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/negative_redz.ipynb @@ -0,0 +1,137 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = 30\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct a pspace instance" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "\n", + "# get the parameter names from this library-space\n", + "param_names = pspace.param_names\n", + "num_pars = len(pspace.param_names)\n", + "print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + "# choose each parameter to be half-way across the range provided by the library\n", + "pars = 0.5 * np.ones(num_pars)\n", + "# params = pars * pspace.param_samples\n", + "params = pspace.normalized_params(pars)\n", + "print(f\"{pars=}\")\n", + "print(f\"{params=}\")\n", + "\n", + "# construct `sam` and `hard` instances based on these parameters,\n", + "# using otherwise all default parameters for this library\n", + "sam, hard = pspace.model_for_normalized_params(pars)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", + "\n", + "# run this model, retrieving binary parameters and the GWB\n", + "data = holo.librarian.run_model(sam, hard, NREALS, NFREQS, NLOUDEST, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + "print(f\"retrieved data: {data.keys()=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspar = data['sspar']\n", + "bgpar = data['bgpar']\n", + "\n", + "print(f\"{sspar.shape=}\")\n", + "print('%d out of %d' % (np.sum(sspar[3]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[3]<0), bgpar[3].size))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(fobs_gw_edges=data['fobs_edges'], hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", + "print('%d out of %d' % (np.sum(sspar[3]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[3]<0), bgpar[3].size))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb index 4f44887f..60206f44 100644 --- a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb +++ b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb @@ -157,7 +157,7 @@ "metadata": {}, "outputs": [], "source": [ - "def _append_freqs_to_pars(data=data[1]):\n", + "def _append_freqs_to_pars(data=data[1], debug=False, short_labels=True):\n", " hc_ss=data['hc_ss']\n", " hc_bg=data['hc_bg']\n", "\n", @@ -177,7 +177,11 @@ " par_units = np.append(sings.par_units, YR)\n", " par_labels = np.append(sings.par_labels, 'GW Frequency $f_\\mathrm{obs}\\ \\mathrm{yr}^{-1}$')\n", "\n", - " print(f\"{par_names=}\\n{par_units=}\\n{par_labels=}\")\n", + " if short_labels:\n", + " par_labels[4] = '$d_\\mathrm{com}$ (Mpc)'\n", + " par_labels[7] = 'GW$ f_\\mathrm{obs}$ (nHz)'\n", + "\n", + " if debug: print(f\"{par_names=}\\n{par_units=}\\n{par_labels=}\")\n", "\n", " pardat= dict(sspar=sspar, bgpar=bgpar, par_names=par_names, par_units=par_units, par_labels=par_labels)\n", "\n", @@ -190,26 +194,23 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_2D_hist(ax, xx, yy, nbins,):\n", + "def draw_2D_hist(ax, xx, yy, nbins, cmap='viridis'):\n", " xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", - " ymin = np.nanmin(yy)\n", - " print(f\"{ymin=}\")\n", - " ymin, ymax = np.log10(ymin), np.log10(np.nanmax(yy))\n", - " print(f\"{ymin=}, {ymax=}\")\n", " yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", - " print(f\"{holo.utils.stats(yy_edges)=}\")\n", + " # print(f\"{holo.utils.stats(yy_edges)=}\")\n", " hist, yy_edges, xx_edges, = np.histogram2d(yy.flatten(), xx.flatten(), bins = (yy_edges, xx_edges))\n", - " print(f\"{holo.utils.stats(xx_edges)=}, {holo.utils.stats(yy_edges)=}\")\n", + " # print(f\"{holo.utils.stats(xx_edges)=}, {holo.utils.stats(yy_edges)=}\")\n", "\n", " xgrid, ygrid = np.meshgrid(xx_edges, yy_edges)\n", - " print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", - " ax.pcolormesh(xgrid, ygrid, hist)\n", + " # print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", + " ax.pcolormesh(xgrid, ygrid, hist, cmap=cmap)\n", "\n", - "def plot_number_densities(data, xx_idx = [0], yy_idx=[4,7], nbins=25,\n", - " par_names=par_names, par_units=par_units, par_labels=par_labels):\n", + "def plot_number_densities(data, xx_idx = [0], yy_idx=[4,7], nbins=25, \n", + " ylim0=(5*10**1, 5*10**3), ylim1=(5*10**-2, 4E0),\n", + " xlim = (2*10**7, 10**11)):\n", " \n", " # add frequencies to par arrays\n", - " par_dat = _append_freqs_to_pars(data)\n", + " pardat = _append_freqs_to_pars(data)\n", " par_names=pardat['par_names']\n", " par_units=pardat['par_units']\n", " par_labels=pardat['par_labels']\n", @@ -223,32 +224,30 @@ " ylabel = par_labels[yy_idx]\n", "\n", " fig, axs = plot.figax_double(nrows=nrows, ncols=ncols, \n", - " sharex=True)\n", - " axs[0,0].set_title('$h_c^2$-weighted background')\n", - " axs[0,1].set_title('single sources')\n", - " axs[0,0].set_ylabel(ylabel[0])\n", - " axs[1,0].set_ylabel(ylabel[1])\n", + " sharex=True, figsize=(7,6))\n", + " axs[0,0].set_title('$h_c^2$-weighted background', fontsize=10)\n", + " axs[0,1].set_title('single sources', fontsize=10)\n", + " axs[0,0].set_ylabel(ylabel[0], fontsize=10)\n", + " axs[1,0].set_ylabel(ylabel[1], fontsize=10)\n", + " if ylim0 is not None: axs[0,0].set_ylim(ylim0)\n", + " if ylim1 is not None: axs[1,0].set_ylim(ylim1)\n", " for ii,ax in enumerate(axs[1,:]):\n", - " ax.set_xlabel(xlabel[0])\n", + " ax.set_xlabel(xlabel[0], fontsize=10)\n", " for ii,ax in enumerate(axs[:,1]):\n", " ax.sharey(axs[ii,0])\n", "\n", " # draw background\n", " xx = (bgpar[xx_idx]*par_units[xx_idx])\n", - " print(xx.shape)\n", " for ii, yy in enumerate(bgpar[yy_idx]):\n", " yy = yy*par_units[yy_idx[ii]]\n", - " print(f\"bg {xx.shape}, {yy.shape=}\")\n", " draw_2D_hist(axs[ii,0], xx, yy, nbins)\n", "\n", - " # draw background\n", + " # draw single sources\n", " xx = (sspar[xx_idx]*par_units[xx_idx])\n", - " print(xx.shape)\n", " for ii, yy in enumerate(sspar[yy_idx]):\n", " yy = yy*par_units[yy_idx[ii]]\n", - " yy[yy<0] = np.min(yy[yy>0])\n", - " print(f\"ss {xx.shape}, {yy.shape=}\")\n", - " draw_2D_hist(axs[ii,1], xx, yy, nbins)\n", + " yy[yy<0] = np.min(yy[yy>0]) # patch\n", + " draw_2D_hist(axs[ii,1], xx, yy, nbins, 'inferno')\n", "\n", " fig.tight_layout()\n", " return fig\n", @@ -257,12 +256,11 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "print(sspar.shape)" + "# Problem with negative final comoving distances and redshifts" ] }, { @@ -302,6 +300,194 @@ "print((sspar[idx])[sspar[idx]<0]/MPC)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.where())" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plots" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='hard_time'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()\n", + "# # set directory path\n", + "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "# save_dir=sam_loc+'/figures' " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# gsmf_phi0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='gsmf_phi0'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# gsmf_mchar0_log10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='gsmf_mchar0_log10'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## mmbulge_mamp_log10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='mmb_mamp_log10'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_scatter_dex" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='mmb_scatter_dex'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='hard_gamma_inner'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, { "cell_type": "code", "execution_count": null, From b77b9acc3c8ad23bf779112941e39637ca57cdca Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 00:01:54 -0700 Subject: [PATCH 098/291] Changed import sam to import sams.sam in gen_lib_sams.py --- scripts/gen_lib_sams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen_lib_sams.py b/scripts/gen_lib_sams.py index d78a32e1..e90596a5 100644 --- a/scripts/gen_lib_sams.py +++ b/scripts/gen_lib_sams.py @@ -38,7 +38,7 @@ from mpi4py import MPI import holodeck as holo -import holodeck.sam +import holodeck.sams.sam import holodeck.logger # from holodeck.constants import YR from holodeck import log as _log #: import the default holodeck log just so that we can silence it From 47570dfffbea4efff302d40cbf9f29f0cf610eef Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 08:11:44 -0700 Subject: [PATCH 099/291] Made hi-res gif maps in sim_map.ipynb --- .../anisotropy/plot-notebooks/sim_map.ipynb | 196 +++++++++++++++++- 1 file changed, 195 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb index 61edde54..1fd8b99c 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb @@ -44,7 +44,7 @@ "metadata": {}, "outputs": [], "source": [ - "NBEST = 5\n", + "NBEST = 1\n", "\n", "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b00-49.npz')\n", "print(f\"{file1.files=}\")\n", @@ -343,6 +343,34 @@ "fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Find Best Sample" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NBEST = 1\n", + "\n", + "file1 = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns32_r50_b00-49.npz')\n", + "print(f\"{file1.files=}\")\n", + "# load ranking info\n", + "nsort = file1['nsort'][:NBEST]\n", + "print(nsort[0])\n", + "nn = nsort[0]\n", + "\n", + "\n", + "file1.close()\n", + "\n" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -351,6 +379,172 @@ "# Higher res" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nn=320\n", + "ff=1\n", + "rr=3\n", + "\n", + "sam_dir = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss51-2023-05-22_uniform_07a_n1000_r100_f40_l2000/'\n", + "hdf_name = sam_dir + '/sam_lib.hdf5'\n", + "hdf_file = h5py.File(hdf_name, 'r')\n", + "\n", + "hc_ss = hdf_file['hc_ss'][nn,0:5,0:5,:]\n", + "hc_bg = hdf_file['hc_bg'][nn,0:5,0:5]\n", + "fobs = hdf_file['fobs'][:]\n", + "\n", + "hdf_file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(hc_ss.shape)\n", + "print(hc_bg.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# make path" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "out_path = '/Users/emigardiner/GWs/holodeck/output/mollmaps'\n", + "out_dir = out_path+'/09B_nside128'\n", + "import os\n", + "if (os.path.exists(out_dir) is False):\n", + " print('Making output directory.')\n", + " os.makedirs(out_dir)\n", + "else:\n", + " print('Writing to an existing directory.')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "make mollmap" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "moll_hc = anisotropy.healpix_map(hc_ss, hc_bg, nside=128)\n", + "ff=1\n", + "rr=3\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot, as is" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig,ax = plot.figax()\n", + "\n", + "# mpl.rcParams.update({'font.size': 14}) \n", + "hp.mollview(moll_hc[ff,rr], hold=True, \n", + " title=None,\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + "fig, ax = plt.gcf(), plt.gca()\n", + "# plt.close(fig)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot a few smoothing cases" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# deg=30.\n", + "ii=0\n", + "for deg in np.geomspace(180,1,10):\n", + " ii+=1\n", + " smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(deg) )\n", + " fig,ax = plot.figax()\n", + "\n", + " # mpl.rcParams.update({'font.size': 14}) \n", + " hp.mollview(smooth_map, hold=True, \n", + " title='Smoothed with fwhm=%.1f$\\deg$' % (deg),\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + " fig, ax = plt.gcf(), plt.gca()\n", + " # fig.savefig(('/Users/emigardiner/GWs/holodeck/ecg-notebooks/anisotropy/mollmaps/log180_ii%d_r%df%d_%03ddeg.png'\n", + " # % (ii,rr,ff,deg)))\n", + " # plt.close(fig)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "plot and save many for gif" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "ii=0\n", + "for deg in np.geomspace(180,1,500):\n", + " ii+=1\n", + " smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(deg) )\n", + " fig,ax = plot.figax()\n", + "\n", + " # mpl.rcParams.update({'font.size': 14}) \n", + " hp.mollview(smooth_map, hold=True, \n", + " title=None,\n", + " cbar=False\n", + " #min = 4e-33, max=1.5e-31, cbar=False\n", + " )\n", + " fig, ax = plt.gcf(), plt.gca()\n", + " fig.savefig((out_dir+'/ii%03d_rr%02dff%02d_%03ddeg.png'\n", + " % (ii,rr,ff,deg)))\n", + " plt.close(fig)\n" + ] + }, { "cell_type": "code", "execution_count": null, From c1a476426d860b755a631e2ba27b41bc89cbd484 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 08:50:06 -0700 Subject: [PATCH 100/291] Trying higher nside --- .../anisotropy/plot-notebooks/sim_map.ipynb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb index 1fd8b99c..fdc4ef91 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb @@ -397,7 +397,9 @@ "hc_bg = hdf_file['hc_bg'][nn,0:5,0:5]\n", "fobs = hdf_file['fobs'][:]\n", "\n", - "hdf_file.close()\n" + "hdf_file.close()\n", + "\n", + "nside=128\n" ] }, { @@ -415,7 +417,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# make path" + "### make path" ] }, { @@ -424,8 +426,10 @@ "metadata": {}, "outputs": [], "source": [ + "\n", + "\n", "out_path = '/Users/emigardiner/GWs/holodeck/output/mollmaps'\n", - "out_dir = out_path+'/09B_nside128'\n", + "out_dir = out_path+'/09B_nside%d_take2' % nside\n", "import os\n", "if (os.path.exists(out_dir) is False):\n", " print('Making output directory.')\n", @@ -439,7 +443,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "make mollmap" + "### make mollmap" ] }, { @@ -448,7 +452,7 @@ "metadata": {}, "outputs": [], "source": [ - "moll_hc = anisotropy.healpix_map(hc_ss, hc_bg, nside=128)\n", + "moll_hc = anisotropy.healpix_map(hc_ss, hc_bg, nside=nside)\n", "ff=1\n", "rr=3\n" ] From 9fcb68257a40f32159859518de3cf67a17b76ae5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 10:17:46 -0700 Subject: [PATCH 101/291] Set random seed in moll_hc production --- .../anisotropy/plot-notebooks/sim_map.ipynb | 65 ++++++++++--------- holodeck/anisotropy.py | 11 +++- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb index fdc4ef91..ae26db93 100644 --- a/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb +++ b/ecg-notebooks/anisotropy/plot-notebooks/sim_map.ipynb @@ -399,7 +399,7 @@ "\n", "hdf_file.close()\n", "\n", - "nside=128\n" + "\n" ] }, { @@ -426,33 +426,9 @@ "metadata": {}, "outputs": [], "source": [ - "\n", - "\n", - "out_path = '/Users/emigardiner/GWs/holodeck/output/mollmaps'\n", - "out_dir = out_path+'/09B_nside%d_take2' % nside\n", - "import os\n", - "if (os.path.exists(out_dir) is False):\n", - " print('Making output directory.')\n", - " os.makedirs(out_dir)\n", - "else:\n", - " print('Writing to an existing directory.')" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### make mollmap" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "moll_hc = anisotropy.healpix_map(hc_ss, hc_bg, nside=nside)\n", + "nside=256\n", + "moll_hc,seed = anisotropy.healpix_map(hc_ss, hc_bg, nside=nside, \n", + " seed=80818, ret_seed=True)\n", "ff=1\n", "rr=3\n" ] @@ -474,7 +450,7 @@ "fig,ax = plot.figax()\n", "\n", "# mpl.rcParams.update({'font.size': 14}) \n", - "hp.mollview(moll_hc[ff,rr], hold=True, \n", + "hp.mollview(hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(1)), hold=True, \n", " title=None,\n", " cbar=False\n", " #min = 4e-33, max=1.5e-31, cbar=False\n", @@ -499,7 +475,7 @@ "source": [ "# deg=30.\n", "ii=0\n", - "for deg in np.geomspace(180,1,10):\n", + "for deg in np.geomspace(120,1,10):\n", " ii+=1\n", " smooth_map = hp.smoothing(moll_hc[ff,rr], fwhm=np.radians(deg) )\n", " fig,ax = plot.figax()\n", @@ -521,7 +497,31 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "plot and save many for gif" + "### make directory" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "out_path = '/Users/emigardiner/GWs/holodeck/output/mollmaps'\n", + "out_dir = out_path+'/09B_nside%d_seed%d' % (nside, seed)\n", + "import os\n", + "if (os.path.exists(out_dir) is False):\n", + " print('Making output directory.')\n", + " os.makedirs(out_dir)\n", + "else:\n", + " print('Writing to an existing directory.')\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### plot and save many for gif" ] }, { @@ -544,8 +544,9 @@ " #min = 4e-33, max=1.5e-31, cbar=False\n", " )\n", " fig, ax = plt.gcf(), plt.gca()\n", + " fig.tight_layout()\n", " fig.savefig((out_dir+'/ii%03d_rr%02dff%02d_%03ddeg.png'\n", - " % (ii,rr,ff,deg)))\n", + " % (ii,rr,ff,deg)), dpi=300)\n", " plt.close(fig)\n" ] }, diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index d6b992c6..e8dfd61e 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -20,7 +20,7 @@ HC_REF15_10YR = 11.2*10**-15 -def healpix_map(hc_ss, hc_bg, nside=NSIDE): +def healpix_map(hc_ss, hc_bg, nside=NSIDE, seed=None, ret_seed=False): """ Build mollview array of hc^2/dOmega for a healpix map Parameters @@ -46,6 +46,12 @@ def healpix_map(hc_ss, hc_bg, nside=NSIDE): nreals = len(hc_ss[0]) nloudest = len(hc_ss[0,0]) + # set random seed + if seed is None: + seed = np.random.randint(99999) # get a random number + print(f"random seed: {seed}") # print it out so we can reuse it if desired + np.random.seed(seed) + # spread background evenly across pixels in moll_hc moll_hc = np.ones((nfreqs,nreals,npix)) * hc_bg[:,:,np.newaxis]**2/(npix/area) # (frequency, realization, pixel) @@ -55,7 +61,8 @@ def healpix_map(hc_ss, hc_bg, nside=NSIDE): for rr in range(nreals): for ll in range(nloudest): moll_hc[ff,rr,pix_ss[ff,rr,ll]] = (moll_hc[ff,rr,pix_ss[ff,rr,ll]] + hc_ss[ff,rr,ll]**2/area) - + if ret_seed: + return moll_hc, seed return moll_hc def healpix_map_oldhc2(hc_ss, hc_bg, nside=NSIDE): From 90945140b2a4f2c5cce7cd07489fabf0db521e7c Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 13:36:49 -0700 Subject: [PATCH 102/291] Various print statements in cyutils and single sources for debugging negative redz issue. --- .../negative_redz.ipynb | 128 +++++++++++++++++- holodeck/cyutils.pyx | 25 ++++ holodeck/single_sources.py | 53 +++++++- 3 files changed, 200 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/negative_redz.ipynb b/ecg-notebooks/parameter_investigation/negative_redz.ipynb index bc78d2a5..518bd6f4 100644 --- a/ecg-notebooks/parameter_investigation/negative_redz.ipynb +++ b/ecg-notebooks/parameter_investigation/negative_redz.ipynb @@ -30,10 +30,10 @@ "metadata": {}, "outputs": [], "source": [ - "SHAPE = 30\n", + "SHAPE = 10\n", "NREALS = 30\n", "NFREQS = 40\n", - "NLOUDEST = 10" + "NLOUDEST = 3" ] }, { @@ -72,6 +72,7 @@ " hard_name = 'Fixed Time'\n", "elif isinstance(hard, holo.hardening.Hard_GW):\n", " hard_name = 'GW Only'\n", + "\n", "# sam, hard = pspace.model_for_params(pspace.normalized_params(pars)) #this is way slower, but why??\n", "\n", "# run this model, retrieving binary parameters and the GWB\n", @@ -80,6 +81,43 @@ "print(f\"retrieved data: {data.keys()=}\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(hard._target_time/GYR)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", + " fobs_gw_edges=data['fobs_edges'], hard=holo.hardening.Fixed_Time_2PL_SAM(sam,3*GYR),\n", + " params=True, loudest=NLOUDEST, realize=NREALS, )\n", + "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", + " fobs_gw_edges=data['fobs_edges'], hard=holo.hardening.Fixed_Time_2PL_SAM(sam,5.5*GYR),\n", + " params=True, loudest=NLOUDEST, realize=NREALS, )\n", + "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n" + ] + }, { "cell_type": "code", "execution_count": null, @@ -94,17 +132,97 @@ "print('%d out of %d' % (np.sum(bgpar[3]<0), bgpar[3].size))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Check neg" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "hc_ss, hc_bg, sspar, bgpar = sam.gwb(fobs_gw_edges=data['fobs_edges'], hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR))\n", - "print('%d out of %d' % (np.sum(sspar[3]<0), sspar[3].size))\n", - "print('%d out of %d' % (np.sum(bgpar[3]<0), bgpar[3].size))" + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs()\n", + "print(fobs_gw_cents.size)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE)\n", + "\n", + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", + " fobs_gw_edges=fobs_gw_edges, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR),\n", + " params=True, loudest=NLOUDEST, realize=NREALS, )\n", + "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sams.Semi_Analytic_Model(shape=15)\n", + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", + " fobs_gw_edges=fobs_gw_edges, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR),\n", + " params=True)\n", + "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n", + "print(np.where(np.logical_and(sspar[3]<0, sspar[3] != -1)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "arr = np.random.uniform(-5, 5, 3*4).reshape(3,4)\n", + "arr[0,0]=-1\n", + "arr[2,2]=-1\n", + "print(arr)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "t1 = arr>0\n", + "t2 = arr==-1\n", + "print(t1,'\\n', t2)\n", + "either = np.logical_or(t1, t2)\n", + "print(either)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "either = np.logical_or(arr>0, arr==-1)\n", + "neither = np.logical_not(either)\n", + "print(either)\n", + "if np.any(neither):\n", + " print(np.sum(neither))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/holodeck/cyutils.pyx b/holodeck/cyutils.pyx index 639d84d3..56a49c59 100644 --- a/holodeck/cyutils.pyx +++ b/holodeck/cyutils.pyx @@ -1700,6 +1700,18 @@ cdef void _loudest_hc_and_par_from_sorted_redz(long[:] shape, double[:,:,:,:] h2 cdef int mm, qq, zz, ff, rr, ll cdef double num, cur, sum_bg, m_bg, q_bg, z_bg, zfinal_bg, dcom_bg, sepa_bg, angs_bg + # # check all redz_final are positive + # for mm in range(len(redz_final)): + # for qq in range(len(redz_final[0])): + # for zz in range(len(redz_final[0,0])): + # for ff in range(len(redz_final[0,0,0])): + # if (redz_final[mm,qq,zz,ff]<0 and redz_final[mm,qq,zz,ff] !=-1): + # err = f"redz_final[{mm},{qq},{zz},{ff},] = {redz_final[mm,qq,zz,ff]} < 0" + # raise ValueError(err) + # print("passed redz_final check in _loudest_hc_and_par_from_sorted_redz") + + + # Setup random number generator from numpy library cdef bitgen_t *rng cdef const char *capsule_name = "BitGenerator" @@ -1745,6 +1757,11 @@ cdef void _loudest_hc_and_par_from_sorted_redz(long[:] shape, double[:,:,:,:] h2 sspar[2,ff,rr,ll] = rz[zz] sspar[3,ff,rr,ll] = redz_final[mm,qq,zz,ff] + # check for negative redz_final + if redz_final[mm,qq,zz,ff]<0: + err = f"redz_final[{mm},{qq},{zz},{ff}] = {redz_final[mm,qq,zz,ff]} < 0" + print("ERROR IN CYUTILS:", err) + # update number and ll index num -= 1 ll += 1 @@ -1769,6 +1786,14 @@ cdef void _loudest_hc_and_par_from_sorted_redz(long[:] shape, double[:,:,:,:] h2 bgpar[5,ff,rr] = sepa_bg/sum_bg # bg avg binary separation after hardening bgpar[6,ff,rr] = angs_bg/sum_bg # bg avg binary angular separation after hardening + # for ff in range(len(sspar[3])): + # for rr in range(len(sspar[3,0])): + # for ll in range(len(sspar[3,0,0])): + # if (sspar[3,ff,rr,ll]<0 and sspar[3,ff,rr,ll] !=-1): + # err = f"sspar[3,{ff},{rr},{ll}] = {sspar[3,ff,rr,ll]} < 0" + # raise ValueError(err) + print("skipped sspar[3] check in _loudest_hc_and_par_from_sorted_redz") + diff --git a/holodeck/single_sources.py b/holodeck/single_sources.py index 1754e081..e9feacf5 100644 --- a/holodeck/single_sources.py +++ b/holodeck/single_sources.py @@ -92,6 +92,13 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): qsort = unraveled[1,:] zsort = unraveled[2,:] + if np.any(np.logical_and(redz<0, redz!=-1)): + err = np.sum(np.logical_and(redz<0, redz!=-1)) + err = f"{err} redz < 0 and !=-1 found in redz, in ss_gws_redz()" + raise ValueError(err) + + print('passed redz check at the beginning of ss_gws_redz()') + # For multiple realizations, using cython if(utils.isinteger(realize)): if(params == True): @@ -109,7 +116,22 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): redz = kale.utils.midpoints(redz, axis=0) redz = np.moveaxis(redz, 0, dd) - dcom_final = cosmo.comoving_distance(redz).to('cm').value # (M,Q,Z,F) in cm + # if np.any(np.logical_and(redz<0, redz!=-1)): + # err = np.sum(np.logical_and(redz<0, redz!=-1)) + # err = f"{err} redz < 0 and !=-1 found in redz, in ss_gws_redz() after kale.utils.midpoints" + # raise ValueError(err) + + dcom_final = +np.inf*np.ones_like(redz) + print(holo.utils.stats(redz), "before sel") + sel = (redz > 0.0) + redz[~sel] = -1.0 + print(holo.utils.stats(redz), "after sel") + redz[redz<0] = -1.0 + print(holo.utils.stats(redz), "after redz[redz<0]=-1") + dcom_final[sel] = cosmo.comoving_distance(redz[sel]).cgs.value + if np.any(dcom_final<0): print('dcom_final<0 found') + + # redz[redz<0] = -1 fobs_orb_edges = edges[-1] fobs_orb_cents = kale.utils.midpoints(fobs_orb_edges) @@ -119,6 +141,12 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): sepa = utils.kepler_sepa_from_freq(mt[:,np.newaxis,np.newaxis,np.newaxis], frst_orb_cents) # (M,Q,Z,F) in cm angs = utils.angs_from_sepa(sepa, dcom_final, redz) # (M,Q,Z,F) use sepa and dcom in cm + print(f"{mt.shape=}, {redz.shape=}, {edges[0].shape=}, {number.shape=}") + # if np.any(np.logical_and(redz<0, redz!=-1)): + # err = np.sum(np.logical_and(redz<0, redz!=-1)) + # err = f"{err} redz < 0 and !=-1 found in redz, in ss_gws_redz()" + # raise ValueError(err) + hc2ss, hc2bg, sspar, bgpar = \ holo.cyutils.loudest_hc_and_par_from_sorted_redz( number, h2fdf, realize, loudest, @@ -126,6 +154,29 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): msort, qsort, zsort) hc_ss = np.sqrt(hc2ss) # calculate single source strain hc_bg = np.sqrt(hc2bg) # calculate background strain + + + # either = np.logical_or(sspar[3]>0, sspar[3]==-1) + # print('either:', sspar[3][either]) + # neither = np.logical_not(either) + # print('neither:', sspar[3][neither]) + if np.any(np.logical_and(sspar[3]<0, sspar[3]!=-1)): + err = np.sum(np.logical_and(sspar[3]<0, sspar[3]!=-1)) + err = f"check 1: {err} out of {sspar[3].size} sspar[3] are negative and not -1 in sings.ss_gws_redz()" + neither = (np.logical_and(sspar[3]<0, sspar[3]!=-1)) + # print('bad sspar:' ,sspar[3][neither], 'at', np.where(neither==True)) + print(err) + raise ValueError(err) + + # check for negatives + if np.any(sspar[3]<0): + sumfalse = np.sum(sspar[3]<0) + err = f"check 2: {sumfalse} out of {sspar[3].size} redz_final are negative in sings.ss_gws_redz()" + # print(np.where(neither==True)) + print(err) + # raise ValueError(err) + + # return return hc_ss, hc_bg, sspar, bgpar else: From 3b7f52f7678c3280965c566b43b99ccdf1aeae60 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 13:38:23 -0700 Subject: [PATCH 103/291] Moved scratch notebooks --- ecg-notebooks/{ => scratch}/scratch_ds.ipynb | 0 ecg-notebooks/{ => scratch}/scratch_libs.ipynb | 0 ecg-notebooks/{ => scratch}/scratch_redz.ipynb | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename ecg-notebooks/{ => scratch}/scratch_ds.ipynb (100%) rename ecg-notebooks/{ => scratch}/scratch_libs.ipynb (100%) rename ecg-notebooks/{ => scratch}/scratch_redz.ipynb (100%) diff --git a/ecg-notebooks/scratch_ds.ipynb b/ecg-notebooks/scratch/scratch_ds.ipynb similarity index 100% rename from ecg-notebooks/scratch_ds.ipynb rename to ecg-notebooks/scratch/scratch_ds.ipynb diff --git a/ecg-notebooks/scratch_libs.ipynb b/ecg-notebooks/scratch/scratch_libs.ipynb similarity index 100% rename from ecg-notebooks/scratch_libs.ipynb rename to ecg-notebooks/scratch/scratch_libs.ipynb diff --git a/ecg-notebooks/scratch_redz.ipynb b/ecg-notebooks/scratch/scratch_redz.ipynb similarity index 100% rename from ecg-notebooks/scratch_redz.ipynb rename to ecg-notebooks/scratch/scratch_redz.ipynb From c867ed002f757301e3325a7e553b77c91aacb713 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 16:30:25 -0700 Subject: [PATCH 104/291] start notebook for better number density plots --- .../take9B_numberdensity_binned.ipynb | 579 ++++++++++++++++++ 1 file changed, 579 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb diff --git a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb new file mode 100644 index 00000000..94055564 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb @@ -0,0 +1,579 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss62_09Bsmall_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", + "print(npz.files)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for item in npz:\n", + " print(item)\n", + " print(npz[item].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(hdf.keys())\n", + "sample_params = hdf['sample_params']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs = hdf['fobs']\n", + "print(1/fobs[0]/YR)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Old below here" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# use one file to get the shape\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", + " allow_pickle=True) \n", + "print(f\"{npz.files=}\")\n", + "data = npz['data']\n", + "print(f\"{data[0].keys()=}\")\n", + "\n", + "# params = npz['params']\n", + "# hard_name = npz['hard_name']\n", + "shape = npz['shape']\n", + "print(f\"{shape=}\")\n", + "# target_param = npz['target_param']\n", + "fobs_gw_cents = npz['data'][0]['fobs_cents']\n", + "fobs_gw_edges = npz['data'][0]['fobs_edges']\n", + "\n", + "npz.close()\n", + "\n", + "# get param names\n", + "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=shape, seed=None)\n", + "param_names = pspace.param_names\n", + "print(f\"{param_names=}\")\n", + "\n", + "\n", + "hc_ss = data[1]['hc_ss']\n", + "hc_bg = data[1]['hc_bg']\n", + "bgpar = data[1]['bgpar']\n", + "sspar = data[1]['sspar']\n", + "sspar = sings.all_sspars(fobs_gw_cents=fobs_gw_cents, sspar=sspar)\n", + "print(f\"{sings.par_names=}\")\n", + "nfreqs, nreals, nloudest = [*hc_ss.shape]\n", + "print(f\"{nfreqs=}, {nreals=}, {nloudest=},\")\n", + "\n", + "# # set directory path\n", + "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "# save_dir=sam_loc+'/figures' " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Dev" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax(ncols=2, xlabel=['mtot', 'final dcom'], figsize=(8,3),\n", + " )\n", + "\n", + "idx = [0, 4]\n", + "\n", + "hist, bins, = np.histogram(sspar[idx[0]].flatten()/MSOL, )\n", + "plot.draw_hist_steps(axs[0], bins, hist)\n", + "\n", + "hist, bins, = np.histogram(sspar[idx[1]].flatten(), )\n", + "plot.draw_hist_steps(axs[1], bins, hist)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sings.par_units)\n", + "print(sings.par_labels)\n", + "print(1/MPC)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mtot = bgpar[0].flatten()/MSOL\n", + "dcom = bgpar[np.where(sings.par_names=='dcom_final')].flatten()/MPC\n", + "\n", + "nbins=30\n", + "mt_edges = np.logspace(np.log10(np.nanmin(mtot)), np.log10(np.nanmax(mtot)), nbins)\n", + "print(np.min(mtot), np.max(mtot))\n", + "print(mt_edges)\n", + "dc_edges = np.logspace(np.log10(np.min(dcom)), np.log10(np.max(dcom)), nbins)\n", + "hist, mtbins, dcbins = np.histogram2d(mtot, dcom, bins=(mt_edges, dc_edges))\n", + "\n", + "MT, DC = np.meshgrid(mtbins, dcbins)\n", + "\n", + "fig, ax = plot.figax(xlabel=sings.par_labels[0],\n", + " ylabel=sings.par_labels[4])\n", + "ax.pcolormesh(MT, DC, hist)\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plotting function" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print([8,]+[*sspar.shape[1:]])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def _append_freqs_to_pars(data=data[1], debug=False, short_labels=True):\n", + " hc_ss=data['hc_ss']\n", + " hc_bg=data['hc_bg']\n", + "\n", + " sspar = data['sspar']\n", + " sspar = sings.all_sspars(fobs_gw_cents, sspar)\n", + " # sspar[sspar<0]=0\n", + " bgpar = data['bgpar']\n", + "\n", + "\n", + " # Add frequency to pars\n", + " _freqs = np.repeat(fobs_gw_cents, hc_ss[0].size).reshape(hc_ss.shape)\n", + " sspar = np.append(sspar, _freqs).reshape([8,]+[*sspar.shape[1:]])\n", + " _freqs = np.repeat(fobs_gw_cents, hc_bg[0].size).reshape(hc_bg.shape)\n", + " bgpar = np.append(bgpar, _freqs).reshape([8,]+[*bgpar.shape[1:]])\n", + "\n", + " par_names = np.append(sings.par_names, 'freqs')\n", + " par_units = np.append(sings.par_units, YR)\n", + " par_labels = np.append(sings.par_labels, 'GW Frequency $f_\\mathrm{obs}\\ \\mathrm{yr}^{-1}$')\n", + "\n", + " if short_labels:\n", + " par_labels[4] = '$d_\\mathrm{com}$ (Mpc)'\n", + " par_labels[7] = 'GW$ f_\\mathrm{obs}$ (nHz)'\n", + "\n", + " if debug: print(f\"{par_names=}\\n{par_units=}\\n{par_labels=}\")\n", + "\n", + " pardat= dict(sspar=sspar, bgpar=bgpar, par_names=par_names, par_units=par_units, par_labels=par_labels)\n", + "\n", + " return pardat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_2D_hist(ax, xx, yy, nbins, cmap='viridis'):\n", + " xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", + " yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", + " # print(f\"{holo.utils.stats(yy_edges)=}\")\n", + " hist, yy_edges, xx_edges, = np.histogram2d(yy.flatten(), xx.flatten(), bins = (yy_edges, xx_edges))\n", + " # print(f\"{holo.utils.stats(xx_edges)=}, {holo.utils.stats(yy_edges)=}\")\n", + "\n", + " xgrid, ygrid = np.meshgrid(xx_edges, yy_edges)\n", + " # print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", + " ax.pcolormesh(xgrid, ygrid, hist, cmap=cmap)\n", + "\n", + "def plot_number_densities(data, xx_idx = [0], yy_idx=[4,7], nbins=25, \n", + " ylim0=(5*10**1, 5*10**3), ylim1=(5*10**-2, 4E0),\n", + " xlim = (2*10**7, 10**11)):\n", + " \n", + " # add frequencies to par arrays\n", + " pardat = _append_freqs_to_pars(data)\n", + " par_names=pardat['par_names']\n", + " par_units=pardat['par_units']\n", + " par_labels=pardat['par_labels']\n", + " sspar=pardat['sspar']\n", + " bgpar=pardat['bgpar']\n", + "\n", + " ncols = 2\n", + " nrows = len(yy_idx)\n", + "\n", + " xlabel = par_labels[xx_idx]\n", + " ylabel = par_labels[yy_idx]\n", + "\n", + " fig, axs = plot.figax_double(nrows=nrows, ncols=ncols, \n", + " sharex=True, figsize=(7,6))\n", + " axs[0,0].set_title('$h_c^2$-weighted background', fontsize=10)\n", + " axs[0,1].set_title('single sources', fontsize=10)\n", + " axs[0,0].set_ylabel(ylabel[0], fontsize=10)\n", + " axs[1,0].set_ylabel(ylabel[1], fontsize=10)\n", + " if ylim0 is not None: axs[0,0].set_ylim(ylim0)\n", + " if ylim1 is not None: axs[1,0].set_ylim(ylim1)\n", + " for ii,ax in enumerate(axs[1,:]):\n", + " ax.set_xlabel(xlabel[0], fontsize=10)\n", + " for ii,ax in enumerate(axs[:,1]):\n", + " ax.sharey(axs[ii,0])\n", + "\n", + " # draw background\n", + " xx = (bgpar[xx_idx]*par_units[xx_idx])\n", + " for ii, yy in enumerate(bgpar[yy_idx]):\n", + " yy = yy*par_units[yy_idx[ii]]\n", + " draw_2D_hist(axs[ii,0], xx, yy, nbins)\n", + "\n", + " # draw single sources\n", + " xx = (sspar[xx_idx]*par_units[xx_idx])\n", + " for ii, yy in enumerate(sspar[yy_idx]):\n", + " yy = yy*par_units[yy_idx[ii]]\n", + " yy[yy<0] = np.min(yy[yy>0]) # patch\n", + " draw_2D_hist(axs[ii,1], xx, yy, nbins, 'inferno')\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "fig = plot_number_densities(data[1])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem with negative final comoving distances and redshifts" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "\n", + "idx = np.where(sings.par_names=='redz_final')\n", + "print(np.sum(sspar[idx]<0), 'out of %d sources have z_final<0' % sspar[0].size)\n", + "print((sspar[idx])[sspar[idx]<0])\n", + "\n", + "idx = np.where(sings.par_names=='dcom_final')\n", + "print(np.sum(sspar[idx]<0), 'out of %d sources have dcom_final<0' % sspar[0].size)\n", + "print((sspar[idx])[sspar[idx]<0]/MPC)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(sspar[idx]/MPC))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "idx = np.where(sings.par_names=='mtot')\n", + "print(np.sum(sspar[idx]<0), 'out of %d sources have mtot<0' % sspar[0].size)\n", + "print((sspar[idx])[sspar[idx]<0]/MPC)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.where())" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plots" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='hard_time'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()\n", + "# # set directory path\n", + "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", + "# save_dir=sam_loc+'/figures' " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# gsmf_phi0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='gsmf_phi0'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# gsmf_mchar0_log10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='gsmf_mchar0_log10'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## mmbulge_mamp_log10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='mmb_mamp_log10'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_scatter_dex" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='mmb_scatter_dex'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='hard_gamma_inner'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "\n", + "for ii in range(len(data)):\n", + " fig = plot_number_densities(data[ii])\n", + " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", + " fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 6bef305399991f12821b844366180efb238698c2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 16:30:53 -0700 Subject: [PATCH 105/291] Update detect_lib_scripy comments and mkdir for gamma_rho_grid --- holodeck/detstats.py | 4 ++++ scripts/detect_lib_script.py | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index b2ffd817..433cea8b 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1251,12 +1251,16 @@ def _gamma_ssi_cython(rho, grid_path): TODO: change grid save location to belong to some class or something? """ + Num = np.size(rho[:,0,0,:]) grid_name = grid_path+'/rho_gamma_interp_grid_Num%d.npz' % (Num) # check if interpolation grid already exists, if not, build it if os.path.exists(grid_name) is False: + # check if grid_path already exists, if not, makedir + if (os.path.exists(grid_path) is False): + os.makedirs(grid_path) _build_gamma_interp_grid(Num, grid_name) # read in data from saved grid diff --git a/scripts/detect_lib_script.py b/scripts/detect_lib_script.py index 682cec0c..8958d3b1 100644 --- a/scripts/detect_lib_script.py +++ b/scripts/detect_lib_script.py @@ -1,3 +1,30 @@ +"""Run detection statistics on a library of semi-analytic-models. + +Usage +----- + +python ./scripts/detect_lib_ss.py --grid_path -p --sigma -s + + : library directory that contains sam_lib.hdf5. + : directory containing gamma-rho interpolation grids. Will mkdir if it doesn't exist. + : pta duration in years, default 16.03 yr + : number of PTA pulsars to simulate, should be calibrated to data + : white noise sigma of PTA pulsars, should be calibrated to data + : number of sky realizations to generate for each single source strain realization + +Example: + + python ./scripts/detect_lib_ss.py /Users/emigardiner/GWs/output/2023-06-22_uniform-09b_n500_r100_f40_l10 \ + --grid_path /Users/emigardiner/GWs/holodeck/output/rho_gamma_grids -p 45 --sigma 1e-6 -s 25 + + +To-Do +----- +* mark output directories as incomplete until all runs have been finished. + Merged libraries from incomplete directories should also get some sort of flag! + +""" + import holodeck as holo import holodeck.detstats as ds @@ -45,7 +72,7 @@ def _setup_argparse(): parser.add_argument('--debug', action='store_true', default=False, help='print steps along the way') parser.add_argument('--snr_cython', action='store_true', default=DEF_SNR_CYTHON, - help='Use cython for ss snr clculations') + help='Use cython for ss snr calculations') parser.add_argument('--save_ssi', action='store_true', default=DEF_SAVE_SSI, help="Save 'gamma_ssi', the detprob of each single source.") From 6e8580fb7f4a956d4fb62870f284c646336e8ea5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 16:31:12 -0700 Subject: [PATCH 106/291] calibrate new 09B library PTA --- .../library_scripts/calibrate_pta_sam.ipynb | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb index 94960c57..32ab5290 100644 --- a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb +++ b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb @@ -36,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss56_redz_2023-05-30_uniform-07a_n1000_r500_f40'\n", + "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss62_09Bsmall_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", "filename = filepath+'/sam_lib.hdf5'\n", "ssfile = h5py.File(filename, 'r')\n", "print(list(ssfile.keys()))\n", @@ -73,7 +73,7 @@ "assert np.all(np.isclose(fobs_cents, fobs)), \"fobs arrays don't match!\"\n", "# print(fobs.shape, fobs_cents.shape)\n", "# print(fobs, '\\n', fobs_cents)\n", - "print(np.max(np.abs(fobs-fobs_cents)))\n" + "print('max dif:', np.max(np.abs(fobs-fobs_cents))*10**9, 'nHz')\n" ] }, { @@ -114,7 +114,7 @@ "fidx=1 # choose second bin\n", "hc_ref15_10yr = 11.2*10**-15 \n", "print(fobs[fidx]*YR)\n", - "nsort, fidx, hc_tt, hc_ref15 = detstats.rank_samples(hc_ss_all, hc_bg_all, fobs, fidx=1, \n", + "nsort, fidx, hc_ref15 = detstats.rank_samples(hc_ss_all, hc_bg_all, fobs, fidx=1, \n", " hc_ref=hc_ref15_10yr, ret_all=True)\n", "nn = nsort[0]\n", "print(nn, fobs[fidx]*YR, hc_ref15)" @@ -135,8 +135,8 @@ "outputs": [], "source": [ "# modify these until dp_bg = .5\n", - "npsrs=50\n", - "sigma=7.85e-6\n", + "npsrs=45\n", + "sigma=5.47e-6\n", "\n", "# build PTA\n", "phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", @@ -152,8 +152,22 @@ "metadata": {}, "outputs": [], "source": [ - "dp_bg = detstats.detect_bg_pta(psrs, fobs, cad, hc_bg_all[nn])\n", - "print(np.mean(dp_bg), np.median(dp_bg), np.std(dp_bg))" + "count = 20\n", + "mean_tot = 0\n", + "median_tot = 0\n", + "for ii in range(count):\n", + " # build PTA\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + " phi=phis, theta=thetas)\n", + " dp_bg = detstats.detect_bg_pta(psrs, fobs, cad, hc_bg_all[nn])\n", + " mean_tot+=np.mean(dp_bg)\n", + " median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", + "mean_tot /= count\n", + "median_tot /= count\n", + "print(mean_tot, median_tot)" ] }, { From 4304fb8384f5033f20d1f41b403e756c27354be4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 16:38:43 -0700 Subject: [PATCH 107/291] start demo for anisotropy methods --- .../an3B_redz_cy_py_dont_match.ipynb | 4 +- .../anisotropy/an3_anisotropy_methods.ipynb | 34 ++-- ecg-notebooks/anisotropy/an4_demo.ipynb | 176 ++++++++++++++++++ 3 files changed, 195 insertions(+), 19 deletions(-) create mode 100644 ecg-notebooks/anisotropy/an4_demo.ipynb diff --git a/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb b/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb index 38e74144..8bfea868 100644 --- a/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb +++ b/ecg-notebooks/anisotropy/an3B_redz_cy_py_dont_match.ipynb @@ -168,7 +168,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=(5,6,7))\n", + "sam = holo.sams.Semi_Analytic_Model(shape=(5,6,7))\n", "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", "vals = sam_model(sam, hard)\n", "\n", @@ -248,7 +248,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=20)\n", + "sam = holo.sams.Semi_Analytic_Model(shape=20)\n", "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", "vals = sam_model(sam, hard)\n", "\n", diff --git a/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb b/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb index 24daa107..568b7d36 100644 --- a/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb +++ b/ecg-notebooks/anisotropy/an3_anisotropy_methods.ipynb @@ -42,8 +42,8 @@ "fobs_orb_cents = fobs_gw_cents/2.0\n", "fobs_orb_edges = fobs_gw_edges/2.0\n", "\n", - "# sam = holo.sam.Semi_Analytic_Model()\n", - "sam_20 = holo.sam.Semi_Analytic_Model(shape=20) # faster version\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "sam_20 = holo.sams.Semi_Analytic_Model(shape=20) # faster version\n", "hard_FT20 = holo.hardening.Fixed_Time_2PL_SAM(sam_20, 3*GYR)\n", "\n", "def setup_calculate_all(sam, hard):\n", @@ -350,7 +350,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_40 = holo.sam.Semi_Analytic_Model(shape=40)\n", + "sam_40 = holo.sams.Semi_Analytic_Model(shape=40)\n", "hard_FT40 = holo.hardening.Fixed_Time_2PL_SAM(sam_40, 3*GYR)\n", "vals_FT40 = setup_calculate_all(sam_40, hard_FT40)" ] @@ -383,7 +383,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_full = holo.sam.Semi_Analytic_Model()\n", + "sam_full = holo.sams.Semi_Analytic_Model()\n", "hard_FTfull = holo.hardening.Fixed_Time_2PL_SAM(sam_full, 3*GYR)\n", "vals_FTfull = setup_calculate_all(sam_full, hard_FTfull)" ] @@ -561,7 +561,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sam.Semi_Analytic_Model(shape=10)\n", + "sam = holo.sams.Semi_Analytic_Model(shape=10)\n", "hard = holo.hardening.Hard_GW()\n", "print(sam._density)\n", "fobs_orb_cents = fobs_gw_cents/2.0\n", @@ -735,7 +735,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9181100 = holo.sam.Semi_Analytic_Model(shape=(91,81,100))\n", + "sam_9181100 = holo.sams.Semi_Analytic_Model(shape=(91,81,100))\n", "hard_FT9181100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181100, 3*GYR)\n", "fig_FTfull, vals_FTfull = compare_all_analytic_anis(sam_9181100, hard_FT9181100)" ] @@ -823,7 +823,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_60 = holo.sam.Semi_Analytic_Model(shape=60)\n", + "sam_60 = holo.sams.Semi_Analytic_Model(shape=60)\n", "hard_FT60 = holo.hardening.Fixed_Time_2PL_SAM(sam_60, 3*GYR)\n", "fig_FT60, vals_FT60 = compare_all_analytic_anis(sam_60, hard_FT60)" ] @@ -842,7 +842,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_70 = holo.sam.Semi_Analytic_Model(shape=70)\n", + "sam_70 = holo.sams.Semi_Analytic_Model(shape=70)\n", "hard_FT70 = holo.hardening.Fixed_Time_2PL_SAM(sam_70, 3*GYR)\n", "fig_FT70, vals_FT70 = compare_all_analytic_anis(sam_70, hard_FT70)" ] @@ -861,7 +861,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_80 = holo.sam.Semi_Analytic_Model(shape=80)\n", + "sam_80 = holo.sams.Semi_Analytic_Model(shape=80)\n", "hard_FT80 = holo.hardening.Fixed_Time_2PL_SAM(sam_80, 3*GYR)\n", "fig_FT80, vals_FT80 = compare_all_analytic_anis(sam_80, hard_FT80)" ] @@ -880,7 +880,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9080100 = holo.sam.Semi_Analytic_Model(shape=[90,80,100])\n", + "sam_9080100 = holo.sams.Semi_Analytic_Model(shape=[90,80,100])\n", "hard_FT9080100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9080100, 3*GYR)\n", "fig_FT9080100, vals_FT9080100 = compare_all_analytic_anis(sam_9080100, hard_FT9080100)" ] @@ -927,7 +927,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9181101 = holo.sam.Semi_Analytic_Model(shape=[91,81,101])\n", + "sam_9181101 = holo.sams.Semi_Analytic_Model(shape=[91,81,101])\n", "hard_FT9181101 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181101, 3*GYR)\n", "fig_FT9181101, vals_FT9181101 = compare_all_analytic_anis(sam_9181101, hard_FT9181101)" ] @@ -974,7 +974,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9180100 = holo.sam.Semi_Analytic_Model(shape=[91,80,100])\n", + "sam_9180100 = holo.sams.Semi_Analytic_Model(shape=[91,80,100])\n", "hard_FT9180100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9180100, 3*GYR)\n", "fig_FT9180100, vals_FT9180100 = compare_all_analytic_anis(sam_9180100, hard_FT9180100)" ] @@ -993,7 +993,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9081100 = holo.sam.Semi_Analytic_Model(shape=[90,81,100])\n", + "sam_9081100 = holo.sams.Semi_Analytic_Model(shape=[90,81,100])\n", "hard_FT9081100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9081100, 3*GYR)\n", "fig_FT9081100, vals_FT9180100 = compare_all_analytic_anis(sam_9081100, hard_FT9081100)" ] @@ -1012,7 +1012,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9080101 = holo.sam.Semi_Analytic_Model(shape=[90,80,101])\n", + "sam_9080101 = holo.sams.Semi_Analytic_Model(shape=[90,80,101])\n", "hard_FT9080101 = holo.hardening.Fixed_Time_2PL_SAM(sam_9080101, 3*GYR)\n", "fig_FT9080101, vals_FT9080101 = compare_all_analytic_anis(sam_9080101, hard_FT9080101)" ] @@ -1059,7 +1059,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9180101 = holo.sam.Semi_Analytic_Model(shape=[91,80,101])\n", + "sam_9180101 = holo.sams.Semi_Analytic_Model(shape=[91,80,101])\n", "hard_FT9180101 = holo.hardening.Fixed_Time_2PL_SAM(sam_9180101, 3*GYR)\n", "fig_FT9180101, vals_FT9180101 = compare_all_analytic_anis(sam_9180101, hard_FT9180101)" ] @@ -1106,7 +1106,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9181100 = holo.sam.Semi_Analytic_Model(shape=[91,81,100])\n", + "sam_9181100 = holo.sams.Semi_Analytic_Model(shape=[91,81,100])\n", "hard_FT9181100 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181100, 3*GYR)\n", "fig_FT9181100, vals_FT9181100 = compare_all_analytic_anis(sam_9181100, hard_FT9181100)" ] @@ -1153,7 +1153,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam_9181102 = holo.sam.Semi_Analytic_Model(shape=[91,81,102])\n", + "sam_9181102 = holo.sams.Semi_Analytic_Model(shape=[91,81,102])\n", "hard_FT9181102 = holo.hardening.Fixed_Time_2PL_SAM(sam_9181102, 3*GYR)\n", "fig_FT9181102, vals_FT9181102 = compare_all_analytic_anis(sam_9181102, hard_FT9181102)" ] diff --git a/ecg-notebooks/anisotropy/an4_demo.ipynb b/ecg-notebooks/anisotropy/an4_demo.ipynb new file mode 100644 index 00000000..2243bed4 --- /dev/null +++ b/ecg-notebooks/anisotropy/an4_demo.ipynb @@ -0,0 +1,176 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import h5py\n", + "import healpy as hp\n", + "import kalepy as kale\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "from holodeck import detstats, plot, utils\n", + "from holodeck.constants import YR, MSOL, GYR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE=20" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setup Example Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# get frequencies\n", + "dur = holo.librarian.DEF_PTA_DUR*YR\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur)\n", + "fobs_orb_cents = fobs_gw_cents/2\n", + "fobs_orb_edges = fobs_gw_edges/2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# build Semi-Analytic-Model\n", + "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE)\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "\n", + "# Evolve model to get final number densities & redshifts at bin edges\n", + "redz_final, dnum = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "redz_initl = np.array(sam.redz)[np.newaxis,np.newaxis,:,np.newaxis]\n", + "redz_prime = sam._redz_prime[...,np.newaxis]\n", + "print(f\"{redz_final.shape=}, {redz_prime.shape=}, {redz_initl.shape=}\")\n", + "\n", + "# calculate final number per bin at bin centers\n", + "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, dnum)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# calculate strain amplitudes\n", + "\n", + "# at bin centers\n", + "hs_cents_initl = anis.strain_amp_at_bin_centers_redz(edges, None)\n", + "hs_cents_prime = anis.strain_amp_at_bin_centers_redz(edges, redz_prime)\n", + "hs_cents_final = anis.strain_amp_at_bin_centers_redz(edges, redz_final) \n", + "print(f\"{hs_cents_initl.shape=}, {hs_cents_prime.shape=}, {hs_cents_final.shape=}\")\n", + "\n", + "# at bin edges\n", + "hs_edges_initl = anis.strain_amp_at_bin_edges_redz(edges, None)\n", + "hs_edges_prime = anis.strain_amp_at_bin_edges_redz(edges, redz_prime)\n", + "hs_edges_final = anis.strain_amp_at_bin_edges_redz(edges, redz_final) \n", + "print(f\"{hs_edges_initl.shape=}, {hs_edges_prime.shape=}, {hs_edges_final.shape=}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Cl's" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# from number and hs at bin centers\n", + "Cl_cents_initl, ... = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_initl)\n", + "Cl_cents_prime,... = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_prime)\n", + "Cl_cents_final,... = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_final)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.max(fobs_gw_cents))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(Cl_cents_final)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = anis.plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=True, sim=False, \n", + " analytic=True, Cl_analytic=Cl_cents_final)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From d48925ab2b1d1bf842ede1061cb545cdac9a1164 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 18:36:52 -0700 Subject: [PATCH 108/291] Make clean analytic anisotropy plots in anlt4_demo.ipynb, for all redshift and integration options. --- ecg-notebooks/anisotropy/an4_demo.ipynb | 176 --------- ecg-notebooks/anisotropy/anlt4_demo.ipynb | 427 ++++++++++++++++++++++ holodeck/anisotropy.py | 11 +- 3 files changed, 433 insertions(+), 181 deletions(-) delete mode 100644 ecg-notebooks/anisotropy/an4_demo.ipynb create mode 100644 ecg-notebooks/anisotropy/anlt4_demo.ipynb diff --git a/ecg-notebooks/anisotropy/an4_demo.ipynb b/ecg-notebooks/anisotropy/an4_demo.ipynb deleted file mode 100644 index 2243bed4..00000000 --- a/ecg-notebooks/anisotropy/an4_demo.ipynb +++ /dev/null @@ -1,176 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%reload_ext autoreload\n", - "%autoreload 2\n", - "from importlib import reload\n", - "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import h5py\n", - "import healpy as hp\n", - "import kalepy as kale\n", - "\n", - "import holodeck as holo\n", - "import holodeck.anisotropy as anis\n", - "from holodeck import detstats, plot, utils\n", - "from holodeck.constants import YR, MSOL, GYR" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "SHAPE=20" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Setup Example Model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# get frequencies\n", - "dur = holo.librarian.DEF_PTA_DUR*YR\n", - "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur)\n", - "fobs_orb_cents = fobs_gw_cents/2\n", - "fobs_orb_edges = fobs_gw_edges/2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# build Semi-Analytic-Model\n", - "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE)\n", - "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", - "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", - " hard_name = 'Fixed Time'\n", - "elif isinstance(hard, holo.hardening.Hard_GW):\n", - " hard_name = 'GW Only'\n", - "\n", - "# Evolve model to get final number densities & redshifts at bin edges\n", - "redz_final, dnum = holo.sam_cython.dynamic_binary_number_at_fobs(\n", - " fobs_orb_cents, sam, hard, holo.cosmo)\n", - "redz_initl = np.array(sam.redz)[np.newaxis,np.newaxis,:,np.newaxis]\n", - "redz_prime = sam._redz_prime[...,np.newaxis]\n", - "print(f\"{redz_final.shape=}, {redz_prime.shape=}, {redz_initl.shape=}\")\n", - "\n", - "# calculate final number per bin at bin centers\n", - "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", - "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, dnum)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# calculate strain amplitudes\n", - "\n", - "# at bin centers\n", - "hs_cents_initl = anis.strain_amp_at_bin_centers_redz(edges, None)\n", - "hs_cents_prime = anis.strain_amp_at_bin_centers_redz(edges, redz_prime)\n", - "hs_cents_final = anis.strain_amp_at_bin_centers_redz(edges, redz_final) \n", - "print(f\"{hs_cents_initl.shape=}, {hs_cents_prime.shape=}, {hs_cents_final.shape=}\")\n", - "\n", - "# at bin edges\n", - "hs_edges_initl = anis.strain_amp_at_bin_edges_redz(edges, None)\n", - "hs_edges_prime = anis.strain_amp_at_bin_edges_redz(edges, redz_prime)\n", - "hs_edges_final = anis.strain_amp_at_bin_edges_redz(edges, redz_final) \n", - "print(f\"{hs_edges_initl.shape=}, {hs_edges_prime.shape=}, {hs_edges_final.shape=}\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Calculate Cl's" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# from number and hs at bin centers\n", - "Cl_cents_initl, ... = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_initl)\n", - "Cl_cents_prime,... = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_prime)\n", - "Cl_cents_final,... = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_final)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.max(fobs_gw_cents))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(Cl_cents_final)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig = anis.plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=True, sim=False, \n", - " analytic=True, Cl_analytic=Cl_cents_final)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "holo310", - "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.10" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/ecg-notebooks/anisotropy/anlt4_demo.ipynb b/ecg-notebooks/anisotropy/anlt4_demo.ipynb new file mode 100644 index 00000000..160d4a71 --- /dev/null +++ b/ecg-notebooks/anisotropy/anlt4_demo.ipynb @@ -0,0 +1,427 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import h5py\n", + "import healpy as hp\n", + "import kalepy as kale\n", + "\n", + "import holodeck as holo\n", + "import holodeck.anisotropy as anis\n", + "from holodeck import detstats, plot, utils\n", + "from holodeck.constants import YR, MSOL, GYR\n", + "\n", + "from matplotlib.lines import Line2D" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE=(91,81,101)\n", + "SAVE=True" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Setup Example Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# get frequencies\n", + "dur = holo.librarian.DEF_PTA_DUR*YR\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur)\n", + "fobs_orb_cents = fobs_gw_cents/2\n", + "fobs_orb_edges = fobs_gw_edges/2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# build Semi-Analytic-Model\n", + "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE)\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = '%dGyr Fixed Time' % (hard._target_time/GYR)\n", + "elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + "print(hard_name)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# Evolve model to get final number densities & redshifts at bin edges\n", + "redz_final, dnum = holo.sam_cython.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo)\n", + "\n", + "# calculate final number per bin at bin centers\n", + "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + "number = holo.sam_cython.integrate_differential_number_3dx1d(edges, dnum)\n", + "intnum = np.floor(number)\n", + "\n", + "# format redz_prime and redz_initial for use like redz_final\n", + "redz_prime = sam._redz_prime[...,np.newaxis]\n", + "redz_initl = np.array(sam.redz)[np.newaxis,np.newaxis,:,np.newaxis]\n", + "mm = len(edges[0])\n", + "qq = len(edges[1])\n", + "zz = len(edges[2])\n", + "redz_initl = np.repeat(redz_initl, mm*qq).reshape(mm,qq,zz,1)\n", + "print(f\"{redz_final.shape=}, {redz_prime.shape=}, {redz_initl.shape=}\")\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# calculate strain amplitudes\n", + "\n", + "# at bin centers\n", + "hs_cents_initl = anis.strain_amp_at_bin_centers_redz(edges, None)\n", + "hs_cents_prime = anis.strain_amp_at_bin_centers_redz(edges, redz_prime)\n", + "hs_cents_final = anis.strain_amp_at_bin_centers_redz(edges, redz_final) \n", + "print(f\"{hs_cents_initl.shape=}, {hs_cents_prime.shape=}, {hs_cents_final.shape=}\")\n", + "\n", + "# at bin edges\n", + "hs_edges_initl = anis.strain_amp_at_bin_edges_redz(edges, None)\n", + "hs_edges_prime = anis.strain_amp_at_bin_edges_redz(edges, redz_prime)\n", + "hs_edges_final = anis.strain_amp_at_bin_edges_redz(edges, redz_final) \n", + "print(f\"{hs_edges_initl.shape=}, {hs_edges_prime.shape=}, {hs_edges_final.shape=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Cl's from Number (bin centers)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# from number and hs at bin centers\n", + "C0_cents_initl, Cl_cents_initl, = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_initl)\n", + "C0_cents_prime, Cl_cents_prime, = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_prime)\n", + "C0_cents_final, Cl_cents_final, = anis.Cl_analytic_from_num(fobs_orb_edges, number, hs_cents_final)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# from number and hs at bin centers\n", + "C0_floor_initl, Cl_floor_initl, = anis.Cl_analytic_from_num(fobs_orb_edges, intnum, hs_cents_initl)\n", + "C0_floor_prime, Cl_floor_prime, = anis.Cl_analytic_from_num(fobs_orb_edges, intnum, hs_cents_prime)\n", + "C0_floor_final, Cl_floor_final, = anis.Cl_analytic_from_num(fobs_orb_edges, intnum, hs_cents_final)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = anis.plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=False, sim=False)\n", + "ax = fig.axes[0]\n", + "ax.set_title('%s, shape=%s' % (hard_name, str(sam.shape)))\n", + "\n", + "anis.draw_bayes(ax, lmax=6, ms=4)\n", + "\n", + "\n", + "C0_cents = [C0_cents_initl, C0_cents_prime, C0_cents_final]\n", + "Cl_cents = [Cl_cents_initl, Cl_cents_prime, Cl_cents_final]\n", + "\n", + "C0_floor = [C0_floor_initl, C0_floor_prime, C0_floor_final]\n", + "Cl_floor = [Cl_floor_initl, Cl_floor_prime, Cl_floor_final]\n", + "\n", + "lw = [1,1.5,2]\n", + "colors = ['goldenrod', 'tab:orange', 'tab:red',]\n", + "labels = ['init', 'prime', 'final']\n", + "handles = []\n", + "for ii in range(3):\n", + " print(ii)\n", + " hh = anis.draw_analytic(ax, C0=C0_cents[ii],Cl=Cl_cents[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=labels[ii], ls='-.', color=colors[ii], lw=lw[ii])\n", + " anis.draw_analytic(ax, C0=C0_floor[ii],Cl=Cl_floor[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=None, ls=':', color=colors[ii], lw=lw[ii])\n", + " handles.append(hh)\n", + "leg = ax.legend(handles=handles, loc='lower left')\n", + "\n", + "leg_handles = [\n", + " Line2D([0], [0], label='SPK', ls='--', color='limegreen'),\n", + " Line2D([0], [0], label='upper lims', ls='-', marker='o', ms=4, color='k'),\n", + " Line2D([0], [0], label='cents number', ls='-.', color=colors[0]),\n", + " Line2D([0], [0], label='cents rounded', ls=':', color=colors[0])]\n", + "leg2 = ax.legend(handles=leg_handles, loc='lower right')\n", + "ax.add_artist(leg)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Cl's from dnum (bin edges)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "C0_edges_initl, Cl_edges_initl = anis.Cl_analytic_from_dnum(edges, dnum, redz_initl)\n", + "C0_edges_prime, Cl_edges_prime = anis.Cl_analytic_from_dnum(edges, dnum, redz_prime)\n", + "C0_edges_final, Cl_edges_final = anis.Cl_analytic_from_dnum(edges, dnum, redz_final)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = anis.plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=False, sim=False)\n", + "ax = fig.axes[0]\n", + "ax.set_title('%s, shape=%s' % (hard_name, str(sam.shape)))\n", + "\n", + "anis.draw_bayes(ax, lmax=6, ms=4, colors=['k', 'k', 'k', 'k', 'k', 'k'])\n", + "\n", + "Cl_edges = [Cl_edges_initl, Cl_edges_prime, Cl_edges_final]\n", + "C0_edges = [C0_edges_initl, C0_edges_prime, C0_edges_final]\n", + "\n", + "handles = []\n", + "for ii in range(3):\n", + " print(ii)\n", + " hh = anis.draw_analytic(ax, C0=C0_edges[ii], Cl=Cl_edges[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=labels[ii], ls='-', color=colors[ii], lw=lw[ii])\n", + " anis.draw_analytic(ax, C0=C0_floor[ii],Cl=Cl_floor[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=None, ls=':', color=colors[ii], lw=lw[ii])\n", + " anis.draw_analytic(ax, C0=C0_cents[ii],Cl=Cl_cents[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=labels[ii], ls='-.', color=colors[ii], lw=lw[ii])\n", + " handles.append(hh)\n", + "\n", + "leg1 = ax.legend(handles=handles, loc='lower left')\n", + "\n", + "leg_handles = [\n", + " Line2D([0], [0], label='edges dnum', ls='-', color=colors[-1]),\n", + " Line2D([0], [0], label='cents number', ls='-.', color=colors[-1]),\n", + " Line2D([0], [0], label='cents rounded', ls=':', color=colors[-1]),\n", + " Line2D([0], [0], label='SPK', ls='--', color='limegreen'),\n", + " Line2D([0], [0], label='bayes upper lims', ls='-', marker='o', ms=4, color='k'),\n", + "]\n", + "leg2 = ax.legend(handles=leg_handles, loc='lower right', ncols=2)\n", + "ax.add_artist(leg1)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Make sure that prime and initl aren't the exact same" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(Cl_edges_initl))\n", + "print(holo.utils.stats(Cl_edges_prime))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(Cl_cents_prime))\n", + "print(holo.utils.stats(Cl_cents_initl))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate Cl's from Random Realizations \n", + "(always cents)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "C0_reals_initl, Cl_reals_initl = anis.Cl_analytic_from_dnum(edges, dnum, redz_initl, realize=20)\n", + "print('one done')\n", + "C0_reals_prime, Cl_reals_prime = anis.Cl_analytic_from_dnum(edges, dnum, redz_prime, realize=20)\n", + "print('two done')\n", + "C0_reals_final, Cl_reals_final = anis.Cl_analytic_from_dnum(edges, dnum, redz_final, realize=20)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(C0_reals_initl.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = anis.plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=False, sim=False)\n", + "ax = fig.axes[0]\n", + "ax.set_title('%s, shape=%s' % (hard_name, str(sam.shape)))\n", + "\n", + "anis.draw_bayes(ax, lmax=6, ms=4, colors=['k', 'k', 'k', 'k', 'k', 'k'])\n", + "labels = ['z_initial', 'z_prime', 'z_final']\n", + "colors=['olive', '#ff4000', 'deeppink']\n", + "lw = [2, 2.5, 3]\n", + "\n", + "C0_reals = [C0_reals_initl, C0_reals_prime, C0_reals_final]\n", + "Cl_reals = [Cl_reals_initl, Cl_reals_prime, Cl_reals_final]\n", + "\n", + "handles = []\n", + "for ii in range(3):\n", + " print(ii)\n", + " hh = anis.draw_analytic(ax, C0=C0_edges[ii], Cl=Cl_edges[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=labels[ii], ls='-', color=colors[ii], lw=lw[ii], alpha=0.7)\n", + " anis.draw_analytic(ax, C0=C0_floor[ii],Cl=Cl_floor[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=None, ls='--', color=colors[ii], lw=lw[ii], alpha=0.5)\n", + " anis.draw_analytic(ax, C0=C0_cents[ii],Cl=Cl_cents[ii], fobs_gw_cents=fobs_gw_cents,\n", + " label=labels[ii], ls='-.', color=colors[ii], lw=lw[ii], alpha=0.7)\n", + " anis.draw_reals(ax, Cl_reals[ii], C0_reals[ii], fobs_gw_cents,\n", + " color=colors[ii], label=None, show_ci=True, show_reals=True, nshow=20)\n", + " handles.append(hh)\n", + "\n", + "leg1 = ax.legend(handles=handles, loc='lower right', bbox_to_anchor=(1,0.2))\n", + "\n", + "leg_handles = [\n", + " Line2D([0], [0], label='edges dnum', ls='-', color=colors[-1], alpha=0.7),\n", + " Line2D([0], [0], label='cents number', ls='-.', color=colors[-1], alpha=0.7),\n", + " Line2D([0], [0], label='cents rounded', ls='--', color=colors[-1], alpha=0.5),\n", + " Line2D([0], [0], label='realizations', ls=':', color=colors[-1], alpha=0.5),\n", + " Line2D([0], [0], label='SPK', ls='--', color='limegreen'),\n", + " Line2D([0], [0], label='bayes upper lims', ls='-', marker='o', ms=4, color='k'),\n", + "]\n", + "leg2 = ax.legend(handles=leg_handles, loc='lower right', ncols=2)\n", + "ax.add_artist(leg1)\n", + "\n", + "fig.tight_layout()\n", + "\n", + "if SAVE:\n", + "# if True:\n", + " fig_path = '/Users/emigardiner/GWs/holodeck/output/figures/anisotropy'\n", + " name = fig_path+f'/anlt_{hard._target_time/GYR}GyrFT_{sam.shape[0]}_{sam.shape[1]}_{sam.shape[2]}.png'\n", + " fig.savefig(name, bbox_inches='tight', dpi=100)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(redz_initl))\n", + "print(holo.utils.stats(redz_prime))\n", + "print(holo.utils.stats(redz_final))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(Cl_cents_final))\n", + "print(holo.utils.stats(Cl_cents_prime))\n", + "print(holo.utils.stats(Cl_cents_initl))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(Cl_floor_final))\n", + "print(holo.utils.stats(Cl_floor_prime))\n", + "print(holo.utils.stats(Cl_floor_initl))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/holodeck/anisotropy.py b/holodeck/anisotropy.py index e8dfd61e..6dc340c1 100644 --- a/holodeck/anisotropy.py +++ b/holodeck/anisotropy.py @@ -604,10 +604,11 @@ def Cl_analytic_from_dnum(edges, dnum, redz=None, realize=False): def draw_analytic(ax, Cl, C0, fobs_gw_cents, color='tab:orange', label='Eq. 17 analytic', - alpha=1, lw=2): + alpha=1, lw=2, ls='-.'): xx = fobs_gw_cents yy = Cl/C0 # (F,) - ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle='dashdot', alpha=alpha) + hh, = ax.plot(xx, yy, color=color, lw=lw, label=label, linestyle=ls, alpha=alpha) + return hh def draw_reals(ax, Cl_many, C0_many, fobs_gw_cents, color='tab:orange', label= 'Poisson number/bin realization', show_ci=False, show_reals=True, show_median=False, nshow=10, lw_median=2, ls_reals = ':'): @@ -632,7 +633,7 @@ def draw_spk(ax, label='SP & K Rough Estimate'): spk_yy= np.array([1*10**-5, 1*10**-3, 1*10**-1]) ax.plot(spk_xx * YR, spk_yy, label=label, color='limegreen', ls='--') -def draw_bayes(ax, lmax, colors = ['k', 'b', 'r', 'g', 'c', 'm']): +def draw_bayes(ax, lmax, colors = ['k', 'b', 'r', 'g', 'c', 'm'], ms=8): xx_nihan = np.array([2.0, 4.0, 5.9, 7.9, 9.9]) *10**-9 # Hz ClC0_nihan = np.array([ @@ -644,7 +645,7 @@ def draw_bayes(ax, lmax, colors = ['k', 'b', 'r', 'g', 'c', 'm']): for ll in range(lmax): ax.plot(xx_nihan, ClC0_nihan[:,ll], label = '$l=%d$' % (ll+1), - color=colors[ll], marker='o', ms=8) + color=colors[ll], marker='o', ms=ms) def draw_sim(ax, xx, Cl_best, lmax, nshow, show_ci=True, show_reals=True): @@ -684,7 +685,7 @@ def plot_ClC0_versions(fobs_gw_cents, spk=True, bayes=True, if sim and (Cl_best_sim is not None) and (lmax_sim is not None): draw_sim(ax, fobs_gw_cents, Cl_best_sim, lmax_sim, show_ci=True, show_reals=True, nshow=10) # ax.set_ylim(10**-6, 10**0) - plot._twin_yr(ax, nano=False) + # plot._twin_yr(ax, nano=False) ax.set_xlim(fobs_gw_cents[0]- 10**(-10), xmax) if legend: From 06875a747696204670ff3aaab0948cd57d874a93 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 18:37:50 -0700 Subject: [PATCH 109/291] Change shape --- ecg-notebooks/anisotropy/anlt4_demo.ipynb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ecg-notebooks/anisotropy/anlt4_demo.ipynb b/ecg-notebooks/anisotropy/anlt4_demo.ipynb index 160d4a71..9474916a 100644 --- a/ecg-notebooks/anisotropy/anlt4_demo.ipynb +++ b/ecg-notebooks/anisotropy/anlt4_demo.ipynb @@ -309,6 +309,14 @@ "print(C0_reals_initl.shape)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot and Save" + ] + }, { "cell_type": "code", "execution_count": null, From e765fbcc4da46a7b0f1e032de7d2c65a68322847 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 20:37:39 -0700 Subject: [PATCH 110/291] Plot marginalized and individual frequency vs. mass with log colorbars --- .../take9B_numberdensity_binned.ipynb | 142 ++++++++++++++++-- 1 file changed, 133 insertions(+), 9 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb index 94055564..da771d69 100644 --- a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb +++ b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb @@ -36,8 +36,21 @@ "metadata": {}, "outputs": [], "source": [ - "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss62_09Bsmall_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", - "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n" + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", + "\n", + "print(hdf.keys())\n", + "sample_params = hdf['sample_params'][...]\n", + "hc_ss = hdf['hc_ss'][...]\n", + "hc_bg = hdf['hc_bg'][...]\n", + "sspar = hdf['sspar'][...]\n", + "bgpar = hdf['bgpar'][...]\n", + "fobs_gw_cents = hdf['fobs'][:]\n", + "hdf.close()\n", + "\n", + "dur = 1/fobs_gw_cents[0]\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", + "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n" ] }, { @@ -46,8 +59,11 @@ "metadata": {}, "outputs": [], "source": [ - "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", - "print(npz.files)" + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz')\n", + "print(npz.files)\n", + "param_names = npz['param_names']\n", + "print(param_names)\n", + "npz.close()" ] }, { @@ -56,9 +72,7 @@ "metadata": {}, "outputs": [], "source": [ - "for item in npz:\n", - " print(item)\n", - " print(npz[item].shape)" + "print(sample_params[0])" ] }, { @@ -67,10 +81,110 @@ "metadata": {}, "outputs": [], "source": [ - "print(hdf.keys())\n", - "sample_params = hdf['sample_params']" + "ssfrq = np.repeat(fobs_gw_cents, nsamps*nreals*nloudest).reshape(nsamps, nfreqs, nreals, nloudest)\n", + "bgfrq = np.repeat(fobs_gw_cents, nsamps*nreals).reshape(nsamps, nfreqs, nreals)\n", + "print(f\"{ssfrq.shape=}, {sspar[:,0].shape=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Mass vs Frequency Marginalized Over Library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot/MSOL\n", + "ff_edges = fobs_gw_edges /10**9\n", + "\n", + "ssmtt = sspar[:,0,...].flatten()/MSOL\n", + "ssfrq = np.repeat(fobs_gw_cents, nsamps*nreals*nloudest)/10**9\n", + "print(f\"{ssmtt.shape=}, {ssfrq.shape=}\")\n", + "\n", + "hist, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))\n", + "print(f\"{ffe.shape=}, {mte.shape=}\")\n", + "\n", + "cmap = 'inferno'\n", + "fig, ax = plot.figax(xlabel='$M$ [M$_\\odot$]', ylabel = '$f$ [nHz]')\n", + "mtgrid, ffgrid = np.meshgrid(mt_edges, ff_edges)\n", + "print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + "ax.pcolormesh(mtgrid, ffgrid, np.log10(hist), cmap=cmap)\n", + "\n", + "ax.set_title('All Uniform 09B')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# For a single sample" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsort = holo.detstats.rank_samples(hc_ss, hc_bg, fobs_gw_cents, fidx=1,\n", + " )\n", + "print(nsort[:5])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "best = 499\n", + "for best in nsort[:10]:\n", + " ssmtt = sspar[best,0,...].flatten()/MSOL\n", + " ssfrq = np.repeat(fobs_gw_cents, nreals*nloudest)/10**9\n", + " print(f\"{ssmtt.shape=}, {ssfrq.shape=}\")\n", + "\n", + " hist, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))\n", + " print(f\"{ffe.shape=}, {mte.shape=}\")\n", + "\n", + " cmap = 'inferno'\n", + " fig, ax = plot.figax(xlabel='$M$ [M$_\\odot$]', ylabel = '$f$ [nHz]', figsize=(5,4))\n", + " mtgrid, ffgrid = np.meshgrid(mte, ffe)\n", + " print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist), cmap=cmap)\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$')\n", + "\n", + " ax.set_title(\n", + " 'sample %d:, $t_\\mathrm{hard}$=%.1fGyr, $\\gamma_\\mathrm{inner}$=%.1f, $\\Phi_0$=%.1f, '\n", + " % (best, sample_params[best,0], sample_params[best,-1], sample_params[best,1], ) \n", + " + '\\n$\\log M_\\mathrm{char,0}={%.1f}$, $\\log \\mu_\\mathrm{MMB}=%.1f$, $\\sigma_\\mathrm{MMB,dex}$=%.1f' \n", + " % (sample_params[best,2], sample_params[best,3], sample_params[best,4]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(hist.shape)\n", + "\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -78,9 +192,19 @@ "outputs": [], "source": [ "fobs = hdf['fobs']\n", + "dur = 1/fobs[0]\n", "print(1/fobs[0]/YR)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sspar = h" + ] + }, { "attachments": {}, "cell_type": "markdown", From 10f03a7e209c05510bacb0ed7a2d8f598380de21 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 21:23:02 -0700 Subject: [PATCH 111/291] Change colorbars to log and fix bin widths across all models. --- .../take9_numberdensity_mass_dist.ipynb | 106 +++++++++--------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb index 60206f44..c578d40b 100644 --- a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb +++ b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb @@ -30,6 +30,14 @@ "import anatomy as anat" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Data" + ] + }, { "cell_type": "code", "execution_count": null, @@ -81,35 +89,6 @@ "# Dev" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, axs = plot.figax(ncols=2, xlabel=['mtot', 'final dcom'], figsize=(8,3),\n", - " )\n", - "\n", - "idx = [0, 4]\n", - "\n", - "hist, bins, = np.histogram(sspar[idx[0]].flatten()/MSOL, )\n", - "plot.draw_hist_steps(axs[0], bins, hist)\n", - "\n", - "hist, bins, = np.histogram(sspar[idx[1]].flatten(), )\n", - "plot.draw_hist_steps(axs[1], bins, hist)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sings.par_units)\n", - "print(sings.par_labels)\n", - "print(1/MPC)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -142,15 +121,6 @@ "# Plotting function" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print([8,]+[*sspar.shape[1:]])" - ] - }, { "cell_type": "code", "execution_count": null, @@ -194,7 +164,39 @@ "metadata": {}, "outputs": [], "source": [ - "def draw_2D_hist(ax, xx, yy, nbins, cmap='viridis'):\n", + "print(sspar.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Edges" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mtot_edges = holo.sams.Semi_Analytic_Model().mtot \n", + "freq_edges = fobs_gw_edges\n", + "\n", + "dcom_min = np.min([np.nanmin(bgpar[4]), np.nanmin(sspar[4])])\n", + "dcom_max = np.max([np.nanmax(bgpar[4]), np.nanmax(sspar[4])])\n", + "print(f\"{dcom_min/MPC=}, {dcom_max/MPC=}\")\n", + "dcom_edges = np.geomspace(dcom_min, dcom_max, 30)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_2D_hist(ax, xx, yy, xx_edges, yy_edges, cmap='viridis'):\n", " xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", " yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", " # print(f\"{holo.utils.stats(yy_edges)=}\")\n", @@ -203,11 +205,13 @@ "\n", " xgrid, ygrid = np.meshgrid(xx_edges, yy_edges)\n", " # print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", - " ax.pcolormesh(xgrid, ygrid, hist, cmap=cmap)\n", + " im = ax.pcolormesh(xgrid, ygrid, np.log10(hist), cmap=cmap)\n", + " cbar = plt.colorbar(im, ax=ax)\n", "\n", "def plot_number_densities(data, xx_idx = [0], yy_idx=[4,7], nbins=25, \n", - " ylim0=(5*10**1, 5*10**3), ylim1=(5*10**-2, 4E0),\n", - " xlim = (2*10**7, 10**11)):\n", + " ylim0=None, ylim1=None, xlim=None):\n", + " # ylim0=(5*10**1, 5*10**3), ylim1=(5*10**-2, 4E0),\n", + " # xlim = (2*10**7, 10**11)):\n", " \n", " # add frequencies to par arrays\n", " pardat = _append_freqs_to_pars(data)\n", @@ -223,6 +227,9 @@ " xlabel = par_labels[xx_idx]\n", " ylabel = par_labels[yy_idx]\n", "\n", + " xx_edges = mtot_edges\n", + " yy_edges = [dcom_edges, freq_edges]\n", + "\n", " fig, axs = plot.figax_double(nrows=nrows, ncols=ncols, \n", " sharex=True, figsize=(7,6))\n", " axs[0,0].set_title('$h_c^2$-weighted background', fontsize=10)\n", @@ -233,6 +240,7 @@ " if ylim1 is not None: axs[1,0].set_ylim(ylim1)\n", " for ii,ax in enumerate(axs[1,:]):\n", " ax.set_xlabel(xlabel[0], fontsize=10)\n", + " if xlim is not None: ax.set_xlim(xlim)\n", " for ii,ax in enumerate(axs[:,1]):\n", " ax.sharey(axs[ii,0])\n", "\n", @@ -240,14 +248,15 @@ " xx = (bgpar[xx_idx]*par_units[xx_idx])\n", " for ii, yy in enumerate(bgpar[yy_idx]):\n", " yy = yy*par_units[yy_idx[ii]]\n", - " draw_2D_hist(axs[ii,0], xx, yy, nbins)\n", + " draw_2D_hist(axs[ii,0], xx, yy, xx_edges = xx_edges, yy_edges=yy_edges[ii])\n", "\n", " # draw single sources\n", " xx = (sspar[xx_idx]*par_units[xx_idx])\n", " for ii, yy in enumerate(sspar[yy_idx]):\n", " yy = yy*par_units[yy_idx[ii]]\n", " yy[yy<0] = np.min(yy[yy>0]) # patch\n", - " draw_2D_hist(axs[ii,1], xx, yy, nbins, 'inferno')\n", + " draw_2D_hist(axs[ii,1], xx, yy, \n", + " xx_edges = xx_edges, yy_edges=yy_edges[ii], cmap='inferno')\n", "\n", " fig.tight_layout()\n", " return fig\n", @@ -300,15 +309,6 @@ "print((sspar[idx])[sspar[idx]<0]/MPC)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.where())" - ] - }, { "attachments": {}, "cell_type": "markdown", From 74c407cddfb2c7f5e02b9bdd7b410c8efb75c5a5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 21:41:40 -0700 Subject: [PATCH 112/291] Make number density plots for ss and bg, individual samples and entire library --- .../take9B_numberdensity_binned.ipynb | 521 ++---------------- 1 file changed, 51 insertions(+), 470 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb index da771d69..88e2bd3d 100644 --- a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb +++ b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb @@ -59,10 +59,14 @@ "metadata": {}, "outputs": [], "source": [ - "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz')\n", + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", "print(npz.files)\n", "param_names = npz['param_names']\n", "print(param_names)\n", + "print(npz['class_name'])\n", + "lib_name = '%s v%s' % (npz['class_name'], npz['librarian_version'])\n", + "print(lib_name)\n", + "# print(npz['sam_shape'])\n", "npz.close()" ] }, @@ -145,398 +149,50 @@ "metadata": {}, "outputs": [], "source": [ - "best = 499\n", - "for best in nsort[:10]:\n", - " ssmtt = sspar[best,0,...].flatten()/MSOL\n", - " ssfrq = np.repeat(fobs_gw_cents, nreals*nloudest)/10**9\n", - " print(f\"{ssmtt.shape=}, {ssfrq.shape=}\")\n", + "def plot_best_index(best):\n", + " if best is None:\n", + " ssmtt = sspar[:,0,...].flatten()/MSOL\n", + " ssfrq = np.repeat(fobs_gw_cents, nsamps*nreals*nloudest)/10**9\n", "\n", - " hist, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))\n", - " print(f\"{ffe.shape=}, {mte.shape=}\")\n", + " bgmtt = bgpar[:,0,...].flatten()/MSOL\n", + " bgfrq = np.repeat(fobs_gw_cents, nsamps*nreals)/10**9\n", + " else:\n", + " ssmtt = sspar[best,0,...].flatten()/MSOL\n", + " ssfrq = np.repeat(fobs_gw_cents, nreals*nloudest)/10**9\n", "\n", - " cmap = 'inferno'\n", - " fig, ax = plot.figax(xlabel='$M$ [M$_\\odot$]', ylabel = '$f$ [nHz]', figsize=(5,4))\n", - " mtgrid, ffgrid = np.meshgrid(mte, ffe)\n", - " print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", - " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist), cmap=cmap)\n", - " cbar = plt.colorbar(im, ax=ax, label='$\\log N$')\n", - "\n", - " ax.set_title(\n", - " 'sample %d:, $t_\\mathrm{hard}$=%.1fGyr, $\\gamma_\\mathrm{inner}$=%.1f, $\\Phi_0$=%.1f, '\n", - " % (best, sample_params[best,0], sample_params[best,-1], sample_params[best,1], ) \n", - " + '\\n$\\log M_\\mathrm{char,0}={%.1f}$, $\\log \\mu_\\mathrm{MMB}=%.1f$, $\\sigma_\\mathrm{MMB,dex}$=%.1f' \n", - " % (sample_params[best,2], sample_params[best,3], sample_params[best,4]))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(hist.shape)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fobs = hdf['fobs']\n", - "dur = 1/fobs[0]\n", - "print(1/fobs[0]/YR)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sspar = h" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Old below here" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# use one file to get the shape\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/hard_time_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz',\n", - " allow_pickle=True) \n", - "print(f\"{npz.files=}\")\n", - "data = npz['data']\n", - "print(f\"{data[0].keys()=}\")\n", - "\n", - "# params = npz['params']\n", - "# hard_name = npz['hard_name']\n", - "shape = npz['shape']\n", - "print(f\"{shape=}\")\n", - "# target_param = npz['target_param']\n", - "fobs_gw_cents = npz['data'][0]['fobs_cents']\n", - "fobs_gw_edges = npz['data'][0]['fobs_edges']\n", - "\n", - "npz.close()\n", - "\n", - "# get param names\n", - "pspace = holo.param_spaces.PS_Uniform_09A(holo.log, nsamples=1, sam_shape=shape, seed=None)\n", - "param_names = pspace.param_names\n", - "print(f\"{param_names=}\")\n", - "\n", - "\n", - "hc_ss = data[1]['hc_ss']\n", - "hc_bg = data[1]['hc_bg']\n", - "bgpar = data[1]['bgpar']\n", - "sspar = data[1]['sspar']\n", - "sspar = sings.all_sspars(fobs_gw_cents=fobs_gw_cents, sspar=sspar)\n", - "print(f\"{sings.par_names=}\")\n", - "nfreqs, nreals, nloudest = [*hc_ss.shape]\n", - "print(f\"{nfreqs=}, {nreals=}, {nloudest=},\")\n", - "\n", - "# # set directory path\n", - "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - "# save_dir=sam_loc+'/figures' " - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Dev" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, axs = plot.figax(ncols=2, xlabel=['mtot', 'final dcom'], figsize=(8,3),\n", - " )\n", - "\n", - "idx = [0, 4]\n", - "\n", - "hist, bins, = np.histogram(sspar[idx[0]].flatten()/MSOL, )\n", - "plot.draw_hist_steps(axs[0], bins, hist)\n", - "\n", - "hist, bins, = np.histogram(sspar[idx[1]].flatten(), )\n", - "plot.draw_hist_steps(axs[1], bins, hist)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sings.par_units)\n", - "print(sings.par_labels)\n", - "print(1/MPC)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "mtot = bgpar[0].flatten()/MSOL\n", - "dcom = bgpar[np.where(sings.par_names=='dcom_final')].flatten()/MPC\n", - "\n", - "nbins=30\n", - "mt_edges = np.logspace(np.log10(np.nanmin(mtot)), np.log10(np.nanmax(mtot)), nbins)\n", - "print(np.min(mtot), np.max(mtot))\n", - "print(mt_edges)\n", - "dc_edges = np.logspace(np.log10(np.min(dcom)), np.log10(np.max(dcom)), nbins)\n", - "hist, mtbins, dcbins = np.histogram2d(mtot, dcom, bins=(mt_edges, dc_edges))\n", - "\n", - "MT, DC = np.meshgrid(mtbins, dcbins)\n", - "\n", - "fig, ax = plot.figax(xlabel=sings.par_labels[0],\n", - " ylabel=sings.par_labels[4])\n", - "ax.pcolormesh(MT, DC, hist)\n", - "fig.tight_layout()" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Plotting function" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print([8,]+[*sspar.shape[1:]])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def _append_freqs_to_pars(data=data[1], debug=False, short_labels=True):\n", - " hc_ss=data['hc_ss']\n", - " hc_bg=data['hc_bg']\n", - "\n", - " sspar = data['sspar']\n", - " sspar = sings.all_sspars(fobs_gw_cents, sspar)\n", - " # sspar[sspar<0]=0\n", - " bgpar = data['bgpar']\n", - "\n", - "\n", - " # Add frequency to pars\n", - " _freqs = np.repeat(fobs_gw_cents, hc_ss[0].size).reshape(hc_ss.shape)\n", - " sspar = np.append(sspar, _freqs).reshape([8,]+[*sspar.shape[1:]])\n", - " _freqs = np.repeat(fobs_gw_cents, hc_bg[0].size).reshape(hc_bg.shape)\n", - " bgpar = np.append(bgpar, _freqs).reshape([8,]+[*bgpar.shape[1:]])\n", - "\n", - " par_names = np.append(sings.par_names, 'freqs')\n", - " par_units = np.append(sings.par_units, YR)\n", - " par_labels = np.append(sings.par_labels, 'GW Frequency $f_\\mathrm{obs}\\ \\mathrm{yr}^{-1}$')\n", - "\n", - " if short_labels:\n", - " par_labels[4] = '$d_\\mathrm{com}$ (Mpc)'\n", - " par_labels[7] = 'GW$ f_\\mathrm{obs}$ (nHz)'\n", - "\n", - " if debug: print(f\"{par_names=}\\n{par_units=}\\n{par_labels=}\")\n", + " bgmtt = bgpar[best,0,...].flatten()/MSOL\n", + " bgfrq = np.repeat(fobs_gw_cents, nreals)/10**9\n", + " # print(f\"{ssmtt.shape=}, {ssfrq.shape=}\")\n", "\n", - " pardat= dict(sspar=sspar, bgpar=bgpar, par_names=par_names, par_units=par_units, par_labels=par_labels)\n", - "\n", - " return pardat" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def draw_2D_hist(ax, xx, yy, nbins, cmap='viridis'):\n", - " xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", - " yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", - " # print(f\"{holo.utils.stats(yy_edges)=}\")\n", - " hist, yy_edges, xx_edges, = np.histogram2d(yy.flatten(), xx.flatten(), bins = (yy_edges, xx_edges))\n", - " # print(f\"{holo.utils.stats(xx_edges)=}, {holo.utils.stats(yy_edges)=}\")\n", - "\n", - " xgrid, ygrid = np.meshgrid(xx_edges, yy_edges)\n", - " # print(f\"{holo.utils.stats(xgrid)=}, {holo.utils.stats(ygrid)=}\")\n", - " ax.pcolormesh(xgrid, ygrid, hist, cmap=cmap)\n", - "\n", - "def plot_number_densities(data, xx_idx = [0], yy_idx=[4,7], nbins=25, \n", - " ylim0=(5*10**1, 5*10**3), ylim1=(5*10**-2, 4E0),\n", - " xlim = (2*10**7, 10**11)):\n", + " hist_ss, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))\n", + " hist_bg, ffe, mte, = np.histogram2d(bgfrq, bgmtt, bins=(ff_edges, mt_edges))\n", " \n", - " # add frequencies to par arrays\n", - " pardat = _append_freqs_to_pars(data)\n", - " par_names=pardat['par_names']\n", - " par_units=pardat['par_units']\n", - " par_labels=pardat['par_labels']\n", - " sspar=pardat['sspar']\n", - " bgpar=pardat['bgpar']\n", - "\n", - " ncols = 2\n", - " nrows = len(yy_idx)\n", - "\n", - " xlabel = par_labels[xx_idx]\n", - " ylabel = par_labels[yy_idx]\n", - "\n", - " fig, axs = plot.figax_double(nrows=nrows, ncols=ncols, \n", - " sharex=True, figsize=(7,6))\n", - " axs[0,0].set_title('$h_c^2$-weighted background', fontsize=10)\n", - " axs[0,1].set_title('single sources', fontsize=10)\n", - " axs[0,0].set_ylabel(ylabel[0], fontsize=10)\n", - " axs[1,0].set_ylabel(ylabel[1], fontsize=10)\n", - " if ylim0 is not None: axs[0,0].set_ylim(ylim0)\n", - " if ylim1 is not None: axs[1,0].set_ylim(ylim1)\n", - " for ii,ax in enumerate(axs[1,:]):\n", - " ax.set_xlabel(xlabel[0], fontsize=10)\n", - " for ii,ax in enumerate(axs[:,1]):\n", - " ax.sharey(axs[ii,0])\n", - "\n", - " # draw background\n", - " xx = (bgpar[xx_idx]*par_units[xx_idx])\n", - " for ii, yy in enumerate(bgpar[yy_idx]):\n", - " yy = yy*par_units[yy_idx[ii]]\n", - " draw_2D_hist(axs[ii,0], xx, yy, nbins)\n", - "\n", - " # draw single sources\n", - " xx = (sspar[xx_idx]*par_units[xx_idx])\n", - " for ii, yy in enumerate(sspar[yy_idx]):\n", - " yy = yy*par_units[yy_idx[ii]]\n", - " yy[yy<0] = np.min(yy[yy>0]) # patch\n", - " draw_2D_hist(axs[ii,1], xx, yy, nbins, 'inferno')\n", + " # print(f\"{ffe.shape=}, {mte.shape=}\")\n", "\n", - " fig.tight_layout()\n", - " return fig\n", - "\n", - "fig = plot_number_densities(data[1])" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem with negative final comoving distances and redshifts" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "\n", - "idx = np.where(sings.par_names=='redz_final')\n", - "print(np.sum(sspar[idx]<0), 'out of %d sources have z_final<0' % sspar[0].size)\n", - "print((sspar[idx])[sspar[idx]<0])\n", + " fig, axs = plot.figax(ncols=2, xlabel='$M$ [M$_\\odot$]', ylabel = '$f$ [nHz]', figsize=(8,4))\n", + " mtgrid, ffgrid = np.meshgrid(mte, ffe)\n", + " # print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", "\n", - "idx = np.where(sings.par_names=='dcom_final')\n", - "print(np.sum(sspar[idx]<0), 'out of %d sources have dcom_final<0' % sspar[0].size)\n", - "print((sspar[idx])[sspar[idx]<0]/MPC)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(holo.utils.stats(sspar[idx]/MPC))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "idx = np.where(sings.par_names=='mtot')\n", - "print(np.sum(sspar[idx]<0), 'out of %d sources have mtot<0' % sspar[0].size)\n", - "print((sspar[idx])[sspar[idx]<0]/MPC)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.where())" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Plots" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# hard_time" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "TARGET='hard_time'\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", - " % TARGET, allow_pickle=True) \n", - "data = npz['data']\n", - "params = npz['params']\n", - "npz.close()\n", + " ax = axs[0]\n", + " ax.set_title('$h_c^2$-weighted Background')\n", + " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist_bg), cmap='viridis')\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", + " ax = axs[1]\n", + " ax.set_title('Single Sources')\n", + " ax.set_ylabel(None)\n", + " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist_ss), cmap='inferno')\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", - "for ii in range(len(data)):\n", - " fig = plot_number_densities(data[ii])\n", - " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", - " fig.tight_layout()\n", - "# # set directory path\n", - "# sam_loc = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/'\n", - "# save_dir=sam_loc+'/figures' " - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# gsmf_phi0" + " if best is None:\n", + " fig.suptitle(lib_name)\n", + " else:\n", + " fig.suptitle(\n", + " 'sample %d:, $t_\\mathrm{hard}$=%.1fGyr, $\\gamma_\\mathrm{inner}$=%.1f, $\\Phi_0$=%.1f, '\n", + " % (best, sample_params[best,0], sample_params[best,-1], sample_params[best,1], ) \n", + " + '$\\log M_\\mathrm{char,0}={%.1f}$, $\\log \\mu_\\mathrm{MMB}=%.1f$, $\\sigma_\\mathrm{MMB,dex}$=%.1f' \n", + " % (sample_params[best,2], sample_params[best,3], sample_params[best,4]))\n", + " fig.tight_layout()" ] }, { @@ -545,18 +201,8 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET='gsmf_phi0'\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", - " % TARGET, allow_pickle=True) \n", - "data = npz['data']\n", - "params = npz['params']\n", - "npz.close()\n", - "\n", - "\n", - "for ii in range(len(data)):\n", - " fig = plot_number_densities(data[ii])\n", - " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", - " fig.tight_layout()" + "for best in nsort[:5]:\n", + " plot_best_index(best)" ] }, { @@ -564,7 +210,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# gsmf_mchar0_log10" + "# Marginalized" ] }, { @@ -573,18 +219,7 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET='gsmf_mchar0_log10'\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", - " % TARGET, allow_pickle=True) \n", - "data = npz['data']\n", - "params = npz['params']\n", - "npz.close()\n", - "\n", - "\n", - "for ii in range(len(data)):\n", - " fig = plot_number_densities(data[ii])\n", - " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", - " fig.tight_layout()" + "plot_best_index(None)" ] }, { @@ -592,7 +227,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## mmbulge_mamp_log10" + "# Individual Frequency" ] }, { @@ -601,26 +236,7 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET='mmb_mamp_log10'\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", - " % TARGET, allow_pickle=True) \n", - "data = npz['data']\n", - "params = npz['params']\n", - "npz.close()\n", - "\n", - "\n", - "for ii in range(len(data)):\n", - " fig = plot_number_densities(data[ii])\n", - " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", - " fig.tight_layout()" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# mmb_scatter_dex" + "hist_ss, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))" ] }, { @@ -629,26 +245,9 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET='mmb_scatter_dex'\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", - " % TARGET, allow_pickle=True) \n", - "data = npz['data']\n", - "params = npz['params']\n", - "npz.close()\n", - "\n", - "\n", - "for ii in range(len(data)):\n", - " fig = plot_number_densities(data[ii])\n", - " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", - " fig.tight_layout()" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# hard_gamma_inner" + "fobs = hdf['fobs']\n", + "dur = 1/fobs[0]\n", + "print(1/fobs[0]/YR)" ] }, { @@ -657,26 +256,8 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET='hard_gamma_inner'\n", - "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", - " % TARGET, allow_pickle=True) \n", - "data = npz['data']\n", - "params = npz['params']\n", - "npz.close()\n", - "\n", - "\n", - "for ii in range(len(data)):\n", - " fig = plot_number_densities(data[ii])\n", - " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", - " fig.tight_layout()" + "sspar = h" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 1c01d1b4db5a0e8011111318aa611437a51bdde4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 22:14:58 -0700 Subject: [PATCH 113/291] Comment out a print statement --- holodeck/detstats.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 433cea8b..040a2186 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1740,7 +1740,7 @@ def expval_of_ss(gamma_ssi,): Expected number of single source detection (dp_ss>thresh) averaged across all strain and sky realizations. """ - print(f"{gamma_ssi.shape=}, {[*gamma_ssi.shape]}") + # print(f"{gamma_ssi.shape=}, {[*gamma_ssi.shape]}") nfreqs, nreals, nskies, nloudest = [*gamma_ssi.shape] ev_ss = np.sum(gamma_ssi)/(nreals*nskies) return ev_ss @@ -1878,7 +1878,7 @@ def amp_to_hc(amp_ref, fobs, dfobs): hc = amp_ref*np.sqrt(fobs/dfobs) return hc -def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref=None, ret_all = False): +def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref=HC_REF15_10YR, ret_all = False): """ Sort samples by those with f=1/yr char strains closest to some reference value. Parameters @@ -1913,10 +1913,6 @@ def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref if fidx is None: fidx = (np.abs(fobs - 1/(10*YR))).argmin() - if (hc_ref is None): - # find reference (e.g. 12.5 yr) char strain - hc_ref = amp_to_hc(amp_ref, fobs[fidx], dfobs[fidx]) - # extrapolate hc_ref at freq closest to 1/10yr from 1/10yr ref hc_ref = hc_ref * (fobs[fidx]*YR/.1)**(-2/3) @@ -1924,9 +1920,7 @@ def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref # select 1/yr median strains of samples hc_tt = np.sqrt(hc_bg[:,fidx,:]**2 + np.sum(hc_ss[:,fidx,:,:]**2, axis=-1)) # (N,R) hc_diff = np.abs(hc_tt - hc_ref) # (N,R) - print('hc_diff', hc_diff.shape) hc_diff = np.median(hc_diff, axis=-1) # median of differences (N,) - print('hc_diff', hc_diff.shape) # sort by closest nsort = np.argsort(hc_diff) From fea8ea0ef168c77f6511963759595671dab199e3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 22:31:08 -0700 Subject: [PATCH 114/291] Add some corrected freq vs mass plots to take9_numberdensity_mass_dist.ipynb. --- .../take9_numberdensity_mass_dist.ipynb | 89 +++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb index c578d40b..c597d3f6 100644 --- a/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb +++ b/ecg-notebooks/parameter_investigation/take9_numberdensity_mass_dist.ipynb @@ -181,13 +181,14 @@ "metadata": {}, "outputs": [], "source": [ - "mtot_edges = holo.sams.Semi_Analytic_Model().mtot \n", - "freq_edges = fobs_gw_edges\n", + "mtot_edges = holo.sams.Semi_Analytic_Model().mtot /MSOL\n", + "freq_edges = fobs_gw_edges*10**9\n", + "print(freq_edges)\n", "\n", "dcom_min = np.min([np.nanmin(bgpar[4]), np.nanmin(sspar[4])])\n", "dcom_max = np.max([np.nanmax(bgpar[4]), np.nanmax(sspar[4])])\n", "print(f\"{dcom_min/MPC=}, {dcom_max/MPC=}\")\n", - "dcom_edges = np.geomspace(dcom_min, dcom_max, 30)" + "dcom_edges = np.geomspace(dcom_min, dcom_max, 30)/MPC" ] }, { @@ -197,8 +198,8 @@ "outputs": [], "source": [ "def draw_2D_hist(ax, xx, yy, xx_edges, yy_edges, cmap='viridis'):\n", - " xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", - " yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", + " # xx_edges = np.logspace(np.log10(np.nanmin(xx)), np.log10(np.nanmax(xx)), nbins)\n", + " # yy_edges = np.logspace(np.log10(np.nanmin(yy)), np.log10(np.nanmax(yy)), nbins)\n", " # print(f\"{holo.utils.stats(yy_edges)=}\")\n", " hist, yy_edges, xx_edges, = np.histogram2d(yy.flatten(), xx.flatten(), bins = (yy_edges, xx_edges))\n", " # print(f\"{holo.utils.stats(xx_edges)=}, {holo.utils.stats(yy_edges)=}\")\n", @@ -340,6 +341,7 @@ "\n", "\n", "for ii in range(len(data)):\n", + " plot_mass_freq(data[ii])\n", " fig = plot_number_densities(data[ii])\n", " fig.suptitle('%s = %.2e' % (TARGET, params[ii][TARGET]), fontsize=10)\n", " fig.tight_layout()\n", @@ -488,6 +490,83 @@ " fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Just the Mass vs Frequency" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET='hard_time'\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_uniform09A_fullshape/%s_p0.5_0.5_0.5_0.5_0.5_0.5_s91_81_101.npz' \n", + " % TARGET, allow_pickle=True) \n", + "data = npz['data']\n", + "params = npz['params']\n", + "npz.close()\n", + "\n", + "def plot_mass_freq(data=data[1]):\n", + " # get edges\n", + " ff_edges=data['fobs_edges']/10**9\n", + " mt_edges=holo.sams.Semi_Analytic_Model().mtot /MSOL\n", + "\n", + " # get masses and frequencies\n", + " sspar = data['sspar']\n", + " bgpar = data['bgpar']\n", + " sspar = sings.all_sspars(fobs_gw_cents, sspar)\n", + " print(np.sum(sspar[3]<0))\n", + "\n", + " ssmtt = sspar[0,...].flatten()/MSOL\n", + " ssfrq = np.repeat(fobs_gw_cents, nreals*nloudest)/10**9\n", + "\n", + " bgmtt = bgpar[0,...].flatten()/MSOL\n", + " bgfrq = np.repeat(fobs_gw_cents, nreals)/10**9\n", + "\n", + " # calculate histograms\n", + " hist_ss, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))\n", + " hist_bg, ffe, mte, = np.histogram2d(bgfrq, bgmtt, bins=(ff_edges, mt_edges))\n", + "\n", + " # plot\n", + " fig, axs = plot.figax(ncols=2, xlabel='$M$ [M$_\\odot$]', ylabel = '$f$ [nHz]', figsize=(8,4))\n", + " mtgrid, ffgrid = np.meshgrid(mte, ffe)\n", + "\n", + " ax = axs[0]\n", + " ax.set_title('$h_c^2$-weighted Background')\n", + " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist_bg), cmap='viridis')\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + " ax = axs[1]\n", + " ax.set_title('Single Sources')\n", + " ax.set_ylabel(None)\n", + " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist_ss), cmap='inferno')\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + "plot_mass_freq(data[1])\n", + "\n", + "# if best is None:\n", + "# fig.suptitle(lib_name)\n", + "# else:\n", + "# fig.suptitle(\n", + "# 'sample %d:, $t_\\mathrm{hard}$=%.1fGyr, $\\gamma_\\mathrm{inner}$=%.1f, $\\Phi_0$=%.1f, '\n", + "# % (best, sample_params[best,0], sample_params[best,-1], sample_params[best,1], ) \n", + "# + '$\\log M_\\mathrm{char,0}={%.1f}$, $\\log \\mu_\\mathrm{MMB}=%.1f$, $\\sigma_\\mathrm{MMB,dex}$=%.1f' \n", + "# % (sample_params[best,2], sample_params[best,3], sample_params[best,4]))\n", + "# fig.tight_layout()" + ] + }, { "cell_type": "code", "execution_count": null, From 4139562cd7b301062b21491cd76872f375618c2f Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 22:31:56 -0700 Subject: [PATCH 115/291] Add save npz to calibrate_pta_sam.ipynb. --- .../library_scripts/calibrate_pta_sam.ipynb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb index 32ab5290..9112a8e1 100644 --- a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb +++ b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb @@ -36,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss62_09Bsmall_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", "filename = filepath+'/sam_lib.hdf5'\n", "ssfile = h5py.File(filename, 'r')\n", "print(list(ssfile.keys()))\n", @@ -136,7 +136,7 @@ "source": [ "# modify these until dp_bg = .5\n", "npsrs=45\n", - "sigma=5.47e-6\n", + "sigma=7.85e-6\n", "\n", "# build PTA\n", "phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", @@ -175,7 +175,10 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "filename = filepath+'/calibrated_pta.npz'\n", + "np.savez(filename, npsrs=npsrs, sigma=sigma)" + ] }, { "cell_type": "code", From e3afdb7c8a26dc4ee7cf7b9444688674491e71ae Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 22:32:35 -0700 Subject: [PATCH 116/291] Set dcom_final<0 to np.nan is single_sources.all_sspars() --- holodeck/single_sources.py | 1 + 1 file changed, 1 insertion(+) diff --git a/holodeck/single_sources.py b/holodeck/single_sources.py index e9feacf5..e7ad89f2 100644 --- a/holodeck/single_sources.py +++ b/holodeck/single_sources.py @@ -844,6 +844,7 @@ def all_sspars(fobs_gw_cents, sspar): redz_init = sspar[2,:,:] # (F,R,L) dimensionless redz_final = sspar[3,:,:] # (F,R,L) dimensionless dcom_final = holo.cosmo.comoving_distance(redz_final).to('cm').value # (F,R,L) in cm + dcom_final[dcom_final<0] = np.nan fobs_orb_cents = fobs_gw_cents/2.0 # (F,) frst_orb_cents = utils.frst_from_fobs(fobs_orb_cents[:,np.newaxis,np.newaxis], redz_final) # (F,R,L) in Hz sepa = utils.kepler_sepa_from_freq(mtot, frst_orb_cents) # (F,R,L) in cm From 05219da8898fde61d6386981e206618816a53b6e Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 22:33:29 -0700 Subject: [PATCH 117/291] Plot more --- .../take9B_numberdensity_binned.ipynb | 34 +++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb index 88e2bd3d..b998b553 100644 --- a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb +++ b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb @@ -64,7 +64,7 @@ "param_names = npz['param_names']\n", "print(param_names)\n", "print(npz['class_name'])\n", - "lib_name = '%s v%s' % (npz['class_name'], npz['librarian_version'])\n", + "lib_name = '%s v%s, %d samples' % (npz['class_name'], npz['librarian_version'], nsamps)\n", "print(lib_name)\n", "# print(npz['sam_shape'])\n", "npz.close()" @@ -195,6 +195,14 @@ " fig.tight_layout()" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot best" + ] + }, { "cell_type": "code", "execution_count": null, @@ -205,6 +213,24 @@ " plot_best_index(best)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## plot worst" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for best in nsort[-5:]:\n", + " plot_best_index(best)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -244,11 +270,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "fobs = hdf['fobs']\n", - "dur = 1/fobs[0]\n", - "print(1/fobs[0]/YR)" - ] + "source": [] }, { "cell_type": "code", From 8546ba1df6d8ccb06e63316e76ad046b5423557c Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 23:45:09 -0700 Subject: [PATCH 118/291] Update ev_ss to calculate an expectation value for each individual strain and sky realization. --- holodeck/detstats.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 040a2186..49749613 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1638,7 +1638,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, snr_bg = np.zeros((nsamp, nfreqs, nreals)) df_ss = np.zeros(nsamp) df_bg = np.zeros(nsamp) - ev_ss = np.zeros(nsamp) + ev_ss = np.zeros((nsamp, nreals, nskies)) if save_ssi: gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) # # one time calculations @@ -1736,13 +1736,13 @@ def expval_of_ss(gamma_ssi,): Returns ------- - ev_ss : int - Expected number of single source detection (dp_ss>thresh) averaged across all strain and sky realizations. + ev_ss : (R,S) + Expected number of single source detection (dp_ss>thresh) for each strain and sky realizations. """ # print(f"{gamma_ssi.shape=}, {[*gamma_ssi.shape]}") - nfreqs, nreals, nskies, nloudest = [*gamma_ssi.shape] - ev_ss = np.sum(gamma_ssi)/(nreals*nskies) + # nfreqs, nreals, nskies, nloudest = [*gamma_ssi.shape] + ev_ss = np.sum(gamma_ssi, axis=(0,3)) return ev_ss # df_bg[nn] = np.sum(dp_bg[nn]>thresh)/(nreals) From efabafad7740e840e76be1033c51067fc24da0b9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 23:49:49 -0700 Subject: [PATCH 119/291] Calibrate new library PTA --- .../library_scripts/calibrate_pta_sam.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb index 9112a8e1..4b32bddf 100644 --- a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb +++ b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb @@ -135,8 +135,8 @@ "outputs": [], "source": [ "# modify these until dp_bg = .5\n", - "npsrs=45\n", - "sigma=7.85e-6\n", + "npsrs=40\n", + "sigma=7.37e-6\n", "\n", "# build PTA\n", "phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", @@ -176,7 +176,7 @@ "metadata": {}, "outputs": [], "source": [ - "filename = filepath+'/calibrated_pta.npz'\n", + "filename = filepath+'/calibrated_pta_%dpsrs_%.2esigma.npz' % (npsrs, sigma)\n", "np.savez(filename, npsrs=npsrs, sigma=sigma)" ] }, From d4bf17586216565468e0a98938edb0723330380d Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 22 Jun 2023 23:53:30 -0700 Subject: [PATCH 120/291] Calibrate n1000 09B PTA --- .../library_scripts/calibrate_pta_sam.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb index 4b32bddf..5c7b1b80 100644 --- a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb +++ b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb @@ -36,7 +36,7 @@ "metadata": {}, "outputs": [], "source": [ - "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10'\n", "filename = filepath+'/sam_lib.hdf5'\n", "ssfile = h5py.File(filename, 'r')\n", "print(list(ssfile.keys()))\n", @@ -136,7 +136,7 @@ "source": [ "# modify these until dp_bg = .5\n", "npsrs=40\n", - "sigma=7.37e-6\n", + "sigma=4.31e-6\n", "\n", "# build PTA\n", "phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", From 3407da37ad9565622896b3cbb150457e29d1f6ec Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 00:05:42 -0700 Subject: [PATCH 121/291] Look at single source expectation values for separate realizations and ratio of mean to bg dp. --- .../parameter_investigation/expvals.ipynb | 197 ++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/expvals.ipynb diff --git a/ecg-notebooks/parameter_investigation/expvals.ipynb b/ecg-notebooks/parameter_investigation/expvals.ipynb new file mode 100644 index 00000000..2a3f233a --- /dev/null +++ b/ecg-notebooks/parameter_investigation/expvals.ipynb @@ -0,0 +1,197 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load library data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", + "\n", + "print(hdf.keys())\n", + "sample_params = hdf['sample_params'][...]\n", + "hc_ss = hdf['hc_ss'][...]\n", + "hc_bg = hdf['hc_bg'][...]\n", + "sspar = hdf['sspar'][...]\n", + "bgpar = hdf['bgpar'][...]\n", + "fobs_gw_cents = hdf['fobs'][:]\n", + "hdf.close()\n", + "\n", + "dur = 1/fobs_gw_cents[0]\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", + "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n", + "print(f\"{nsamps=}, {nfreqs=}, {nreals=}, {nloudest=}\")\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Param Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "psfile = np.load(file_path+'/PS_Uniform_09B.pspace.npz')\n", + "print(psfile.files)\n", + "param_names = psfile['param_names']\n", + "print(param_names)\n", + "lib_name = '%s v%s, %d samples' % (psfile['class_name'], psfile['librarian_version'], nsamps)\n", + "print(lib_name)\n", + "psfile.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dsfile = np.load(file_path+'/detstats/psrs40_sigma7.37e-06/detstats.npz')\n", + "print(dsfile.files)\n", + "dp_ss = dsfile['dp_ss']\n", + "dp_bg = dsfile['dp_bg']\n", + "df_ss = dsfile['df_ss']\n", + "df_bg = dsfile['df_bg']\n", + "snr_ss = dsfile['snr_ss']\n", + "snr_bg = dsfile['snr_bg']\n", + "ev_ss = dsfile['ev_ss']\n", + "dsfile.close()\n", + "\n", + "nskies = ev_ss.shape[-1]\n", + "print(f\"{ev_ss.shape=}, {dp_bg.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ev_skymean = np.mean(ev_ss, axis=-1)\n", + "evrat = ev_skymean/dp_bg" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hard_time = sample_params[:,0]\n", + "argsort = np.argsort(hard_time)\n", + "\n", + "xx = hard_time[argsort]\n", + "yy = ev_ss[argsort].reshape(nsamps, nreals*nskies)\n", + "# y2 = np.median(dprat, axis=-1)[argsort]\n", + "\n", + "fig, ax = plot.figax(xlabel='$t_\\mathrm{hard}$ [Gyr]', ylabel='Expectation Value for SS Detections')\n", + "\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# ax.scatter(xx,yy, label='SS EV/ BG DP', alpha=0.5)\n", + "# ax.scatter(xx, y2, label='SS DP/BG DP', alpha=0.5)\n", + "# ax.legend()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hard_time = sample_params[:,0]\n", + "argsort = np.argsort(hard_time)\n", + "\n", + "xx = hard_time[argsort]\n", + "yy = evrat[argsort]\n", + "# y2 = np.median(dprat, axis=-1)[argsort]\n", + "\n", + "fig, ax = plot.figax(xlabel='$t_\\mathrm{hard}$ [Gyr]', ylabel='exp # of SS / DP of BG')\n", + "\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# ax.scatter(xx,yy, label='SS EV/ BG DP', alpha=0.5)\n", + "# ax.scatter(xx, y2, label='SS DP/BG DP', alpha=0.5)\n", + "# ax.legend()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='hard_time', ylabel='DP')\n", + "xx = hard_time[argsort]" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From fe641a3b66007ddcc1bb6d341e692b68523389cb Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 00:27:23 -0700 Subject: [PATCH 122/291] Make many variations just of hard-time. --- .../tk10_varyhardtime.ipynb | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb new file mode 100644 index 00000000..59152b0a --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb @@ -0,0 +1,160 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = 20\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, \n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, hard_name, sam.shape, target_param)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "params_list = np.linspace(0,1,6)\n", + "print(params_list)\n", + "rv_hard_time = vary_parameter('hard_time', params_list=params_list)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data = rv_hard_time[0]" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From f19b9667533cb01dd7cfb28fbabf377bdefbcfe3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 00:33:59 -0700 Subject: [PATCH 123/291] remove dur argument from detect_pspace_model() --- holodeck/detstats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 49749613..32c60c90 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1931,11 +1931,11 @@ def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref ######################### Param Space Models ########################### -def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur, +def detect_pspace_model(fobs_cents, hc_ss, hc_bg, npsrs, sigma, nskies, thresh=DEF_THRESH, debug=False): shape = hc_ss.shape nfreqs, nreals, nloudest = shape[0], shape[1], shape[2] - + dur = 1/fobs_cents[0] # calculate dur, cad, dfobs dur = dur * YR From b77386880de3e0ba7e170fa836b4e5ee50df5bca Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 00:46:27 -0700 Subject: [PATCH 124/291] Comment out some print statements and correct error checking in cyutils to allow for z=-1 --- holodeck/cyutils.pyx | 3 ++- holodeck/single_sources.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/holodeck/cyutils.pyx b/holodeck/cyutils.pyx index 56a49c59..f76ec0e2 100644 --- a/holodeck/cyutils.pyx +++ b/holodeck/cyutils.pyx @@ -1758,7 +1758,8 @@ cdef void _loudest_hc_and_par_from_sorted_redz(long[:] shape, double[:,:,:,:] h2 sspar[3,ff,rr,ll] = redz_final[mm,qq,zz,ff] # check for negative redz_final - if redz_final[mm,qq,zz,ff]<0: + if redz_final[mm,qq,zz,ff]<0 and redz_final[mm,qq,zz,ff]!=-1: + # badz = badz+1 err = f"redz_final[{mm},{qq},{zz},{ff}] = {redz_final[mm,qq,zz,ff]} < 0" print("ERROR IN CYUTILS:", err) diff --git a/holodeck/single_sources.py b/holodeck/single_sources.py index e7ad89f2..052d4117 100644 --- a/holodeck/single_sources.py +++ b/holodeck/single_sources.py @@ -122,12 +122,12 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): # raise ValueError(err) dcom_final = +np.inf*np.ones_like(redz) - print(holo.utils.stats(redz), "before sel") + # print(holo.utils.stats(redz), "before sel") sel = (redz > 0.0) redz[~sel] = -1.0 - print(holo.utils.stats(redz), "after sel") + # print(holo.utils.stats(redz), "after sel") redz[redz<0] = -1.0 - print(holo.utils.stats(redz), "after redz[redz<0]=-1") + # print(holo.utils.stats(redz), "after redz[redz<0]=-1") dcom_final[sel] = cosmo.comoving_distance(redz[sel]).cgs.value if np.any(dcom_final<0): print('dcom_final<0 found') From 9f2eb831efa21600f71f4dc1ccdd1f876a8b8f68 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 00:46:48 -0700 Subject: [PATCH 125/291] Calibrate PTA in varying hard_time tk10 nb --- .../tk10_varyhardtime.ipynb | 75 +++++++++++++++++-- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb index 59152b0a..d904a685 100644 --- a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb @@ -20,7 +20,8 @@ "import holodeck.single_sources as sings\n", "from holodeck.constants import YR, MSOL, MPC\n", "import holodeck as holo\n", - "\n" + "\n", + "import hasasia.sim as hsim\n" ] }, { @@ -32,7 +33,8 @@ "SHAPE = 20\n", "NREALS = 30\n", "NFREQS = 40\n", - "NLOUDEST = 10" + "NLOUDEST = 10\n", + "NPSRS = 40\n" ] }, { @@ -74,7 +76,7 @@ " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", " nreals=NREALS, nfreqs=NFREQS,\n", - " pars=None, save_dir=None, \n", + " pars=None, save_dir=None, detstats=False,\n", " ):\n", " # get the parameter names from this library-space\n", " param_names = pspace.param_names\n", @@ -106,6 +108,8 @@ " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, \n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", + " if detstats:\n", + " print('need to calculate detstats')\n", " if save_dir is not None:\n", " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", @@ -115,6 +119,67 @@ " return (data, params, hard_name, sam.shape, target_param)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calibrate PTA" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rv = vary_parameter('hard_time', params_list=[0.5])\n", + "data = rv[0][0]\n", + "\n", + "# calculate dur, cad, dfobs\n", + "fobs_edges = data['fobs_edges']\n", + "fobs_cents = data['fobs_cents']\n", + "dur = 1/fobs_cents[0]\n", + "hifr = NFREQS/dur\n", + "cad = 1.0 / (2 * hifr)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 40\n", + "SIGMA = 4.05e-6\n", + "\n", + "# build PTA\n", + "print('Building pulsar timing array.')\n", + "sum_median=0\n", + "sum_mean=0\n", + "count=30\n", + "for ii in range(count):\n", + " phis = np.random.uniform(0, 2*np.pi, size = NPSRS)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = NPSRS)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=SIGMA,\n", + " phi=phis, theta=thetas)\n", + "\n", + " dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, data['hc_bg'])\n", + " # print(f\"{np.median(dp_bg)=}, {np.mean(dp_bg)=}, {np.std(dp_bg)=}\")\n", + " sum_median += np.median(dp_bg)\n", + " sum_mean += np.mean(dp_bg)\n", + "print(f\"average median={sum_median/count}, average mean={sum_mean/count}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Run Many Hard Times" + ] + }, { "cell_type": "code", "execution_count": null, @@ -131,9 +196,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "data = rv_hard_time[0]" - ] + "source": [] } ], "metadata": { From 659e253094986606640cd2eb668d0bbccbdad772 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 09:05:44 -0700 Subject: [PATCH 126/291] Add ev_ss to detect_pspace_model() --- holodeck/detstats.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 32c60c90..cdde106a 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1968,11 +1968,12 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dp_ss, snr_ss, gamma_ssi = vals_ss[0], vals_ss[1], vals_ss[2] df_ss = np.sum(dp_ss>thresh)/(nreals*nskies) df_bg = np.sum(dp_bg>thresh)/(nreals) + ev_ss = expval_of_ss(gamma_ssi) dsdata = { 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, 'dp_bg':dp_bg, 'snr_bg':snr_bg, - 'df_ss':df_ss, 'df_bg':df_bg + 'df_ss':df_ss, 'df_bg':df_bg, 'ev_ss':ev_ss, } return dsdata From 87d45783833658c4de3987b1cc6d5119843623bb Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 09:06:13 -0700 Subject: [PATCH 127/291] Added dsdat calculation to vary_parameter() --- .../tk10_varyhardtime.ipynb | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb index d904a685..92074d6a 100644 --- a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb @@ -76,7 +76,8 @@ " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", " nreals=NREALS, nfreqs=NFREQS,\n", - " pars=None, save_dir=None, detstats=False,\n", + " pars=None, save_dir=None, \n", + " get_ds=False, #npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES,\n", " ):\n", " # get the parameter names from this library-space\n", " param_names = pspace.param_names\n", @@ -92,6 +93,7 @@ "\n", " data = []\n", " params = []\n", + " dsdat = []\n", " for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", @@ -109,14 +111,16 @@ " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", " if detstats:\n", - " print('need to calculate detstats')\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + " dsdat.append(_dsdat)\n", " if save_dir is not None:\n", " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", " print('saved to %s' % filename)\n", "\n", - " return (data, params, hard_name, sam.shape, target_param)" + " return (data, params, dsdat)" ] }, { @@ -152,6 +156,7 @@ "source": [ "NPSRS = 40\n", "SIGMA = 4.05e-6\n", + "NSKIES = 25\n", "\n", "# build PTA\n", "print('Building pulsar timing array.')\n", @@ -188,7 +193,31 @@ "source": [ "params_list = np.linspace(0,1,6)\n", "print(params_list)\n", - "rv_hard_time = vary_parameter('hard_time', params_list=params_list)" + "data, params, dsdat = vary_parameter('hard_time', params_list=params_list)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(dsdat[1]['ev_ss'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def_draw_ev(ax):\n", + "\n", + "\n", + "def plot_ssev_vs_freq(dsdat):\n", + " fig, ax = plot.figax(xlabel='Frequency [yr$^{-1}$]', ylabel='Single Source Detections')\n", + " xx = fobs_cents*YR\n", + " yy = dsdat['ev_ss']" ] }, { From 0d8b423c48962a9b519d10f4568c9500a99f4c36 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 09:30:39 -0700 Subject: [PATCH 128/291] Plot ss_ev or ss_dp vs. bg_dp for varying hard time. --- .../tk10_varyhardtime.ipynb | 53 +++++++++++++++++-- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb index 92074d6a..b411a61a 100644 --- a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb @@ -202,7 +202,10 @@ "metadata": {}, "outputs": [], "source": [ - "print(dsdat[1]['ev_ss'].shape)" + "print(dsdat[1]['ev_ss'].shape)\n", + "print(data[1]['fobs_cents'].shape)\n", + "print(dsdat[1]['dp_bg'].shape)\n", + "print(dsdat[1]['dp_ss'].shape)" ] }, { @@ -213,11 +216,51 @@ "source": [ "# def_draw_ev(ax):\n", "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", "\n", - "def plot_ssev_vs_freq(dsdat):\n", - " fig, ax = plot.figax(xlabel='Frequency [yr$^{-1}$]', ylabel='Single Source Detections')\n", - " xx = fobs_cents*YR\n", - " yy = dsdat['ev_ss']" + " hh, = ax.errorbar(xx, yy, yerr, color=color,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "\n", + "# def plot_evss_vs_dpbg(dsdat):\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + "\n", + "# fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + "# ylabel='$\\langle$ Single Source Detections $\\\\rangle_\\mathrm{skies}$')\n", + "# for ii, ds in enumerate(dsdat):\n", + "# draw_skies_vs_bg(ax, ds['ev_ss'], ds['dp_bg'], color=colors[ii])\n", + "# # xx = fobs_cents*YR\n", + "# # yy = dsdat['ev_ss']\n", + "\n", + "# return fig\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param='hard_time', use_ev=True):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + "\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source Detections Probability $\\\\rangle_\\mathrm{skies}$')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'upper left', title='$\\tau_\\mathrm{hard}$')\n", + " # xx = fobs_cents*YR\n", + " # yy = dsdat['ev_ss']\n", + "\n", + " return fig\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)" ] }, { From 7cd55230e183c1ae3fb916686ed3258903422370 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 12:57:44 -0700 Subject: [PATCH 129/291] Correct dur usage in detect_pspace_model() --- holodeck/detstats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index cdde106a..4455b90d 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1938,10 +1938,10 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur = 1/fobs_cents[0] # calculate dur, cad, dfobs - dur = dur * YR + # dur = dur * YR hifr = nfreqs/dur cad = 1.0 / (2 * hifr) - fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad) + fobs_cents, fobs_edges = holo.utils.pta_freqs(dur) dfobs = np.diff(fobs_edges) # build PTA From 8adbd9fdf9144a4c2c463f1a6499935f3c51aa43 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 12:57:59 -0700 Subject: [PATCH 130/291] Updated ss vs bg detstats plots --- .../tk10_varyhardtime.ipynb | 90 +++++++++++++++---- 1 file changed, 74 insertions(+), 16 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb index b411a61a..ea44601e 100644 --- a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb @@ -110,7 +110,7 @@ " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, \n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", - " if detstats:\n", + " if get_ds:\n", " _dsdat = detstats.detect_pspace_model(\n", " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", " dsdat.append(_dsdat)\n", @@ -137,17 +137,26 @@ "metadata": {}, "outputs": [], "source": [ - "rv = vary_parameter('hard_time', params_list=[0.5])\n", - "data = rv[0][0]\n", + "rv = vary_parameter('hard_time', params_list=[0.5], get_ds=False)\n", + "data1 = rv[0][0] # there is only one data being returned\n", + "print(f\"{len(rv[0])}\")\n", "\n", "# calculate dur, cad, dfobs\n", - "fobs_edges = data['fobs_edges']\n", - "fobs_cents = data['fobs_cents']\n", - "dur = 1/fobs_cents[0]\n", + "fobs_edges = data1['fobs_edges']\n", + "fobs_cents = data1['fobs_cents']\n", + "dur = 1/fobs_cents\n", "hifr = NFREQS/dur\n", "cad = 1.0 / (2 * hifr)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Change the following as needed" + ] + }, { "cell_type": "code", "execution_count": null, @@ -155,14 +164,15 @@ "outputs": [], "source": [ "NPSRS = 40\n", - "SIGMA = 4.05e-6\n", - "NSKIES = 25\n", + "SIGMA = 2.01e-5\n", + "NSKIES = 40\n", "\n", "# build PTA\n", "print('Building pulsar timing array.')\n", "sum_median=0\n", "sum_mean=0\n", "count=30\n", + "# dat = data[int(len(data)/2)]\n", "for ii in range(count):\n", " phis = np.random.uniform(0, 2*np.pi, size = NPSRS)\n", " thetas = np.random.uniform(np.pi/2, np.pi/2, size = NPSRS)\n", @@ -170,11 +180,25 @@ " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=SIGMA,\n", " phi=phis, theta=thetas)\n", "\n", - " dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, data['hc_bg'])\n", + " dp_bg = detstats.detect_bg_pta(psrs, fobs_cents, cad, data1['hc_bg'])\n", " # print(f\"{np.median(dp_bg)=}, {np.mean(dp_bg)=}, {np.std(dp_bg)=}\")\n", " sum_median += np.median(dp_bg)\n", " sum_mean += np.mean(dp_bg)\n", - "print(f\"average median={sum_median/count}, average mean={sum_mean/count}\")" + "print(f\"average median={sum_median/count}, average mean={sum_mean/count}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# check that rest make sense\n", + "\n", + "dsdat1 = detstats.detect_pspace_model(fobs_cents, data1['hc_ss'], data1['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + "print(holo.utils.stats(dsdat1['ev_ss']))\n", + "print(holo.utils.stats(dsdat1['dp_ss']))\n", + "print(holo.utils.stats(dsdat1['dp_bg']))" ] }, { @@ -193,7 +217,7 @@ "source": [ "params_list = np.linspace(0,1,6)\n", "print(params_list)\n", - "data, params, dsdat = vary_parameter('hard_time', params_list=params_list)" + "data, params, dsdat = vary_parameter('hard_time', params_list=params_list, get_ds=True)" ] }, { @@ -208,6 +232,28 @@ "print(dsdat[1]['dp_ss'].shape)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ds in dsdat:\n", + " print(holo.utils.stats(ds['dp_bg']))\n", + " print(holo.utils.stats(ds['dp_ss'][:,5]))\n", + " print(holo.utils.stats(ds['ev_ss'][:,5]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ds in dsdat:\n", + " print(holo.utils.stats(ds['dp_bg']/ds['dp_ss'][:,5]))" + ] + }, { "cell_type": "code", "execution_count": null, @@ -215,6 +261,8 @@ "outputs": [], "source": [ "# def_draw_ev(ax):\n", + "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", + "# plt.rcParams[\"font.family\"] = \"serif\"\n", "\n", "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", " color='k', mean=True):\n", @@ -225,7 +273,7 @@ " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", "\n", - " hh, = ax.errorbar(xx, yy, yerr, color=color,\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", " linestyle='', capsize=3, marker='o', alpha=0.5)\n", " return hh\n", "\n", @@ -246,23 +294,33 @@ " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", "\n", " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", - " ylabel='$\\langle$ Single Source Detections Probability $\\\\rangle_\\mathrm{skies}$')\n", + " ylabel='$\\langle$ Single Source Detections Probability $\\\\rangle_\\mathrm{skies}$',\n", + " ) #xscale='linear', yscale='linear')\n", " handles = []\n", " for ii, ds in enumerate(dsdat):\n", - " label = params[ii][target_param]\n", + " label = '%.2f' % params[ii][target_param]\n", " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", " handles.append(hh)\n", - " ax.legend(handles=handles, loc = 'upper left', title='$\\tau_\\mathrm{hard}$')\n", + " ax.legend(handles=handles, loc = 'upper left', title='$\\\\tau_\\mathrm{hard}$',\n", + " ncols=2, title_fontsize=12)\n", + " # ax.set_aspect(1)\n", " # xx = fobs_cents*YR\n", " # yy = dsdat['ev_ss']\n", - "\n", + " fig.tight_layout()\n", " return fig\n", "\n", "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, From d9b79b9b5e989570c6a2cd97cbbcdf65617cd69c Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 16:51:43 -0700 Subject: [PATCH 131/291] Allow for no theta_ss input in detect_ss_pta --- holodeck/detstats.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 4455b90d..b56034ff 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1414,7 +1414,7 @@ def detect_ss(thetas, phis, sigmas, cad, dur, fobs, dfobs, hc_ss, hc_bg, def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, - theta_ss=None, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, + theta_ss=None, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, nskies=25, Fe_bar = None, Amp_red=None, gamma_red=None, alpha_0=0.001, Fe_bar_guess=15, ret_snr=False, print_nans=False, snr_cython=True, gamma_cython=True, grid_path=GAMMA_RHO_GRID_PATH): """ Calculate the single source detection probability, and all intermediary steps for @@ -1475,6 +1475,9 @@ def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, """ # Assign random single source sky params, if not provided. + nfreqs, nreals, nloudest = [*hc_ss.shape] + if theta_ss is None: + theta_ss = np.random.uniform(0,np.pi, size=nfreqs*nskies*nloudest).reshape(nfreqs, nskies, nloudest) if phi_ss is None: phi_ss = np.random.uniform(0,2*np.pi, size=theta_ss.size).reshape(theta_ss.shape) if Phi0_ss is None: @@ -1933,8 +1936,7 @@ def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref def detect_pspace_model(fobs_cents, hc_ss, hc_bg, npsrs, sigma, nskies, thresh=DEF_THRESH, debug=False): - shape = hc_ss.shape - nfreqs, nreals, nloudest = shape[0], shape[1], shape[2] + nfreqs, nreals, nloudest = [*hc_ss.shape] dur = 1/fobs_cents[0] # calculate dur, cad, dfobs @@ -1960,15 +1962,18 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, # Calculate DPs, SNRs, and DFs if debug: print('Calculating SS and BG detection statistics.') dp_bg, snr_bg = detect_bg_pta(psrs, fobs_cents, cad, hc_bg, ret_snr=True) + # print(f"{np.mean(dp_bg)=}") vals_ss = detect_ss_pta( psrs, cad, dur, fobs_cents, dfobs, hc_ss, hc_bg, gamma_cython=True, snr_cython=True, ret_snr=True, theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss, ) dp_ss, snr_ss, gamma_ssi = vals_ss[0], vals_ss[1], vals_ss[2] + # print(f"{np.mean(dp_ss)=}") df_ss = np.sum(dp_ss>thresh)/(nreals*nskies) df_bg = np.sum(dp_bg>thresh)/(nreals) ev_ss = expval_of_ss(gamma_ssi) + # print(f"{np.mean(ev_ss)=}") dsdata = { 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, From 66852b50bfe9c33da2fb47b2daed2942a5b815ca Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 17:50:16 -0700 Subject: [PATCH 132/291] Plot SS vs BG DP with colorbars for each parameter --- .../tk11_ssdp_vs_freqs.ipynb | 341 ++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb b/ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb new file mode 100644 index 00000000..8b40a925 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb @@ -0,0 +1,341 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", + "\n", + "print(hdf.keys())\n", + "sample_params = hdf['sample_params'][...]\n", + "hc_ss = hdf['hc_ss'][...]\n", + "hc_bg = hdf['hc_bg'][...]\n", + "sspar = hdf['sspar'][...]\n", + "bgpar = hdf['bgpar'][...]\n", + "fobs_gw_cents = hdf['fobs'][:]\n", + "hdf.close()\n", + "\n", + "dur = 1/fobs_gw_cents[0]\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", + "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", + "print(npz.files)\n", + "param_names = npz['param_names']\n", + "print(param_names)\n", + "print(npz['class_name'])\n", + "lib_name = '%s v%s, %d samples' % (npz['class_name'], npz['librarian_version'], nsamps)\n", + "print(lib_name)\n", + "# print(npz['sam_shape'])\n", + "npz.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10/detstats/psrs40_sigma4.31e-06/detstats.npz')\n", + "\n", + "dp_ss = npz['dp_ss']\n", + "dp_bg = npz['dp_bg']\n", + "df_ss = npz['df_ss']\n", + "df_bg = npz['df_bg']\n", + "ev_ss = npz['ev_ss']\n", + "print(f\"{ev_ss.shape=}, {dp_ss.shape=}\")\n", + "npz.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sample_params[0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def_draw_ev(ax):\n", + "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", + "# plt.rcParams[\"font.family\"] = \"serif\"\n", + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True, errors=False,\n", + " ms=2):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + " if errors:\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.05, markersize=ms)\n", + " else: \n", + " hh = ax.scatter(xx, yy, color=color, label=label,\n", + " linestyle='', marker='o', alpha=0.05, s=ms)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dp_ss, dp_bg, target_params=None, norm=None, \n", + " use_ev=False, errors=False, ms=2, alpha=0.05, color='tab:blue', cmap=cm.rainbow):\n", + " # colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " # cmin = \n", + "\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) \n", + " \n", + " for ii in range(len(dp_ss)):\n", + " # label = '%.2f' % params[ii][target_param]\n", + " if target_params is not None and norm is not None:\n", + " color = cmap(norm(target_params[ii]))\n", + " detss = dp_ss[ii] # use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, dp_bg[ii], color=color, errors=errors, ms=ms) #, label=label)\n", + "\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "# fig2 = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, errors=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig1 = plot_dpss_vs_dpbg(dp_ss, dp_bg, use_ev=False)\n", + "fig2 = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Color by params" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target = 'hard_time'\n", + "def normalize_target(target, param_names=param_names, sample_params=sample_params):\n", + " idx = list(param_names).index(target)\n", + " target_params = sample_params[:,idx]\n", + " mintarget = np.min(target_params)\n", + " maxtarget = np.max(target_params)\n", + " norm = mpl.colors.Normalize(vmin=mintarget, vmax=maxtarget)\n", + " return target_params, norm" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(target_params.shape)\n", + "print(dp_ss.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Connect to hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target_params, norm = normalize_target('hard_time')\n", + "cmap=cm.rainbow\n", + "fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", + " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", + " label='$\\\\tau_\\mathrm{hard}$', shrink=0.75 )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsamps, nfreqs, nreals)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(ev_ss.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(param_names)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cmap=cm.rainbow\n", + "\n", + "for tt, target in enumerate(param_names):\n", + " target_params, norm = normalize_target(target)\n", + " fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", + " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", + " cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", + " label=target, shrink=0.75 )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig.axes[0].set_ylim(10**-1, 4)\n", + "fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Diverging Colorbar for ratio!!\n", + "## make this for individual sample" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## make this for whole library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 39b3038acf63ec16d2930b316c9cb920d9716a72 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 17:55:49 -0700 Subject: [PATCH 133/291] Plot ratio vs hardening time for mass colorbar --- .../tk10_varyhardtime.ipynb | 288 ++++++++++++++++-- 1 file changed, 261 insertions(+), 27 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb index ea44601e..2f5bfa10 100644 --- a/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10_varyhardtime.ipynb @@ -14,6 +14,7 @@ "import matplotlib.pyplot as plt\n", "import matplotlib.cm as cm\n", "import h5py\n", + "import matplotlib as mpl\n", "\n", "\n", "from holodeck import plot, detstats\n", @@ -30,11 +31,12 @@ "metadata": {}, "outputs": [], "source": [ - "SHAPE = 20\n", + "SHAPE = None\n", "NREALS = 30\n", "NFREQS = 40\n", "NLOUDEST = 10\n", - "NPSRS = 40\n" + "RECONSTRUCT = True\n", + "NPARS = 21" ] }, { @@ -107,7 +109,7 @@ " elif isinstance(hard, holo.hardening.Hard_GW):\n", " hard_name = 'GW Only'\n", " # run this model, retrieving binary parameters and the GWB\n", - " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, \n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", " if get_ds:\n", @@ -131,6 +133,14 @@ "# Calibrate PTA" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Get Middle Model" + ] + }, { "cell_type": "code", "execution_count": null, @@ -138,13 +148,21 @@ "outputs": [], "source": [ "rv = vary_parameter('hard_time', params_list=[0.5], get_ds=False)\n", - "data1 = rv[0][0] # there is only one data being returned\n", - "print(f\"{len(rv[0])}\")\n", - "\n", + "data1 = rv[0][0] # there is o|nly one data being returned\n", + "print(f\"{len(rv[0])}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ "# calculate dur, cad, dfobs\n", "fobs_edges = data1['fobs_edges']\n", "fobs_cents = data1['fobs_cents']\n", - "dur = 1/fobs_cents\n", + "dur = 1/fobs_cents[0]\n", + "print(dur.shape)\n", "hifr = NFREQS/dur\n", "cad = 1.0 / (2 * hifr)" ] @@ -154,7 +172,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Change the following as needed" + "## Change the PTA as needed" ] }, { @@ -164,8 +182,8 @@ "outputs": [], "source": [ "NPSRS = 40\n", - "SIGMA = 2.01e-5\n", - "NSKIES = 40\n", + "SIGMA = 2.6e-6\n", + "NSKIES = 35\n", "\n", "# build PTA\n", "print('Building pulsar timing array.')\n", @@ -187,6 +205,66 @@ "print(f\"average median={sum_median/count}, average mean={sum_mean/count}\")\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "theta_ss, phi_ss, Phi0_ss, iota_ss, psi_ss = detstats._build_skies(NFREQS, NSKIES, NLOUDEST)\n", + "dfobs = np.diff(fobs_edges)\n", + "hc_ss = data1['hc_ss']\n", + "hc_bg = data1['hc_bg']\n", + "vals_ss = detstats.detect_ss_pta(\n", + " psrs, cad, dur, fobs_cents, dfobs, hc_ss, hc_bg, \n", + " gamma_cython=True, snr_cython=True, ret_snr=True, \n", + " theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss,\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(NLOUDEST)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(theta_ss.shape)\n", + "print(hc_ss.shape)\n", + "print(hc_bg.shape)\n", + "print(data1['hc_bg'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data1['hc_bg'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dfobs = np.diff(fobs_edges)\n", + "print(cad.shape)\n", + "theta_ss = np.random.uniform(0, np.pi, size = NFREQS * NSKIES * NLOUDEST).reshape(NFREQS, NSKIES, NLOUDEST)\n", + "dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, cad=cad, dur=dur, fobs=fobs_cents, dfobs=dfobs, #theta_ss=theta_ss,\n", + " hc_ss=data1['hc_ss'], hc_bg=data1['hc_bg'], ret_snr=True)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -198,6 +276,7 @@ "dsdat1 = detstats.detect_pspace_model(fobs_cents, data1['hc_ss'], data1['hc_bg'], NPSRS, SIGMA, NSKIES)\n", "print(holo.utils.stats(dsdat1['ev_ss']))\n", "print(holo.utils.stats(dsdat1['dp_ss']))\n", + "print(holo.utils.stats(dsdat1['ev_ss']-dsdat1['dp_ss']))\n", "print(holo.utils.stats(dsdat1['dp_bg']))" ] }, @@ -215,9 +294,9 @@ "metadata": {}, "outputs": [], "source": [ - "params_list = np.linspace(0,1,6)\n", - "print(params_list)\n", - "data, params, dsdat = vary_parameter('hard_time', params_list=params_list, get_ds=True)" + "filename = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "name = '/hardtime_%dvariations' % NPARS\n", + "filename = filename +name+'.npz'" ] }, { @@ -226,10 +305,26 @@ "metadata": {}, "outputs": [], "source": [ - "print(dsdat[1]['ev_ss'].shape)\n", - "print(data[1]['fobs_cents'].shape)\n", - "print(dsdat[1]['dp_bg'].shape)\n", - "print(dsdat[1]['dp_ss'].shape)" + "RECONSTRUCT=True\n", + "if RECONSTRUCT:\n", + " params_list = np.linspace(0,1,NPARS)\n", + " print(params_list)\n", + " data, params, dsdat = vary_parameter('hard_time', params_list=params_list, get_ds=True)\n", + " np.savez(filename, data=data, params=params, dsdat=dsdat)\n", + "else:\n", + " file = np.load(filename, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## or just reconstruct detstats" ] }, { @@ -238,10 +333,27 @@ "metadata": {}, "outputs": [], "source": [ - "for ds in dsdat:\n", - " print(holo.utils.stats(ds['dp_bg']))\n", - " print(holo.utils.stats(ds['dp_ss'][:,5]))\n", - " print(holo.utils.stats(ds['ev_ss'][:,5]))" + "JUST_DETSTATS = False\n", + "if JUST_DETSTATS:\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + " dsdat.append(_dsdat)\n", + " np.savez(filename = filename +'/hardtime_%dvars_p%d_sig%.2e.npz' % (NPARS, NPSRS, SIGMA,),\n", + " data = data, dsdat=dsdat, params=params)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ds in dsdat[:3]:\n", + " print(f\"{holo.utils.stats(ds['dp_bg'])=}\")\n", + " print(f\"{holo.utils.stats(ds['dp_ss'])=}\")\n", + " print(f\"{holo.utils.stats(ds['ev_ss'])=}\")" ] }, { @@ -292,9 +404,9 @@ "\n", "def plot_dpss_vs_dpbg(dsdat, params, target_param='hard_time', use_ev=True):\n", " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", - "\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", - " ylabel='$\\langle$ Single Source Detections Probability $\\\\rangle_\\mathrm{skies}$',\n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", " ) #xscale='linear', yscale='linear')\n", " handles = []\n", " for ii, ds in enumerate(dsdat):\n", @@ -302,16 +414,31 @@ " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", " handles.append(hh)\n", - " ax.legend(handles=handles, loc = 'upper left', title='$\\\\tau_\\mathrm{hard}$',\n", - " ncols=2, title_fontsize=12)\n", + " ax.legend(handles=handles, loc = 'lower left', title='$\\\\tau_\\mathrm{hard}$',\n", + " ncols=4, title_fontsize=12)\n", " # ax.set_aspect(1)\n", " # xx = fobs_cents*YR\n", " # yy = dsdat['ev_ss']\n", + "\n", " fig.tight_layout()\n", " return fig\n", "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\gamma_\\mathrm{outer}=%.2f$' % (params[0]['hard_gamma_inner'], 2.5)\n", + "print(text)\n", + "\n", + "param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "\n", + "\n", "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", - "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)" + "fig1.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "fig1.savefig(param_path+'/')\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" ] }, { @@ -319,7 +446,114 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "\n", + "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target='hard_time'\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Get mass normalization\n", + "\n", + "sspar = []\n", + "ssmtot = []\n", + "for dat in data:\n", + " sspar.append(dat['sspar'])\n", + " ssmtot.append(dat['sspar'][0])\n", + "sspar = np.array(sspar)\n", + "ssmtot = np.array(ssmtot)/MSOL\n", + "ssmtot = np.max(ssmtot, axis=(1,3))\n", + "norm = mpl.colors.Normalize(vmin=np.min(ssmtot), vmax=np.max(ssmtot))\n", + "\n", + "print(np.min(ssmtot))\n", + "print(np.max(ssmtot))\n", + "print(ssmtot.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(norm(1e43))\n", + "print(norm(0))\n", + "cmap = cm.viridis\n", + "print(cmap(0.5))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "cmap = cm.gist_rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target='hard_time'\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(ssmtot[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='Mass of Loudest Source [M$_\\odot$]')" + ] }, { "cell_type": "code", From 245c0253f2ce31e2853502a818f584a402b48be8 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 18:27:38 -0700 Subject: [PATCH 134/291] Update detstats to not pass in dur or cad, calculate them internally instead. --- .../library_scripts/calibrate_pta_sam.ipynb | 2 +- holodeck/detstats.py | 69 +++++++++---------- scripts/detect_lib_script.py | 35 +++++----- 3 files changed, 51 insertions(+), 55 deletions(-) diff --git a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb index 5c7b1b80..f2f740ba 100644 --- a/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb +++ b/ecg-notebooks/detstats_functions/library_scripts/calibrate_pta_sam.ipynb @@ -162,7 +162,7 @@ " # sigmas = np.ones_like(phis)*sigma\n", " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", " phi=phis, theta=thetas)\n", - " dp_bg = detstats.detect_bg_pta(psrs, fobs, cad, hc_bg_all[nn])\n", + " dp_bg = detstats.detect_bg_pta(psrs, fobs, hc_bg_all[nn])\n", " mean_tot+=np.mean(dp_bg)\n", " median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", "mean_tot /= count\n", diff --git a/holodeck/detstats.py b/holodeck/detstats.py index b56034ff..8c850b6a 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -460,7 +460,7 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False -def detect_bg_pta(pulsars, fobs, cad, hc_bg, alpha_0=0.001, ret_snr = False): +def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False): """ Calculate the background detection probability, and all the intermediary steps from a list of hasasia.Pulsar objects. @@ -470,8 +470,6 @@ def detect_bg_pta(pulsars, fobs, cad, hc_bg, alpha_0=0.001, ret_snr = False): A set of pulsars generated by hasasia.sim.sim_pta() fobs : (F,) 1Darray of scalars Frequency bin centers in hertz. - cad : scalar - Cadence of observations in seconds. hc_bg : (F,R) Characteristic strain of the background at each frequency, for R realizations. @@ -494,6 +492,8 @@ def detect_bg_pta(pulsars, fobs, cad, hc_bg, alpha_0=0.001, ret_snr = False): TODO: implement red noise """ + cad = 1.0/(2*fobs[-1]) + # get pulsar properties thetas = np.zeros(len(pulsars)) phis = np.zeros(len(pulsars)) @@ -1312,7 +1312,7 @@ def _ss_detection_probability(gamma_ss_i): ######################## Detection Probability ######################### -def detect_ss(thetas, phis, sigmas, cad, dur, fobs, dfobs, hc_ss, hc_bg, +def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, theta_ss, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, Amp_red=None, gamma_red=None, alpha_0=0.001, ret_snr=False,): """ Calculate the single source detection probability, and all intermediary steps. @@ -1325,10 +1325,6 @@ def detect_ss(thetas, phis, sigmas, cad, dur, fobs, dfobs, hc_ss, hc_bg, Azimuthal (longitudinal) angular position of each pulsar in radians. sigmas : (P,) 1Darray of scalars Sigma_i of each pulsar in seconds. - cad : scalar - Cadence of observations in seconds. - dur : scalar - Duration of observations in seconds. fobs : (F,) 1Darray of scalars Observer frame gw frequency bin centers in Hz. dfobs : (F-1,) 1Darray of scalars @@ -1371,6 +1367,10 @@ def detect_ss(thetas, phis, sigmas, cad, dur, fobs, dfobs, hc_ss, hc_bg, SNR of each single source. """ + dur = 1.0/fobs[0] + cad = 1.0/(2*fobs[-1]) + fobs_cents, fobs_edges = utils.pta_freqs(dur, num=len(fobs)) + dfobs = np.diff(fobs_edges) # Assign random single source sky params, if not provided. if phi_ss is None: @@ -1413,7 +1413,7 @@ def detect_ss(thetas, phis, sigmas, cad, dur, fobs, dfobs, hc_ss, hc_bg, return gamma_ss -def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, +def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, theta_ss=None, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, nskies=25, Fe_bar = None, Amp_red=None, gamma_red=None, alpha_0=0.001, Fe_bar_guess=15, ret_snr=False, print_nans=False, snr_cython=True, gamma_cython=True, grid_path=GAMMA_RHO_GRID_PATH): @@ -1424,14 +1424,8 @@ def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, ---------- pulsars : (P,) list of hasasia.Pulsar objects A set of pulsars generated by hasasia.sim.sim_pta() - cad : scalar - Cadence of observations in seconds. - dur : scalar - Duration of observations in seconds. fobs : (F,) 1Darray of scalars Observer frame gw frequency bin centers in Hz. - dfobs : (F-1,) 1Darray of scalars - Observer frame gw frequency bin widths in Hz. hc_ss : (F,R,L) NDarray of scalars Characteristic strain of the L loudest single sources at each frequency, for R realizations. @@ -1474,6 +1468,12 @@ def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, DP of each single source. Returned only if ret_snr is True. """ + + dur = 1.0/fobs[0] + cad = 1.0/(2*fobs[-1]) + fobs_cents, fobs_edges = utils.pta_freqs(dur, num=len(fobs)) + dfobs = np.diff(fobs_edges) + # Assign random single source sky params, if not provided. nfreqs, nreals, nloudest = [*hc_ss.shape] if theta_ss is None: @@ -1544,9 +1544,8 @@ def detect_ss_pta(pulsars, cad, dur, fobs, dfobs, hc_ss, hc_bg, ######################################################################## def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, - dur=None, cad=None, dfobs=None, plot=True, debug=False, - grid_path=GAMMA_RHO_GRID_PATH, snr_cython = True, - save_ssi=False, ret_dict=False): + plot=True, debug=False, grid_path=GAMMA_RHO_GRID_PATH, + snr_cython = True, save_ssi=False, ret_dict=False): """ Calculate detection statistics for an ss library output. Parameters @@ -1604,9 +1603,11 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, # Read in hdf file ssfile = h5py.File(hdf_name, 'r') fobs = ssfile['fobs'][:] - if dfobs is None: dfobs = ssfile['dfobs'][:] - if dur is None: dur = ssfile['pta_dur'][0] - if cad is None: cad = ssfile['pta_cad'][0] + dur = 1.0/fobs[0] + cad = 1.0/(2*fobs[-1]) + # if dfobs is None: dfobs = ssfile['dfobs'][:] + # if dur is None: dur = ssfile['pta_dur'][0] + # if cad is None: cad = ssfile['pta_cad'][0] hc_ss = ssfile['hc_ss'][...] hc_bg = ssfile['hc_bg'][...] shape = hc_ss.shape @@ -1650,12 +1651,11 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, for nn in range(nsamp): if debug: print('on sample nn=%d out of N=%d' % (nn,nsamp)) - dp_bg[nn,:], snr_bg[nn,...] = detect_bg_pta(psrs, fobs, cad, hc_bg[nn], ret_snr=True) - vals_ss = detect_ss_pta(psrs, cad, dur, fobs, dfobs, - hc_ss[nn], hc_bg[nn], ret_snr=True, - gamma_cython=True, snr_cython=snr_cython, - theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, - iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) + dp_bg[nn,:], snr_bg[nn,...] = detect_bg_pta(psrs, fobs, hc_bg[nn], ret_snr=True) + vals_ss = detect_ss_pta(psrs, fobs, hc_ss[nn], hc_bg[nn], + ret_snr=True, gamma_cython=True, snr_cython=snr_cython, + theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, + iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) dp_ss[nn,:,:], snr_ss[nn,...] = vals_ss[0], vals_ss[1], df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) ev_ss[nn] = expval_of_ss(vals_ss[2]) @@ -1936,15 +1936,12 @@ def rank_samples(hc_ss, hc_bg, fobs, fidx=None, dfobs=None, amp_ref=None, hc_ref def detect_pspace_model(fobs_cents, hc_ss, hc_bg, npsrs, sigma, nskies, thresh=DEF_THRESH, debug=False): + nfreqs, nreals, nloudest = [*hc_ss.shape] dur = 1/fobs_cents[0] - - # calculate dur, cad, dfobs - # dur = dur * YR - hifr = nfreqs/dur - cad = 1.0 / (2 * hifr) - fobs_cents, fobs_edges = holo.utils.pta_freqs(dur) - dfobs = np.diff(fobs_edges) + cad = 1.0 / (2 * fobs_cents[-1]) + # fobs_cents, fobs_edges = holo.utils.pta_freqs(dur) + # dfobs = np.diff(fobs_edges) # build PTA if debug: print('Building pulsar timing array.') @@ -1961,10 +1958,10 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, # Calculate DPs, SNRs, and DFs if debug: print('Calculating SS and BG detection statistics.') - dp_bg, snr_bg = detect_bg_pta(psrs, fobs_cents, cad, hc_bg, ret_snr=True) + dp_bg, snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True) # print(f"{np.mean(dp_bg)=}") vals_ss = detect_ss_pta( - psrs, cad, dur, fobs_cents, dfobs, hc_ss, hc_bg, + psrs, fobs_cents, hc_ss, hc_bg, gamma_cython=True, snr_cython=True, ret_snr=True, theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss, ) diff --git a/scripts/detect_lib_script.py b/scripts/detect_lib_script.py index 8958d3b1..904805b2 100644 --- a/scripts/detect_lib_script.py +++ b/scripts/detect_lib_script.py @@ -7,7 +7,6 @@ : library directory that contains sam_lib.hdf5. : directory containing gamma-rho interpolation grids. Will mkdir if it doesn't exist. - : pta duration in years, default 16.03 yr : number of PTA pulsars to simulate, should be calibrated to data : white noise sigma of PTA pulsars, should be calibrated to data : number of sky realizations to generate for each single source strain realization @@ -33,7 +32,7 @@ import argparse DEF_NFREQS = holo.librarian.DEF_NUM_FBINS -DEF_PTA_DUR = holo.librarian.DEF_PTA_DUR +# DEF_PTA_DUR = holo.librarian.DEF_PTA_DUR DEF_NPSRS = 60 DEF_SIGMA = 1e-6 @@ -54,8 +53,8 @@ def _setup_argparse(): parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, help='number of frequency bins') - parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, - help='pta duration in yrs') + # parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, + # help='pta duration in yrs') parser.add_argument('-p', '--npsrs', action='store', dest='npsrs', type=int, default=DEF_NPSRS, help='number of pulsars in pta') @@ -79,14 +78,14 @@ def _setup_argparse(): args = parser.parse_args() return args -def freq_data(args): - nfreqs = args.nfreqs - dur = args.dur * YR - hifr = nfreqs/dur - cad = 1.0 / (2 * hifr) - fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad) - dfobs = np.diff(fobs_edges) - return dur, cad, dfobs +# def freq_data(args): +# nfreqs = args.nfreqs +# dur = args.dur * YR +# hifr = nfreqs/dur +# cad = 1.0 / (2 * hifr) +# fobs_edges = holo.utils.nyquist_freqs_edges(dur, cad) +# dfobs = np.diff(fobs_edges) +# return dur, cad, dfobs def main(): # setup command line arguments @@ -94,11 +93,11 @@ def main(): print('npsrs=%d, sigma=%e s, nskies=%d, thresh=%f' % (args.npsrs, args.sigma, args.nskies, args.thresh)) - # calculate cad and dfobs from duration and nfreqs - dur, cad, dfobs = freq_data(args) - args = _setup_argparse() - print('dur=%f yr, cad=%f yr, nfreqs=%d' % - (dur/YR, cad/YR, len(dfobs))) + # # calculate cad and dfobs from duration and nfreqs + # dur, cad, dfobs = freq_data(args) + # args = _setup_argparse() + # print('dur=%f yr, cad=%f yr, nfreqs=%d' % + # (dur/YR, cad/YR, len(dfobs))) hdf_name = args.lib_path+'/sam_lib.hdf5' @@ -110,7 +109,7 @@ def main(): ds.detect_lib(hdf_name, output_dir, args.npsrs, args.sigma, nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, - dur=dur, cad=cad, dfobs=dfobs, grid_path=args.grid_path, + grid_path=args.grid_path, snr_cython=args.snr_cython, save_ssi=args.save_ssi) From f7a1b2a2f21820ac263bffc43af949c8fbadd37b Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 22:16:28 -0700 Subject: [PATCH 135/291] Use individually calibrated PTAs in tk10B_varyhard_ptacalib.ipynb --- .../tk10B_varyhard_ptacalib.ipynb | 484 ++++++++++++++++++ 1 file changed, 484 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb new file mode 100644 index 00000000..bde123be --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb @@ -0,0 +1,484 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "RECONSTRUCT = False\n", + "NPARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " get_ds=False, #npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES,\n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " dsdat = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if get_ds:\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + " dsdat.append(_dsdat)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, dsdat)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Run/Load Many Hard Times" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "name = '/hardtime_%dvariations' % NPARS\n", + "filename = path +name+'.npz'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if RECONSTRUCT:\n", + " params_list = np.linspace(0,1,NPARS)\n", + " print(params_list)\n", + " data, params, dsdat = vary_parameter('hard_time', params_list=params_list, get_ds=True)\n", + " np.savez(filename, data=data, params=params, dsdat=dsdat)\n", + "else:\n", + " file = np.load(filename, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# PTA Calibration" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad, nreals=NREALS):\n", + " all_dp = np.zeros((trials, nreals))\n", + " # median_tot = 0\n", + " for ii in range(trials):\n", + " # build PTA\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + " phi=phis, theta=thetas)\n", + " all_dp[ii] = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", + " # print(f'{dp_bg=}')\n", + " avg_dp = np.mean(all_dp)\n", + " std_dp = np.std(all_dp)\n", + " # median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", + " return avg_dp, std_dp\n", + "\n", + "def quick_pta_calibration(hc_bg, fobs, maxtrials=2, debug=False,\n", + " sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS):\n", + " assert maxtrials>1, \"'maxtrials' must be >1\"\n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " sigma=sig_start\n", + "\n", + " avg_dp = 0\n", + " trials=1\n", + " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + " avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", + " fobs=fobs, dur=dur, cad=cad)\n", + " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", + " \n", + " if avg_dp>0.4 and avg_dp<0.5:\n", + " trials=maxtrials\n", + "\n", + " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", + " sig_min = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max)\n", + " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", + " sig_max = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max) \n", + " return sigma, avg_dp, std_dp" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "num = 0.134980435\n", + "print(f\"{num=:.3f}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Individual DetStats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 40\n", + "\n", + "JUST_DETSTATS = True\n", + "if JUST_DETSTATS or RECONSTRUCT:\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " sigma, avg_dp, std_dp = quick_pta_calibration(_data['hc_bg'], _data['fobs_cents'], maxtrials=5)\n", + " print(f\"{ii}, {sigma=:.4e}, {avg_dp=:.4f}, {std_dp=:.4f}\")\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, sigma, NSKIES)\n", + " dsdat.append(_dsdat)\n", + " np.savez((path +'/hardtime_%dvars_%dpsrs_calibrated.npz' % (NPARS, NPSRS,)),\n", + " data = data, dsdat=dsdat, params=params)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ds in dsdat[:3]:\n", + " print(f\"{holo.utils.stats(ds['dp_bg'])=}\")\n", + " print(f\"{holo.utils.stats(ds['dp_ss'])=}\")\n", + " print(f\"{holo.utils.stats(ds['ev_ss'])=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def_draw_ev(ax):\n", + "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", + "# plt.rcParams[\"font.family\"] = \"serif\"\n", + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "\n", + "# def plot_evss_vs_dpbg(dsdat):\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + "\n", + "# fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + "# ylabel='$\\langle$ Single Source Detections $\\\\rangle_\\mathrm{skies}$')\n", + "# for ii, ds in enumerate(dsdat):\n", + "# draw_skies_vs_bg(ax, ds['ev_ss'], ds['dp_bg'], color=colors[ii])\n", + "# # xx = fobs_cents*YR\n", + "# # yy = dsdat['ev_ss']\n", + "\n", + "# return fig\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param='hard_time', use_ev=True):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title='$\\\\tau_\\mathrm{hard}$',\n", + " ncols=4, title_fontsize=12)\n", + " # ax.set_aspect(1)\n", + " # xx = fobs_cents*YR\n", + " # yy = dsdat['ev_ss']\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\gamma_\\mathrm{outer}=%.2f$' % (params[0]['hard_gamma_inner'], 2.5)\n", + "print(text)\n", + "\n", + "param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "fig1.savefig(param_path+'/')\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target='hard_time'\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Get mass normalization\n", + "\n", + "sspar = []\n", + "ssmtot = []\n", + "for dat in data:\n", + " sspar.append(dat['sspar'])\n", + " ssmtot.append(dat['sspar'][0])\n", + "sspar = np.array(sspar)\n", + "ssmtot = np.array(ssmtot)/MSOL\n", + "ssmtot = np.max(ssmtot, axis=(1,3))\n", + "norm = mpl.colors.Normalize(vmin=np.min(ssmtot), vmax=np.max(ssmtot))\n", + "\n", + "print(np.min(ssmtot))\n", + "print(np.max(ssmtot))\n", + "print(ssmtot.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "cmap = cm.gist_rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target='hard_time'\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(ssmtot[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='Mass of Loudest Source [M$_\\odot$]')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 3f8fa0281d090800c1efdb232118f171d1d64796 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 22:17:39 -0700 Subject: [PATCH 136/291] Develop quick_pta_calibration() function in calibration_function.ipynb. --- .../calibration_function.ipynb | 250 ++++++++++++++++++ 1 file changed, 250 insertions(+) create mode 100644 ecg-notebooks/detstats_functions/calibration_function.ipynb diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb new file mode 100644 index 00000000..c71e1f7a --- /dev/null +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -0,0 +1,250 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import scipy as sp\n", + "import h5py\n", + "\n", + "import holodeck as holo\n", + "import holodeck.single_sources as ss\n", + "from holodeck.constants import YR, MSOL\n", + "from holodeck import utils, detstats, plot\n", + "\n", + "\n", + "import hasasia.sensitivity as hsen\n", + "import hasasia.sim as hsim" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Read in hdf file" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "filepath = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10'\n", + "filename = filepath+'/sam_lib.hdf5'\n", + "ssfile = h5py.File(filename, 'r')\n", + "print(list(ssfile.keys()))\n", + "fobs = ssfile['fobs'][:]\n", + "dur = 1/fobs[0]\n", + "cad = 1/(2*fobs[-1])\n", + "hc_ss_all = ssfile['hc_ss'][...]\n", + "hc_bg_all = ssfile['hc_bg'][...]\n", + "shape = hc_ss_all.shape\n", + "nsamp, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3]\n", + "print('N,F,R,L:', nsamp, nfreqs, nreals, nloudest)\n", + "ssfile.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# find best\n", + "# found this in a another notebook to be sample 30\n", + "# nn=30\n", + "fidx=1 # choose second bin\n", + "hc_ref15_10yr = 11.2*10**-15 \n", + "print(fobs[fidx]*YR)\n", + "nsort, fidx, hc_ref15 = detstats.rank_samples(hc_ss_all, hc_bg_all, fobs, fidx=1, \n", + " hc_ref=hc_ref15_10yr, ret_all=True)\n", + "nn = nsort[0]\n", + "print(nn, fobs[fidx]*YR, hc_ref15)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def get_dpbg(hc_bg, npsrs, sigma, trials):\n", + " avg_dp_tot = 0\n", + " # median_tot = 0\n", + " for ii in range(trials):\n", + " # build PTA\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + " phi=phis, theta=thetas)\n", + " dp_bg = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", + " # print(f'{dp_bg=}')\n", + " avg_dp_tot+=np.median(dp_bg)\n", + " avg_dp = avg_dp_tot/trials\n", + " # median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", + " return avg_dp" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 40\n", + "SIG_START = 1e-7\n", + "SIG_MIN = 1e-9\n", + "SIG_MAX = 1e-3" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(hc_bg_all.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad, nreals=NREALS):\n", + " all_dp = np.zeros((trials, nreals))\n", + " # median_tot = 0\n", + " for ii in range(trials):\n", + " # build PTA\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + " phi=phis, theta=thetas)\n", + " all_dp[ii] = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", + " # print(f'{dp_bg=}')\n", + " avg_dp = np.mean(all_dp)\n", + " std_dp = np.std(all_dp)\n", + " # median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", + " return avg_dp, std_dp\n", + "\n", + "def quick_pta_calibration(hc_bg, fobs, maxtrials=2, debug=False,\n", + " sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS):\n", + " assert maxtrials>1, \"'maxtrials' must be >1\"\n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " sigma=sig_start\n", + "\n", + " avg_dp = 0\n", + " trials=1\n", + " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + " avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", + " fobs=fobs, dur=dur, cad=cad)\n", + " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", + " \n", + " if avg_dp>0.4 and avg_dp<0.5:\n", + " trials=maxtrials\n", + "\n", + " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", + " sig_min = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max)\n", + " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", + " sig_max = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max) \n", + " return sigma, avg_dp, std_dp" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def quick_pta_calibration(hc_bg, maxtrials=2, debug=False):\n", + " assert maxtrials>1, \"'maxtrials' must be >1\"\n", + " avg_dp = 0\n", + " sigma = SIG_START\n", + " sig_min = SIG_MIN\n", + " sig_max = SIG_MAX\n", + " trials=1\n", + " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + " avg_dp = get_dpbg(hc_bg, npsrs=NPSRS, sigma=sigma, trials=trials)\n", + " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", + " \n", + " if avg_dp>0.4 and avg_dp<0.5:\n", + " trials=maxtrials\n", + "\n", + " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", + " sig_min = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max)\n", + " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", + " sig_max = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max)\n", + " return sigma\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%timeit sigma=quick_pta_calibration(hc_bg_all[nsort[0]], maxtrials=2)\n", + "print(sigma)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(get_dpbg(hc_bg_all[nsort[0]], NPSRS, sigma, trials=1))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 21231d2d365abae31f5fd64c93718413a5f50dfa Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 23 Jun 2023 22:58:42 -0700 Subject: [PATCH 137/291] Plot with mass of highest SNR source for colorbars --- .../tk10B_varyhard_ptacalib.ipynb | 65 ++++++++++++++----- 1 file changed, 47 insertions(+), 18 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb index bde123be..8974c7b1 100644 --- a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb @@ -400,21 +400,48 @@ "metadata": {}, "outputs": [], "source": [ - "# Get mass normalization\n", + "print(NREALS)\n", + "print(dsdat[0]['snr_ss'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Get SS mass normalization\n", "\n", - "sspar = []\n", "ssmtot = []\n", - "for dat in data:\n", - " sspar.append(dat['sspar'])\n", - " ssmtot.append(dat['sspar'][0])\n", - "sspar = np.array(sspar)\n", - "ssmtot = np.array(ssmtot)/MSOL\n", - "ssmtot = np.max(ssmtot, axis=(1,3))\n", - "norm = mpl.colors.Normalize(vmin=np.min(ssmtot), vmax=np.max(ssmtot))\n", - "\n", - "print(np.min(ssmtot))\n", - "print(np.max(ssmtot))\n", - "print(ssmtot.shape)" + "ss_dp = []\n", + "mt_hisnr= np.zeros((NPARS, NREALS))\n", + "for ii,dat in enumerate(data):\n", + " # ssmtot.append(dat['sspar'][0])\n", + " snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + " # print(snr_ss.shape)\n", + " ssmtot = dat['sspar'][0]\n", + " # print(ssmtot.shape)\n", + " # for each realization, find the frequency with the loudest single source\n", + " for rr in range(len(snr_ss[0])):\n", + " argmax = np.argmax(snr_ss[:,rr,:,:])\n", + " fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + " mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "vmin = np.min(mt_hisnr)\n", + "vmax = np.max(mt_hisnr)\n", + "norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "print(f\"{vmin=}, {vmax=}\")\n", + "print(mt_hisnr.shape)" ] }, { @@ -424,8 +451,9 @@ "outputs": [], "source": [ "xlabel='$\\\\tau_\\mathrm{hard}$'\n", - "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", - "cmap = cm.gist_rainbow\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", "\n", "fig, ax = plot.figax(xscale='linear',)\n", "ax.set_ylabel(ylabel, fontsize=14)\n", @@ -437,10 +465,10 @@ "for ii, par in enumerate(params):\n", " xx.append(params[ii][target])\n", " dp_bg = dsdat[ii]['dp_bg']\n", - " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", " yy.append(dp_ss/dp_bg)\n", " for rr in range(len(yy[0])):\n", - " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(ssmtot[ii,rr])), alpha=0.5,)\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(mt_hisnr[ii,rr])), alpha=0.5,)\n", "xx = np.array(xx)\n", "yy = np.array(yy)\n", "print(yy.shape)\n", @@ -449,7 +477,8 @@ "plot.draw_med_conf(ax, xx, yy)\n", "# for rr in range(len(yy[0])):\n", "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", - "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='Mass of Loudest Source [M$_\\odot$]')" + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures'+'/dpratio_vs_')" ] }, { From d02ff2220771ca2ad1840dfead0907de5f0be337 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 10:38:04 -0700 Subject: [PATCH 138/291] Save figures. --- .../parameter_investigation/tk10B_varyhard_ptacalib.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb index 8974c7b1..a2e4c444 100644 --- a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb @@ -343,7 +343,8 @@ "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", "fig1.tight_layout()\n", - "fig1.savefig(param_path+'/')\n", + "fig1.savefig('/Users/emigardiner/GWs/holodeck/output/figures/params'+'/ss_vs_bg_w_hardtime_21vars.png')\n", + "\n", "\n", "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", @@ -478,7 +479,8 @@ "# for rr in range(len(yy[0])):\n", "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", - "# fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures'+'/dpratio_vs_')" + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "fig.savefig(figloc+'/dpratio_vs_hardtime_w_mass_%dvars.png' % NPARS)" ] }, { From 166bbb2603ff8796e7f44a8365b6615a83625461 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 10:53:50 -0700 Subject: [PATCH 139/291] Clean up if reconstruct/if get_detstats options and calculated calibrated lib detstats for varying gsmf mchar0 --- .../tk10C_varymchar0_ptacalib.ipynb | 515 ++++++++++++++++++ 1 file changed, 515 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb new file mode 100644 index 00000000..57675dd1 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb @@ -0,0 +1,515 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "RECONSTRUCT = True\n", + "NPARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " get_ds=False, #npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES,\n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " dsdat = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if get_ds:\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + " dsdat.append(_dsdat)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, dsdat)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Set Filename" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "name = '/gsmf_mchar0_%dvariations' % NPARS\n", + "filename = path +name+'.npz'" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# PTA Calibration" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad, nreals=NREALS):\n", + " all_dp = np.zeros((trials, nreals))\n", + " # median_tot = 0\n", + " for ii in range(trials):\n", + " # build PTA\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " # sigmas = np.ones_like(phis)*sigma\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + " phi=phis, theta=thetas)\n", + " all_dp[ii] = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", + " # print(f'{dp_bg=}')\n", + " avg_dp = np.mean(all_dp)\n", + " std_dp = np.std(all_dp)\n", + " # median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", + " return avg_dp, std_dp\n", + "\n", + "def quick_pta_calibration(hc_bg, fobs, maxtrials=2, debug=False,\n", + " sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS):\n", + " assert maxtrials>1, \"'maxtrials' must be >1\"\n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " sigma=sig_start\n", + "\n", + " avg_dp = 0\n", + " trials=1\n", + " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + " avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", + " fobs=fobs, dur=dur, cad=cad)\n", + " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", + " \n", + " if avg_dp>0.4 and avg_dp<0.5:\n", + " trials=maxtrials\n", + "\n", + " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", + " sig_min = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max)\n", + " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", + " sig_max = sigma\n", + " sigma = np.random.uniform(sig_min, sig_max) \n", + " return sigma, avg_dp, std_dp" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if RECONSTRUCT) and Individual DetStats (if RECONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 40\n", + "\n", + "JUST_DETSTATS = True\n", + "if JUST_DETSTATS or RECONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if RECONSTRUCT:\n", + " params_list = np.linspace(0,1,NPARS)\n", + " data, params, temp = vary_parameter('gsmf_mchar0_log10', params_list=params_list, get_ds=False)\n", + " else:\n", + " file = np.load(filename, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " sigma, avg_dp, std_dp = quick_pta_calibration(_data['hc_bg'], _data['fobs_cents'], maxtrials=5)\n", + " print(f\"{ii}, {sigma=:.4e}, {avg_dp=:.4f}, {std_dp=:.4f}\")\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, sigma, NSKIES)\n", + " dsdat.append(_dsdat)\n", + " np.savez((path +'/hardtime_%dvars_%dpsrs_calibrated.npz' % (NPARS, NPSRS,)),\n", + " data = data, dsdat=dsdat, params=params)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ds in dsdat[:3]:\n", + " print(f\"{holo.utils.stats(ds['dp_bg'])=}\")\n", + " print(f\"{holo.utils.stats(ds['dp_ss'])=}\")\n", + " print(f\"{holo.utils.stats(ds['ev_ss'])=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# if RECONSTRUCT:\n", + "# params_list = np.linspace(0,1,NPARS)\n", + "# print(params_list)\n", + "# data, params, dsdat = vary_parameter('gsmf_mchar0_log10', params_list=params_list, get_ds=True)\n", + "# else:\n", + "# file = np.load(filename, allow_pickle=True)\n", + "# print(file.files)\n", + "# data = file['data']\n", + "# params = file['params']\n", + "# dsdat = file['dsdat']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def_draw_ev(ax):\n", + "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", + "# plt.rcParams[\"font.family\"] = \"serif\"\n", + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "\n", + "# def plot_evss_vs_dpbg(dsdat):\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + "\n", + "# fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + "# ylabel='$\\langle$ Single Source Detections $\\\\rangle_\\mathrm{skies}$')\n", + "# for ii, ds in enumerate(dsdat):\n", + "# draw_skies_vs_bg(ax, ds['ev_ss'], ds['dp_bg'], color=colors[ii])\n", + "# # xx = fobs_cents*YR\n", + "# # yy = dsdat['ev_ss']\n", + "\n", + "# return fig\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param='hard_time', use_ev=True):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title='$\\\\tau_\\mathrm{hard}$',\n", + " ncols=4, title_fontsize=12)\n", + " # ax.set_aspect(1)\n", + " # xx = fobs_cents*YR\n", + " # yy = dsdat['ev_ss']\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\gamma_\\mathrm{outer}=%.2f$' % (params[0]['hard_gamma_inner'], 2.5)\n", + "print(text)\n", + "\n", + "param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "fig1.savefig('/Users/emigardiner/GWs/holodeck/output/figures/params'+'/ss_vs_bg_w_hardtime_21vars.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target='hard_time'\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(NREALS)\n", + "print(dsdat[0]['snr_ss'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Get SS mass normalization\n", + "\n", + "ssmtot = []\n", + "ss_dp = []\n", + "mt_hisnr= np.zeros((NPARS, NREALS))\n", + "for ii,dat in enumerate(data):\n", + " # ssmtot.append(dat['sspar'][0])\n", + " snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + " # print(snr_ss.shape)\n", + " ssmtot = dat['sspar'][0]\n", + " # print(ssmtot.shape)\n", + " # for each realization, find the frequency with the loudest single source\n", + " for rr in range(len(snr_ss[0])):\n", + " argmax = np.argmax(snr_ss[:,rr,:,:])\n", + " fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + " mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "vmin = np.min(mt_hisnr)\n", + "vmax = np.max(mt_hisnr)\n", + "norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "print(f\"{vmin=}, {vmax=}\")\n", + "print(mt_hisnr.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target='hard_time'\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(mt_hisnr[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "fig.savefig(figloc+'/dpratio_vs_hardtime_w_mass_%dvars.png' % NPARS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 4b73e5fa3b103492e0cab45b28a3284cffafaceb Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 11:03:22 -0700 Subject: [PATCH 140/291] Update calibration function to correctly asses number of trials --- .../calibration_function.ipynb | 86 +++++++++++-------- .../tk10C_varymchar0_ptacalib.ipynb | 10 ++- 2 files changed, 57 insertions(+), 39 deletions(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index c71e1f7a..0a3e5f82 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -104,6 +104,7 @@ "metadata": {}, "outputs": [], "source": [ + "NREALS = nreals\n", "NPSRS = 40\n", "SIG_START = 1e-7\n", "SIG_MIN = 1e-9\n", @@ -116,7 +117,47 @@ "metadata": {}, "outputs": [], "source": [ - "print(hc_bg_all.shape)" + "# def get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad, nreals=NREALS):\n", + "# all_dp = np.zeros((trials, nreals))\n", + "# # median_tot = 0\n", + "# for ii in range(trials):\n", + "# # build PTA\n", + "# phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + "# thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + "# # sigmas = np.ones_like(phis)*sigma\n", + "# psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma,\n", + "# phi=phis, theta=thetas)\n", + "# all_dp[ii] = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", + "# # print(f'{dp_bg=}')\n", + "# avg_dp = np.mean(all_dp)\n", + "# std_dp = np.std(all_dp)\n", + "# # median_tot+=np.median(dp_bg) #, np.std(dp_bg))\n", + "# return avg_dp, std_dp\n", + "\n", + "# def quick_pta_calibration(hc_bg, fobs, maxtrials=2, debug=False,\n", + "# sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS):\n", + "# assert maxtrials>1, \"'maxtrials' must be >1\"\n", + "# dur = 1.0/fobs[0]\n", + "# cad = 1.0/(2*fobs[-1])\n", + "# sigma=sig_start\n", + "\n", + "# avg_dp = 0\n", + "# trials=1\n", + "# while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + "# avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", + "# fobs=fobs, dur=dur, cad=cad)\n", + "# if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", + " \n", + "# if avg_dp>0.4 and avg_dp<0.5:\n", + "# trials=maxtrials\n", + "\n", + "# if avg_dp>=0.51: # avg_dp too high, raise sigma\n", + "# sig_min = sigma\n", + "# sigma = np.random.uniform(sig_min, sig_max)\n", + "# elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", + "# sig_max = sigma\n", + "# sigma = np.random.uniform(sig_min, sig_max) \n", + "# return sigma, avg_dp, std_dp" ] }, { @@ -150,14 +191,18 @@ " sigma=sig_start\n", "\n", " avg_dp = 0\n", - " trials=1\n", - " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + " trials = 1\n", + " enough_trials = False\n", + " while avg_dp<.495 or avg_dp>.505 or enough_trials==False: # must be within the desired target range using the max number of trials\n", " avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", " fobs=fobs, dur=dur, cad=cad)\n", " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", " \n", " if avg_dp>0.4 and avg_dp<0.5:\n", - " trials=maxtrials\n", + " if trials == maxtrials:\n", + " enough_trials=True\n", + " else:\n", + " trials=maxtrials\n", "\n", " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", " sig_min = sigma\n", @@ -174,38 +219,7 @@ "metadata": {}, "outputs": [], "source": [ - "def quick_pta_calibration(hc_bg, maxtrials=2, debug=False):\n", - " assert maxtrials>1, \"'maxtrials' must be >1\"\n", - " avg_dp = 0\n", - " sigma = SIG_START\n", - " sig_min = SIG_MIN\n", - " sig_max = SIG_MAX\n", - " trials=1\n", - " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", - " avg_dp = get_dpbg(hc_bg, npsrs=NPSRS, sigma=sigma, trials=trials)\n", - " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", - " \n", - " if avg_dp>0.4 and avg_dp<0.5:\n", - " trials=maxtrials\n", - "\n", - " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", - " sig_min = sigma\n", - " sigma = np.random.uniform(sig_min, sig_max)\n", - " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", - " sig_max = sigma\n", - " sigma = np.random.uniform(sig_min, sig_max)\n", - " return sigma\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%timeit sigma=quick_pta_calibration(hc_bg_all[nsort[0]], maxtrials=2)\n", + "sigma=quick_pta_calibration(hc_bg_all[nsort[0]], fobs=fobs, maxtrials=2)\n", "print(sigma)" ] }, diff --git a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb index 57675dd1..839fdf68 100644 --- a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb @@ -187,14 +187,18 @@ " sigma=sig_start\n", "\n", " avg_dp = 0\n", - " trials=1\n", - " while avg_dp<.495 or avg_dp>.505 or trials==1:\n", + " trials = 1\n", + " enough_trials = False\n", + " while avg_dp<.495 or avg_dp>.505 or enough_trials==False: # must be within the desired target range using the max number of trials\n", " avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", " fobs=fobs, dur=dur, cad=cad)\n", " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", " \n", " if avg_dp>0.4 and avg_dp<0.5:\n", - " trials=maxtrials\n", + " if trials == maxtrials:\n", + " enough_trials=True\n", + " else:\n", + " trials=maxtrials\n", "\n", " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", " sig_min = sigma\n", From f63c87a95531d6ebab4ce5328b7b284af917ab71 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 11:18:23 -0700 Subject: [PATCH 141/291] Try calibration with scipy.optimize.fsolve. --- .../calibration_function.ipynb | 40 +++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index 0a3e5f82..543ecf95 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -210,7 +210,7 @@ " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", " sig_max = sigma\n", " sigma = np.random.uniform(sig_min, sig_max) \n", - " return sigma, avg_dp, std_dp" + " return sigma, avg_dp, std_dp\n" ] }, { @@ -219,8 +219,42 @@ "metadata": {}, "outputs": [], "source": [ - "sigma=quick_pta_calibration(hc_bg_all[nsort[0]], fobs=fobs, maxtrials=2)\n", - "print(sigma)" + "def sigma_function(sigma, hc_bg=hc_bg_all[nsort[0]], npsrs=NPSRS, trials=3, fobs=fobs, nreals=NREALS):\n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " all_dp = np.zeros((trials, nreals))\n", + " for ii in range(trials):\n", + " # build PTA\n", + " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", + " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", + " print(f\"{sigma=}\")\n", + " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma[0],\n", + " phi=phis, theta=thetas)\n", + " # calculate bg dp for this trial\n", + " all_dp[ii] = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", + " # find mean dp of all trials\n", + " avg_dp = np.mean(all_dp)\n", + "\n", + " # function that we want to be zero\n", + " zero = avg_dp-0.5\n", + " return zero" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "root = sp.optimize.fsolve(sigma_function, SIG_START)\n", + "print(get_dpbg(hc_bg_all[nn], NPSRS, root, 3, fobs, dur, cad, nreals=NREALS))" ] }, { From f474191fa4e43723cd4df890df3790efca9bac5e Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 11:29:46 -0700 Subject: [PATCH 142/291] Update plot saving to all use the assigned target param at the top --- .../tk10C_varymchar0_ptacalib.ipynb | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb index 839fdf68..41161061 100644 --- a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb @@ -40,7 +40,9 @@ "NPARS = 21\n", "\n", "NPSRS = 40\n", - "NSKIES = 25" + "NSKIES = 25\n", + "TARGET = 'gsmf_mchar0_log10'\n", + "TITLE = '$\\log( M_\\mathrm{char,0} / \\mathrm{M}_\\odot )$'" ] }, { @@ -144,8 +146,9 @@ "outputs": [], "source": [ "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", - "name = '/gsmf_mchar0_%dvariations' % NPARS\n", - "filename = path +name+'.npz'" + "name = '/%s_%dvariations' % (TARGET, NPARS)\n", + "filename = path +name+'.npz'\n", + "print(filename)" ] }, { @@ -230,7 +233,7 @@ " # get data (not dsdat_)\n", " if RECONSTRUCT:\n", " params_list = np.linspace(0,1,NPARS)\n", - " data, params, temp = vary_parameter('gsmf_mchar0_log10', params_list=params_list, get_ds=False)\n", + " data, params, temp = vary_parameter(target_param=TARGET, params_list=params_list, get_ds=False)\n", " else:\n", " file = np.load(filename, allow_pickle=True)\n", " print(file.files)\n", @@ -245,7 +248,7 @@ " _dsdat = detstats.detect_pspace_model(\n", " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, sigma, NSKIES)\n", " dsdat.append(_dsdat)\n", - " np.savez((path +'/hardtime_%dvars_%dpsrs_calibrated.npz' % (NPARS, NPSRS,)),\n", + " np.savez((path +'/%s_%dvars_%dpsrs_calibrated.npz' % (TARGET, NPARS, NPSRS,)),\n", " data = data, dsdat=dsdat, params=params)" ] }, @@ -315,7 +318,7 @@ "\n", "# return fig\n", "\n", - "def plot_dpss_vs_dpbg(dsdat, params, target_param='hard_time', use_ev=True):\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", @@ -327,7 +330,7 @@ " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", " handles.append(hh)\n", - " ax.legend(handles=handles, loc = 'lower left', title='$\\\\tau_\\mathrm{hard}$',\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", " ncols=4, title_fontsize=12)\n", " # ax.set_aspect(1)\n", " # xx = fobs_cents*YR\n", @@ -338,7 +341,7 @@ "\n", "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", - "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\gamma_\\mathrm{outer}=%.2f$' % (params[0]['hard_gamma_inner'], 2.5)\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", "print(text)\n", "\n", "param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", @@ -347,7 +350,7 @@ "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", "fig1.tight_layout()\n", - "fig1.savefig('/Users/emigardiner/GWs/holodeck/output/figures/params'+'/ss_vs_bg_w_hardtime_21vars.png')\n", + "fig1.savefig(param_path+f'/ss_vs_bg_w_{TARGET}_21vars.png')\n", "\n", "\n", "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", @@ -362,7 +365,7 @@ "outputs": [], "source": [ "\n", - "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "xlabel=TITLE\n", "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", "colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", "\n", @@ -371,7 +374,7 @@ "ax.set_ylabel(ylabel, fontsize=14)\n", "ax.set_xlabel(xlabel, fontsize=14)\n", "\n", - "target='hard_time'\n", + "target=TARGET\n", "xx = []\n", "yy = []\n", "for ii, par in enumerate(params):\n", @@ -416,6 +419,14 @@ "outputs": [], "source": [] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, { "cell_type": "code", "execution_count": null, @@ -449,13 +460,21 @@ "print(mt_hisnr.shape)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "xlabel='$\\\\tau_\\mathrm{hard}$'\n", + "xlabel=TITLE\n", "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", "cmap = cm.rainbow\n", @@ -464,7 +483,7 @@ "ax.set_ylabel(ylabel, fontsize=14)\n", "ax.set_xlabel(xlabel, fontsize=14)\n", "\n", - "target='hard_time'\n", + "target=TARGET\n", "xx = []\n", "yy = []\n", "for ii, par in enumerate(params):\n", @@ -483,8 +502,10 @@ "# for rr in range(len(yy[0])):\n", "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", + "fig.tight_layout()\n", + "\n", "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", - "fig.savefig(figloc+'/dpratio_vs_hardtime_w_mass_%dvars.png' % NPARS)" + "fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars.png' % (TARGET, NPARS))" ] }, { From 7218478acf3af5058d776a8a73450a90457f4ce6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 13:39:41 -0700 Subject: [PATCH 143/291] Calibrate each individual realization of a sample using binary_pta_calibration. --- .../calibration_function.ipynb | 199 +++++++++++++++++- 1 file changed, 189 insertions(+), 10 deletions(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index 543ecf95..cfcf46e1 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -73,6 +73,15 @@ "print(nn, fobs[fidx]*YR, hc_ref15)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_bg = detstats.detect_bg_pta" + ] + }, { "cell_type": "code", "execution_count": null, @@ -184,8 +193,7 @@ " return avg_dp, std_dp\n", "\n", "def quick_pta_calibration(hc_bg, fobs, maxtrials=2, debug=False,\n", - " sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS):\n", - " assert maxtrials>1, \"'maxtrials' must be >1\"\n", + " sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS,):\n", " dur = 1.0/fobs[0]\n", " cad = 1.0/(2*fobs[-1])\n", " sigma=sig_start\n", @@ -210,7 +218,185 @@ " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", " sig_max = sigma\n", " sigma = np.random.uniform(sig_min, sig_max) \n", - " return sigma, avg_dp, std_dp\n" + " return sigma, avg_dp, std_dp\n", + "\n", + "def binary_pta_calibration(hc_bg, fobs, maxtrials=2, debug=False,\n", + " sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, npsrs=NPSRS,):\n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " sigma=sig_start\n", + "\n", + " avg_dp = 0\n", + " trials = 1\n", + " enough_trials = False\n", + " while avg_dp<.495 or avg_dp>.505 or enough_trials==False: # must be within the desired target range using the max number of trials\n", + " avg_dp, std_dp = get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials,\n", + " fobs=fobs, dur=dur, cad=cad)\n", + " if debug: print(f\"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}\")\n", + " \n", + " if avg_dp>0.4 and avg_dp<0.5:\n", + " if trials == maxtrials:\n", + " enough_trials=True\n", + " else:\n", + " trials=maxtrials\n", + "\n", + " if avg_dp>=0.51: # avg_dp too high, raise sigma\n", + " sig_min = sigma\n", + " sigma = np.mean([sig_min, sig_max])\n", + " elif avg_dp<=0.49: # avg_dp too low, decrease sigma\n", + " sig_max = sigma\n", + " sigma = np.mean([sig_min, sig_max]) \n", + " return sigma, avg_dp, std_dp" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def logmean(arr1, axis=None):\n", + " \"\"\" Get the geometric (log space) mean over two arrays \"\"\"\n", + " log1 = np.log10(arr1)\n", + " logmean = np.mean(log1, axis=axis)\n", + " mean = 10**logmean\n", + " return mean\n", + "\n", + "print('%.2e' % logmean([0.001, 0.01]))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{nreals=}\")\n", + "sigma, avg_dp, std_dp = quick_pta_calibration(hc_bg_all[nn], fobs, maxtrials=1)\n", + "print(f\"{sigma=:.3e}, {avg_dp=:.3f}, {std_dp=:.3f}\")\n", + "%timeit sigma, avg_dp, std_dp = quick_pta_calibration(hc_bg_all[nn], fobs, maxtrials=1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{nreals=}\")\n", + "sigma, avg_dp, std_dp = binary_pta_calibration(hc_bg_all[nn], fobs, maxtrials=1)\n", + "print(f\"{sigma=:.3e}, {avg_dp=:.3f}, {std_dp=:.3f}\")\n", + "%timeit sigma, avg_dp, std_dp = binary_pta_calibration(hc_bg_all[nn], fobs, maxtrials=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{nreals=}\")\n", + "sigma, avg_dp, std_dp = quick_pta_calibration(hc_bg_all[nn], fobs, maxtrials=2)\n", + "print(f\"{sigma=:.3e}, {avg_dp=:.2f}, {std_dp=:.3f}\")\n", + "%timeit sigma, avg_dp, std_dp = quick_pta_calibration(hc_bg_all[nn], fobs, maxtrials=2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{nreals=}\")\n", + "sigma, avg_dp, std_dp = binary_pta_calibration(hc_bg_all[nn], fobs, maxtrials=2)\n", + "print(f\"{sigma=:.3e}, {avg_dp=:.3f}, {std_dp=:.3f}\")\n", + "%timeit sigma, avg_dp, std_dp = binary_pta_calibration(hc_bg_all[nn], fobs, maxtrials=2)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Function from detstats.py" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{nreals=}\")\n", + "sigma, avg_dp, std_dp = detstats.binary_pta_calibration(hc_bg_all[nn], fobs, NPSRS, maxtrials=1)\n", + "print(f\"{sigma=:.3e}, {avg_dp=:.3f}, {std_dp=:.3f}\")\n", + "%timeit sigma, avg_dp, std_dp = detstats.binary_pta_calibration(hc_bg_all[nn], fobs, NPSRS, maxtrials=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{nreals=}\")\n", + "sigma, avg_dp, std_dp = detstats.binary_pta_calibration(hc_bg_all[nn], fobs, NPSRS, maxtrials=5)\n", + "print(f\"{sigma=:.3e}, {avg_dp=:.3f}, {std_dp=:.3f}\")\n", + "%timeit sigma, avg_dp, std_dp = detstats.binary_pta_calibration(hc_bg_all[nn], fobs, NPSRS, maxtrials=5)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Individual Realizations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_bg = hc_bg_all[nn]\n", + "\n", + "import time\n", + "\n", + "def calibrate_every_real(hc_bg, fobs, npsrs, maxtrials):\n", + " nreals = hc_bg.shape[-1]\n", + " rsigmas = np.zeros(nreals)\n", + " avg_dps = np.zeros(nreals)\n", + " std_dps = np.zeros(nreals)\n", + " for rr in range(nreals):\n", + " hc_bg_rr = hc_bg[:,rr:rr+1]\n", + " # print(hc_bg_rr.shape)\n", + " rsigmas[rr], avg_dps[rr], std_dps[rr] = detstats.binary_pta_calibration(\n", + " hc_bg_rr, fobs, npsrs, maxtrials, sig_min=1e-8, sig_max=1e-4\n", + " )\n", + " return rsigmas, avg_dps, std_dps\n", + "start_time = time.time()\n", + "rsigmas, avg_dps, std_dps = calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 2)\n", + "print(f\"{time.time() - start_time} s\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time rsigmas, avg_dps, std_dps = calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 1)\n", + "%time rsigmas, avg_dps, std_dps = calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 2)\n", + "%time rsigmas, avg_dps, std_dps = calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 3)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Try with Fsolve" ] }, { @@ -240,13 +426,6 @@ " return zero" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, From 564e7e85d0e99034fca492e2e1e309f88022a5e1 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 13:45:41 -0700 Subject: [PATCH 144/291] Add calibration functions to detstats.py, including binary_pta_calibration, _get_dpbg, and calibrate_every_real(). --- holodeck/detstats.py | 64 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 8c850b6a..eb856dff 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1981,3 +1981,67 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, return dsdata ############################ Calibrate PTA ############################# + +def binary_pta_calibration(hc_bg, fobs, npsrs, maxtrials=2, debug=False, + sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, ): + """ Calibrate the PTA to a 50% target DP for a given model, average over many realizations + + """ + dur = 1.0/fobs[0] + cad = 1.0/(2*fobs[-1]) + sigma=sig_start + + avg_dp = 0 + trials = 1 + enough_trials = False + while avg_dp<.495 or avg_dp>.505 or enough_trials==False: # must be within the desired target range using the max number of trials + avg_dp, std_dp = _get_dpbg(hc_bg, npsrs=npsrs, sigma=sigma, trials=trials, + fobs=fobs, dur=dur, cad=cad) + if debug: print(f"{avg_dp=}, {sigma=}, {sig_min=}, {sig_max=}, {trials=}") + + # if we're close, raise the number of trials + if avg_dp>0.4 and avg_dp<0.5: + if trials == maxtrials: + enough_trials=True + else: + trials=maxtrials + + if avg_dp>=0.51: # avg_dp too high, raise sigma + sig_min = sigma + sigma = np.mean([sig_min, sig_max]) + elif avg_dp<=0.49: # avg_dp too low, decrease sigma + sig_max = sigma + sigma = np.mean([sig_min, sig_max]) + return sigma, avg_dp, std_dp + +def _get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad,): + nreals = hc_bg.shape[-1] + all_dp = np.zeros((trials, nreals)) + + for ii in range(trials): + # build PTA + phis = np.random.uniform(0, 2*np.pi, size = npsrs) + thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + phi=phis, theta=thetas) + # calculate bg detprob of each realizations for the given PTA + all_dp[ii] = detect_bg_pta(psrs, fobs, hc_bg=hc_bg) + + avg_dp = np.mean(all_dp) + std_dp = np.std(all_dp) + return avg_dp, std_dp + +def calibrate_every_real(hc_bg, fobs, npsrs, maxtrials, + sig_start = 1e-6, sig_min=1e-9, sig_max=1e-4, debug=False): + nreals = hc_bg.shape[-1] + rsigmas = np.zeros(nreals) + avg_dps = np.zeros(nreals) + std_dps = np.zeros(nreals) + for rr in range(nreals): + hc_bg_rr = hc_bg[:,rr:rr+1] + # print(hc_bg_rr.shape) + rsigmas[rr], avg_dps[rr], std_dps[rr] = binary_pta_calibration( + hc_bg_rr, fobs, npsrs, maxtrials, debug=debug, + sig_start = sig_start, sig_min=sig_min, sig_max=sig_max, + ) + return rsigmas, avg_dps, std_dps \ No newline at end of file From 971707f43971659620da46daaef07c2549224145 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 13:46:04 -0700 Subject: [PATCH 145/291] Plot calibrated PTA results for varying hard time and varying mchar0 --- .../parameter_investigation/tk10B_varyhard_ptacalib.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb index a2e4c444..a2bc998f 100644 --- a/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10B_varyhard_ptacalib.ipynb @@ -36,7 +36,8 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "RECONSTRUCT = False\n", + "RECONSTRUCT = True\n", + "JUST_DETSTATS=False\n", "NPARS = 21\n", "\n", "NPSRS = 40\n", @@ -250,7 +251,6 @@ "source": [ "NPSRS = 40\n", "\n", - "JUST_DETSTATS = True\n", "if JUST_DETSTATS or RECONSTRUCT:\n", " dsdat = []\n", " for ii, _data in enumerate(data):\n", @@ -343,7 +343,7 @@ "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", "fig1.tight_layout()\n", - "fig1.savefig('/Users/emigardiner/GWs/holodeck/output/figures/params'+'/ss_vs_bg_w_hardtime_21vars.png')\n", + "# fig1.savefig('/Users/emigardiner/GWs/holodeck/output/figures/params'+'/ss_vs_bg_w_hardtime_21vars.png')\n", "\n", "\n", "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", From 579372db2705ca8529037acfadb47434b6807ed0 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 13:46:32 -0700 Subject: [PATCH 146/291] Time every realization calibration for varying ntrials --- .../detstats_functions/calibration_function.ipynb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index cfcf46e1..2248a7cb 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -391,6 +391,15 @@ "%time rsigmas, avg_dps, std_dps = calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 3)\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%timeit rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 5)" + ] + }, { "attachments": {}, "cell_type": "markdown", From 4c146e2a23013061df8a5d94f57474e95bdf9dea Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 14:23:17 -0700 Subject: [PATCH 147/291] Time different ntrials, note necessity for a 'bad guess check' when using many trials. --- .../calibration_function.ipynb | 27 ++++++++++++++++++- holodeck/detstats.py | 2 ++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index 2248a7cb..0e8c5361 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -397,9 +397,34 @@ "metadata": {}, "outputs": [], "source": [ - "%timeit rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 5)" + "%time rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 4)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 5, debug=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "attachments": {}, "cell_type": "markdown", diff --git a/holodeck/detstats.py b/holodeck/detstats.py index eb856dff..000bd934 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1986,6 +1986,8 @@ def binary_pta_calibration(hc_bg, fobs, npsrs, maxtrials=2, debug=False, sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, ): """ Calibrate the PTA to a 50% target DP for a given model, average over many realizations + # BUG: This seems to get stuck on bad guesses, when requiring high max trials. + # TODO: Set up a check for bar guesses. """ dur = 1.0/fobs[0] cad = 1.0/(2*fobs[-1]) From 804ee64cdcaea1c8c9c9a10b6974feff7f5da7e4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 15:03:06 -0700 Subject: [PATCH 148/291] Add note to change mass normalization to use single source DPs (gamma_ssi) instead of just highest SNR frequency bin --- .../parameter_investigation/tk10C_varymchar0_ptacalib.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb index 41161061..5bf0ae9a 100644 --- a/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10C_varymchar0_ptacalib.ipynb @@ -42,7 +42,9 @@ "NPSRS = 40\n", "NSKIES = 25\n", "TARGET = 'gsmf_mchar0_log10'\n", - "TITLE = '$\\log( M_\\mathrm{char,0} / \\mathrm{M}_\\odot )$'" + "TITLE = '$\\log( M_\\mathrm{char,0} / \\mathrm{M}_\\odot )$'\n", + "\n", + "# TODO: Change mass normalization to use single source with highest gamma_ssi!" ] }, { From 78c5b15a389e53fe390f4a4dd1fbd387686ec405 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 15:16:48 -0700 Subject: [PATCH 149/291] Remove snr_ss lib calculation when save_ssi is false; separate pta formation into _build_pta --- holodeck/detstats.py | 98 ++++++++++++++++++++++++++++++-------------- 1 file changed, 68 insertions(+), 30 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 000bd934..5f62f0a4 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1594,10 +1594,11 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, Fraction of realizations with a single source detection, for each sample. df_bg : (N,) 1Darray Fraction of realizations with a background detection, for each sample. - ev_ss : (N,) 1Darray + ev_ss : (N,R,) NDarray Expectation number of single source detections, averaged across realizations, for each sample. + TODO: Update, no need to return ss_snr """ # Read in hdf file @@ -1611,7 +1612,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, hc_ss = ssfile['hc_ss'][...] hc_bg = ssfile['hc_bg'][...] shape = hc_ss.shape - nsamp, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3] + nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3] # Assign output folder import os @@ -1636,30 +1637,34 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, # Calculate DPs, SNRs, and DFs if debug: print('Calculating SS and BG detection statistics.') - dp_ss = np.zeros((nsamp, nreals, nskies)) # (N,R,S) - dp_bg = np.zeros((nsamp, nreals)) # (N,R) - snr_ss = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) - snr_bg = np.zeros((nsamp, nfreqs, nreals)) - df_ss = np.zeros(nsamp) - df_bg = np.zeros(nsamp) - ev_ss = np.zeros((nsamp, nreals, nskies)) - if save_ssi: gamma_ssi = np.zeros((nsamp, nfreqs, nreals, nskies, nloudest)) + dp_ss = np.zeros((nsamps, nreals, nskies)) # (N,R,S) + dp_bg = np.zeros((nsamps, nreals)) # (N,R) + snr_bg = np.zeros((nsamps, nfreqs, nreals)) + df_ss = np.zeros(nsamps) + df_bg = np.zeros(nsamps) + ev_ss = np.zeros((nsamps, nreals, nskies)) + if save_ssi: + snr_ss = np.zeros((nsamps, nfreqs, nreals, nskies, nloudest)) + gamma_ssi = np.zeros((nsamps, nfreqs, nreals, nskies, nloudest)) # # one time calculations # Num = nfreqs * nloudest # number of single sources in a single strain realization (F*L) # Fe_bar = _Fe_thresh(Num) # scalar - for nn in range(nsamp): - if debug: print('on sample nn=%d out of N=%d' % (nn,nsamp)) + for nn in range(nsamps): + if debug: print('on sample nn=%d out of N=%d' % (nn,nsamps)) dp_bg[nn,:], snr_bg[nn,...] = detect_bg_pta(psrs, fobs, hc_bg[nn], ret_snr=True) vals_ss = detect_ss_pta(psrs, fobs, hc_ss[nn], hc_bg[nn], ret_snr=True, gamma_cython=True, snr_cython=snr_cython, theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) - dp_ss[nn,:,:], snr_ss[nn,...] = vals_ss[0], vals_ss[1], + dp_ss[nn,:,:] = vals_ss[0] + if save_ssi: + snr_ss[nn] = vals_ss[1] + gamma_ssi[nn] = vals_ss[2] df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) ev_ss[nn] = expval_of_ss(vals_ss[2]) - if save_ssi: gamma_ssi[nn] = vals_ss[2] + if plot: fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], @@ -1670,8 +1675,8 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, plt.close(fig) if debug: print('Saving npz files and allsamp plots.') - fig1 = plot_detprob(dp_ss, dp_bg, nsamp) - fig2 = plot_detfrac(df_ss, df_bg, nsamp, thresh) + fig1 = plot_detprob(dp_ss, dp_bg, nsamps) + fig2 = plot_detfrac(df_ss, df_bg, nsamps, thresh) fig1.savefig(output_dir+'/allsamp_detprobs.png', dpi=300) fig2.savefig(output_dir+'/allsamp_detfracs.png', dpi=300) plt.close(fig1) @@ -1681,18 +1686,28 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss, gamma_ssi=gamma_ssi) else: np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, - snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss) + snr_bg=snr_bg, ev_ss = ev_ss) # return dictionary if ret_dict: data = { 'dp_ss':dp_ss, 'dp_bg':dp_bg, 'df_ss':df_ss, 'df_bg':df_bg, - 'snr_ss':snr_ss, 'snr_bg':snr_bg, 'ev_ss':ev_ss + 'snr_bg':snr_bg, 'ev_ss':ev_ss } - if save_ssi: data.update({'gamma_ssi':gamma_ssi}) + if save_ssi: + data.update({'gamma_ssi':gamma_ssi}) + data.update({'snr_ss':snr_ss}) return data return +def _build_pta(npsrs, sigma, dur, cad): + # build PTA + phis = np.random.uniform(0, 2*np.pi, size = npsrs) + thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + # sigmas = np.ones_like(phis)*sigma + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + phi=phis, theta=thetas) + return psrs def _build_skies(nfreqs, nskies, nloudest): theta_ss = np.random.uniform(0, np.pi, size = nfreqs * nskies * nloudest).reshape(nfreqs, nskies, nloudest) @@ -1808,7 +1823,7 @@ def plot_sample_nn(fobs, hc_ss, hc_bg, dp_ss, dp_bg, df_ss, df_bg, nn): return fig -def plot_detprob(dp_ss_all, dp_bg_all, nsamp): +def plot_detprob(dp_ss_all, dp_bg_all, nsamps): """ Plot detection probability for many samples. Paramaters @@ -1826,11 +1841,11 @@ def plot_detprob(dp_ss_all, dp_bg_all, nsamp): fig, ax = plt.subplots(figsize=(6.5,4)) ax.set_xlabel('Param Space Sample') ax.set_ylabel('Detection Probability, $\gamma$') - ax.errorbar(np.arange(nsamp), np.mean(dp_bg_all, axis=1), + ax.errorbar(np.arange(nsamps), np.mean(dp_bg_all, axis=1), yerr = np.std(dp_bg_all, axis=1), linestyle='', marker='d', capsize=5, color='cornflowerblue', alpha=0.5, label = r'$\langle \gamma_\mathrm{BG} \rangle$') - ax.errorbar(np.arange(nsamp), np.mean(dp_ss_all, axis=(1,2)), + ax.errorbar(np.arange(nsamps), np.mean(dp_ss_all, axis=(1,2)), yerr = np.std(dp_ss_all, axis=(1,2)), linestyle='', marker='o', capsize=5, color='orangered', alpha=0.5, label = r'$\langle \gamma_\mathrm{SS} \rangle$') @@ -1843,7 +1858,7 @@ def plot_detprob(dp_ss_all, dp_bg_all, nsamp): return fig -def plot_detfrac(df_ss, df_bg, nsamp, thresh): +def plot_detfrac(df_ss, df_bg, nsamps, thresh): """ Plot detection fraction for many samples. Paramaters @@ -1859,9 +1874,9 @@ def plot_detfrac(df_ss, df_bg, nsamp, thresh): fig : figure object """ fig, ax = plt.subplots(figsize=(6.5,4)) - ax.plot(np.arange(nsamp), df_bg, color='cornflowerblue', label='BG', + ax.plot(np.arange(nsamps), df_bg, color='cornflowerblue', label='BG', marker='d', alpha=0.5) - ax.plot(np.arange(nsamp), df_ss, color='orangered', label='SS', + ax.plot(np.arange(nsamps), df_ss, color='orangered', label='SS', marker='o', alpha=0.5) ax.set_xlabel('Param Space Sample') ax.set_ylabel('Detection Fraction') @@ -1945,11 +1960,12 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, # build PTA if debug: print('Building pulsar timing array.') - phis = np.random.uniform(0, 2*np.pi, size = npsrs) - thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) - # sigmas = np.ones_like(phis)*sigma - psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, - phi=phis, theta=thetas) + psrs = _build_pta(npsrs, sigma, dur, cad) + # phis = np.random.uniform(0, 2*np.pi, size = npsrs) + # thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + # # sigmas = np.ones_like(phis)*sigma + # psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + # phi=phis, theta=thetas) # Build ss skies if debug: print('Building ss skies.') @@ -1980,7 +1996,10 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, return dsdata + +######################################################################## ############################ Calibrate PTA ############################# +######################################################################## def binary_pta_calibration(hc_bg, fobs, npsrs, maxtrials=2, debug=False, sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, ): @@ -2035,6 +2054,25 @@ def _get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad,): def calibrate_every_real(hc_bg, fobs, npsrs, maxtrials, sig_start = 1e-6, sig_min=1e-9, sig_max=1e-4, debug=False): + """ Calibrate the PTA independently for each background realizations + + Parameters + ---------- + hc_bg : (F,R) Ndarray + fobs : (F,) 1Darray + npsrs : integer + maxtrials : integer + + Returns + ------- + rsigmas : (R,) 1Darray + Calibrated PTA white noise sigma for each realization. + avg_dps : (R,) 1Darray + Average background detprob across PTA realizations, calculated for the realization's PTA. + std_dps : (R,) 1Darray + Standard deviation among PTA realizations for the given bg realizations. + + """ nreals = hc_bg.shape[-1] rsigmas = np.zeros(nreals) avg_dps = np.zeros(nreals) From 1e6d48010f338ac9ace629c9fbae134569097be3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 15:47:14 -0700 Subject: [PATCH 150/291] Use individual realization calibration in tk10D with hard_time --- .../tk10D_everyrealcalib.ipynb | 501 ++++++++++++++++++ 1 file changed, 501 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb new file mode 100644 index 00000000..ae550fcf --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb @@ -0,0 +1,501 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "RECONSTRUCT = False\n", + "JUST_DETSTATS = True\n", + "\n", + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+'/hardtime_21variations.npz'\n", + "save_data_to_file = path+'/hardtime_21vars_clbrt_reals.npz' \n", + "\n", + "NPARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'hard_time'\n", + "TITLE = '$\\log( M_\\mathrm{char,0} / \\mathrm{M}_\\odot )$'" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " get_ds=False, #npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES,\n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " dsdat = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if get_ds:\n", + " _dsdat = detstats.detect_pspace_model(\n", + " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + " dsdat.append(_dsdat)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params, dsdat)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if RECONSTRUCT) and Individual DetStats (if RECONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NPSRS = 40\n", + "\n", + "JUST_DETSTATS = True\n", + "if JUST_DETSTATS or RECONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if RECONSTRUCT:\n", + " params_list = np.linspace(0,1,NPARS)\n", + " data, params, temp = vary_parameter(target_param=TARGET, params_list=params_list, get_ds=False)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + "\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + "\n", + " # get calibrated sigmas for each realization\n", + " sigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg, fobs, NPSRS, maxtrials=1)\n", + " \n", + " # for each realization, get individual calibrated detstats \n", + " dp_ss = np.zeros((NREALS, NSKIES)) \n", + " dp_bg = np.zeros(NREALS)\n", + " snr_ss = np.zeros((NFREQS, NREALS, NSKIES, NLOUDEST))\n", + " snr_bg = np.zeros((NREALS))\n", + " gamma_ssi = np.zeros((NFREQS, NREALS, NSKIES, NLOUDEST))\n", + " # ev_ss = np.zeros\n", + " \n", + " for rr in range(NREALS):\n", + " # get psrs for the given calibrated realizations\n", + " psrs = detstats._build_pta(NPSRS, sigmas[rr], dur, cad)\n", + " # use those psrs to calculate realization detstats\n", + " _dp_bg, _snr_bg = detstats.detect_bg_pta(psrs, fobs, hc_bg[:,rr:rr+1], ret_snr=True)\n", + " print(f\"{_dp_bg.shape=}, {_snr_bg.shape=}\")\n", + " dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze()\n", + " _dp_ss, _snr_ss, _gamma_ssi = detstats.detect_ss_pta(\n", + " psrs, fobs, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], ret_snr=True)\n", + " print(f\"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=} \")\n", + " dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze()\n", + " ev_ss = detstats.expval_of_ss(gamma_ssi)\n", + " df_ss, df_bg = detstats.detfrac_of_reals(dp_ss, dp_bg)\n", + " _dsdat = {\n", + " 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, \n", + " 'dp_bg':dp_bg, 'snr_bg':snr_bg,\n", + " 'df_bg':df_bg, 'ev_ss':ev_ss,\n", + " }\n", + " dsdat.append(_dsdat)\n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ds in dsdat[:3]:\n", + " print(f\"{holo.utils.stats(ds['dp_bg'])=}\")\n", + " print(f\"{holo.utils.stats(ds['dp_ss'])=}\")\n", + " print(f\"{holo.utils.stats(ds['ev_ss'])=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# if RECONSTRUCT:\n", + "# params_list = np.linspace(0,1,NPARS)\n", + "# print(params_list)\n", + "# data, params, dsdat = vary_parameter('gsmf_mchar0_log10', params_list=params_list, get_ds=True)\n", + "# else:\n", + "# file = np.load(filename, allow_pickle=True)\n", + "# print(file.files)\n", + "# data = file['data']\n", + "# params = file['params']\n", + "# dsdat = file['dsdat']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def_draw_ev(ax):\n", + "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", + "# plt.rcParams[\"font.family\"] = \"serif\"\n", + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "\n", + "# def plot_evss_vs_dpbg(dsdat):\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + "\n", + "# fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + "# ylabel='$\\langle$ Single Source Detections $\\\\rangle_\\mathrm{skies}$')\n", + "# for ii, ds in enumerate(dsdat):\n", + "# draw_skies_vs_bg(ax, ds['ev_ss'], ds['dp_bg'], color=colors[ii])\n", + "# # xx = fobs_cents*YR\n", + "# # yy = dsdat['ev_ss']\n", + "\n", + "# return fig\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + " # ax.set_aspect(1)\n", + " # xx = fobs_cents*YR\n", + " # yy = dsdat['ev_ss']\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "# fig1.savefig(param_path+f'/ss_vs_bg_w_{TARGET}_21vars.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "xlabel=TITLE\n", + "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(NREALS)\n", + "print(dsdat[0]['snr_ss'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Get SS mass normalization\n", + "\n", + "ssmtot = []\n", + "ss_dp = []\n", + "mt_hisnr= np.zeros((NPARS, NREALS))\n", + "for ii,dat in enumerate(data):\n", + " # ssmtot.append(dat['sspar'][0])\n", + " snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + " # print(snr_ss.shape)\n", + " ssmtot = dat['sspar'][0]\n", + " # print(ssmtot.shape)\n", + " # for each realization, find the frequency with the loudest single source\n", + " for rr in range(len(snr_ss[0])):\n", + " argmax = np.argmax(snr_ss[:,rr,:,:])\n", + " fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + " mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "vmin = np.min(mt_hisnr)\n", + "vmax = np.max(mt_hisnr)\n", + "norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "print(f\"{vmin=}, {vmax=}\")\n", + "print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(mt_hisnr[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "# for rr, yi in enumerate(yy):\n", + "# ax.scatter(xx,yy[:,rr])\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "# fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars.png' % (TARGET, NPARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 62e7f44ccbd55060528e0c28b5a362d7e2e4c020 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 15:59:34 -0700 Subject: [PATCH 151/291] Separate detstats and data calculations, check for load files if CONSTRUCT is True --- .../tk10D_everyrealcalib.ipynb | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb index ae550fcf..994ff256 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb @@ -36,14 +36,10 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "RECONSTRUCT = False\n", + "CONSTRUCT = True\n", "JUST_DETSTATS = True\n", "\n", - "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", - "load_data_from_file = path+'/hardtime_21variations.npz'\n", - "save_data_to_file = path+'/hardtime_21vars_clbrt_reals.npz' \n", - "\n", - "NPARS = 21\n", + "NPARS = 6\n", "\n", "NPSRS = 40\n", "NSKIES = 25\n", @@ -51,6 +47,23 @@ "TITLE = '$\\log( M_\\mathrm{char,0} / \\mathrm{M}_\\odot )$'" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NPARS}vars_clbrt_reals.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NPARS}vars_clbrt_reals.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -107,7 +120,7 @@ "\n", " data = []\n", " params = []\n", - " dsdat = []\n", + " # dsdat = []\n", " for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", @@ -124,17 +137,17 @@ " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", - " if get_ds:\n", - " _dsdat = detstats.detect_pspace_model(\n", - " _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", - " dsdat.append(_dsdat)\n", + " # if get_ds:\n", + " # _dsdat = detstats.detect_pspace_model(\n", + " # _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", + " # dsdat.append(_dsdat)\n", " if save_dir is not None:\n", " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", " print('saved to %s' % filename)\n", "\n", - " return (data, params, dsdat)" + " return (data, params) #, dsdat)" ] }, { @@ -142,7 +155,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Calculate Data (if RECONSTRUCT) and Individual DetStats (if RECONSTRUCT or JUST_DETSTAATS)" + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" ] }, { @@ -154,9 +167,9 @@ "NPSRS = 40\n", "\n", "JUST_DETSTATS = True\n", - "if JUST_DETSTATS or RECONSTRUCT:\n", + "if JUST_DETSTATS or CONSTRUCT:\n", " # get data (not dsdat_)\n", - " if RECONSTRUCT:\n", + " if CONSTRUCT:\n", " params_list = np.linspace(0,1,NPARS)\n", " data, params, temp = vary_parameter(target_param=TARGET, params_list=params_list, get_ds=False)\n", " else:\n", @@ -231,7 +244,7 @@ "metadata": {}, "outputs": [], "source": [ - "# if RECONSTRUCT:\n", + "# if CONSTRUCT:\n", "# params_list = np.linspace(0,1,NPARS)\n", "# print(params_list)\n", "# data, params, dsdat = vary_parameter('gsmf_mchar0_log10', params_list=params_list, get_ds=True)\n", From 1e97fb4b0baee72c452458ff66d136944c351d66 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 16:03:47 -0700 Subject: [PATCH 152/291] Add detect_pspace_model_clbrt_psrs() function to detstats.py --- holodeck/detstats.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 5f62f0a4..68722f9d 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1997,6 +1997,46 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, return dsdata +def detect_pspace_model_clbrt_psrs(fobs_cents, hc_ss, hc_bg, + npsrs, nskies, maxtrials=1, + thresh=DEF_THRESH, debug=False): + """ Detect pspace model using individual PTA calibration for each realization + + """ + dur = 1.0/fobs_cents[0] + cad = 1.0/(2*fobs_cents[-1]) + + nfreqs, nreals, nloudest = [*hc_ss.shape] + # get calibrated sigmas + sigmas, avg_dps, std_dps = calibrate_every_real(hc_bg, fobs_cents, npsrs, maxtrials=maxtrials) + + # form arrays for individual realization detstats + dp_ss = np.zeros((nreals, nskies)) + dp_bg = np.zeros(nreals) + snr_ss = np.zeros((nfreqs, nreals, nskies, nloudest)) + snr_bg = np.zeros((nreals)) + gamma_ssi = np.zeros((nfreqs, nreals, nskies, nloudest)) + + # for each realization, get individual detstats + for rr in range(nreals): + # get psrs for the given calibrated sigma + psrs = _build_pta(npsrs, sigmas[rr], dur, cad) + # use those psrs to calculate realization detstats + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) + dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() + _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], ret_snr=True) + dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() + ev_ss = expval_of_ss(gamma_ssi) + df_ss, df_bg = detfrac_of_reals(dp_ss, dp_bg) + _dsdat = { + 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, + 'dp_bg':dp_bg, 'snr_bg':snr_bg, + 'df_ss':df_ss, 'df_bg':df_bg, 'ev_ss':ev_ss, + } + return _dsdat + + ######################################################################## ############################ Calibrate PTA ############################# ######################################################################## From 489cdf1b02782061f2ecb585914b9ede77740519 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 16:15:50 -0700 Subject: [PATCH 153/291] Run everything with 3vars to make sure it's working, using dsdat code from detstats.py --- .../tk10D_everyrealcalib.ipynb | 184 +++++------------- 1 file changed, 53 insertions(+), 131 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb index 994ff256..f6534aff 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb @@ -38,8 +38,9 @@ "\n", "CONSTRUCT = True\n", "JUST_DETSTATS = True\n", + "SAVEFIGS = False\n", "\n", - "NPARS = 6\n", + "NPARS = 3\n", "\n", "NPSRS = 40\n", "NSKIES = 25\n", @@ -78,15 +79,7 @@ "metadata": {}, "outputs": [], "source": [ - "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", "param_names = pspace.param_names\n", "num_pars = len(param_names)\n", "pars = 0.5*np.ones(num_pars)" @@ -104,7 +97,6 @@ " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", " nreals=NREALS, nfreqs=NFREQS,\n", " pars=None, save_dir=None, \n", - " get_ds=False, #npsrs=NPSRS, sigma=SIGMA, nskies=NSKIES,\n", " ):\n", " # get the parameter names from this library-space\n", " param_names = pspace.param_names\n", @@ -120,7 +112,6 @@ "\n", " data = []\n", " params = []\n", - " # dsdat = []\n", " for ii, par in enumerate(params_list):\n", " pars[param_idx] = par\n", " print(f\"{ii=}, {pars=}\")\n", @@ -137,17 +128,13 @@ " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", " data.append(_data)\n", - " # if get_ds:\n", - " # _dsdat = detstats.detect_pspace_model(\n", - " # _data['fobs_cents'], _data['hc_ss'], _data['hc_bg'], NPSRS, SIGMA, NSKIES)\n", - " # dsdat.append(_dsdat)\n", " if save_dir is not None:\n", " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", " print('saved to %s' % filename)\n", "\n", - " return (data, params) #, dsdat)" + " return (data, params)" ] }, { @@ -171,7 +158,7 @@ " # get data (not dsdat_)\n", " if CONSTRUCT:\n", " params_list = np.linspace(0,1,NPARS)\n", - " data, params, temp = vary_parameter(target_param=TARGET, params_list=params_list, get_ds=False)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list, get_ds=False)\n", " else:\n", " file = np.load(load_data_from_file, allow_pickle=True)\n", " print(file.files)\n", @@ -187,73 +174,29 @@ " dsdat = []\n", " for ii, _data in enumerate(data):\n", " print(f\"{ii=}\")\n", - "\n", " # get strain info\n", " hc_bg = _data['hc_bg']\n", " hc_ss = _data['hc_ss']\n", - "\n", - " # get calibrated sigmas for each realization\n", - " sigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg, fobs, NPSRS, maxtrials=1)\n", - " \n", - " # for each realization, get individual calibrated detstats \n", - " dp_ss = np.zeros((NREALS, NSKIES)) \n", - " dp_bg = np.zeros(NREALS)\n", - " snr_ss = np.zeros((NFREQS, NREALS, NSKIES, NLOUDEST))\n", - " snr_bg = np.zeros((NREALS))\n", - " gamma_ssi = np.zeros((NFREQS, NREALS, NSKIES, NLOUDEST))\n", - " # ev_ss = np.zeros\n", - " \n", - " for rr in range(NREALS):\n", - " # get psrs for the given calibrated realizations\n", - " psrs = detstats._build_pta(NPSRS, sigmas[rr], dur, cad)\n", - " # use those psrs to calculate realization detstats\n", - " _dp_bg, _snr_bg = detstats.detect_bg_pta(psrs, fobs, hc_bg[:,rr:rr+1], ret_snr=True)\n", - " print(f\"{_dp_bg.shape=}, {_snr_bg.shape=}\")\n", - " dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze()\n", - " _dp_ss, _snr_ss, _gamma_ssi = detstats.detect_ss_pta(\n", - " psrs, fobs, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], ret_snr=True)\n", - " print(f\"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=} \")\n", - " dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze()\n", - " ev_ss = detstats.expval_of_ss(gamma_ssi)\n", - " df_ss, df_bg = detstats.detfrac_of_reals(dp_ss, dp_bg)\n", - " _dsdat = {\n", - " 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, \n", - " 'dp_bg':dp_bg, 'snr_bg':snr_bg,\n", - " 'df_bg':df_bg, 'ev_ss':ev_ss,\n", - " }\n", + " _dsdat = detstats.detect_pspace_model_clbrt_psrs(fobs, hc_ss, hc_bg, NPSRS, NSKIES, maxtrials=1)\n", " dsdat.append(_dsdat)\n", + " \n", " np.savez(save_data_to_file,\n", - " data = data, dsdat=dsdat, params=params)" + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for ds in dsdat[:3]:\n", - " print(f\"{holo.utils.stats(ds['dp_bg'])=}\")\n", - " print(f\"{holo.utils.stats(ds['dp_ss'])=}\")\n", - " print(f\"{holo.utils.stats(ds['ev_ss'])=}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "# if CONSTRUCT:\n", - "# params_list = np.linspace(0,1,NPARS)\n", - "# print(params_list)\n", - "# data, params, dsdat = vary_parameter('gsmf_mchar0_log10', params_list=params_list, get_ds=True)\n", - "# else:\n", - "# file = np.load(filename, allow_pickle=True)\n", - "# print(file.files)\n", - "# data = file['data']\n", - "# params = file['params']\n", - "# dsdat = file['dsdat']" + "# Plot" ] }, { @@ -262,9 +205,6 @@ "metadata": {}, "outputs": [], "source": [ - "# def_draw_ev(ax):\n", - "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", - "# plt.rcParams[\"font.family\"] = \"serif\"\n", "\n", "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", " color='k', mean=True):\n", @@ -279,19 +219,6 @@ " linestyle='', capsize=3, marker='o', alpha=0.5)\n", " return hh\n", "\n", - "\n", - "# def plot_evss_vs_dpbg(dsdat):\n", - "# colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", - "\n", - "# fig, ax = plot.figax(xlabel='Background Detection Probability', \n", - "# ylabel='$\\langle$ Single Source Detections $\\\\rangle_\\mathrm{skies}$')\n", - "# for ii, ds in enumerate(dsdat):\n", - "# draw_skies_vs_bg(ax, ds['ev_ss'], ds['dp_bg'], color=colors[ii])\n", - "# # xx = fobs_cents*YR\n", - "# # yy = dsdat['ev_ss']\n", - "\n", - "# return fig\n", - "\n", "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", @@ -306,9 +233,6 @@ " handles.append(hh)\n", " ax.legend(handles=handles, loc = 'lower left', title=title,\n", " ncols=4, title_fontsize=12)\n", - " # ax.set_aspect(1)\n", - " # xx = fobs_cents*YR\n", - " # yy = dsdat['ev_ss']\n", "\n", " fig.tight_layout()\n", " return fig\n", @@ -324,7 +248,7 @@ "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", "fig1.tight_layout()\n", - "# fig1.savefig(param_path+f'/ss_vs_bg_w_{TARGET}_21vars.png')\n", + "# if SAVEFIGS: fig1.savefig(param_path+f'/ss_vs_bg_w_{TARGET}_21vars.png')\n", "\n", "\n", "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", @@ -377,13 +301,11 @@ ] }, { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "print(NREALS)\n", - "print(dsdat[0]['snr_ss'].shape)" + "# Get Mass Normalization" ] }, { @@ -391,14 +313,41 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "# Get SS mass normalization\n", + "use_snr=False\n", + "# ssmtot = []\n", + "# ss_dp = []\n", + "if use_snr:\n", + " mt_hisnr= np.zeros((NPARS, NREALS))\n", + " for ii,dat in enumerate(data):\n", + " # ssmtot.append(dat['sspar'][0])\n", + " snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + " # print(snr_ss.shape)\n", + " ssmtot = dat['sspar'][0]\n", + " # print(ssmtot.shape)\n", + " # for each realization, find the frequency with the loudest single source\n", + " for rr in range(len(snr_ss[0])):\n", + " argmax = np.argmax(snr_ss[:,rr,:,:])\n", + " fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + " mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + " mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + " vmin = np.min(mt_hisnr)\n", + " vmax = np.max(mt_hisnr)\n", + " norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "print(f\"{vmin=}, {vmax=}\")\n", + "print(mt_hisnr.shape)" + ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "# Get Mass Normalization" + "# Any Normalization" ] }, { @@ -407,31 +356,8 @@ "metadata": {}, "outputs": [], "source": [ - "# Get SS mass normalization\n", - "\n", - "ssmtot = []\n", - "ss_dp = []\n", - "mt_hisnr= np.zeros((NPARS, NREALS))\n", - "for ii,dat in enumerate(data):\n", - " # ssmtot.append(dat['sspar'][0])\n", - " snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", - " # print(snr_ss.shape)\n", - " ssmtot = dat['sspar'][0]\n", - " # print(ssmtot.shape)\n", - " # for each realization, find the frequency with the loudest single source\n", - " for rr in range(len(snr_ss[0])):\n", - " argmax = np.argmax(snr_ss[:,rr,:,:])\n", - " fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", - " # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", - " mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", - "\n", - "mt_hisnr = np.log10(mt_hisnr/MSOL)\n", - "vmin = np.min(mt_hisnr)\n", - "vmax = np.max(mt_hisnr)\n", - "norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", - "\n", - "print(f\"{vmin=}, {vmax=}\")\n", - "print(mt_hisnr.shape)" + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass" ] }, { @@ -470,11 +396,7 @@ "xx = np.array(xx)\n", "yy = np.array(yy)\n", "print(yy.shape)\n", - "# for rr, yi in enumerate(yy):\n", - "# ax.scatter(xx,yy[:,rr])\n", "plot.draw_med_conf(ax, xx, yy)\n", - "# for rr in range(len(yy[0])):\n", - "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])\n", "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", "fig.tight_layout()\n", "\n", From 7720826b19ef94b2237cefa30b18b230c550e4c7 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 16:27:13 -0700 Subject: [PATCH 154/291] Plot using mass of highest DP single source, across sky realizations. --- .../tk10D_everyrealcalib.ipynb | 77 +++++++++++-------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb index f6534aff..e95aabcb 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb @@ -36,8 +36,8 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "CONSTRUCT = True\n", - "JUST_DETSTATS = True\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", "SAVEFIGS = False\n", "\n", "NPARS = 3\n", @@ -153,7 +153,6 @@ "source": [ "NPSRS = 40\n", "\n", - "JUST_DETSTATS = True\n", "if JUST_DETSTATS or CONSTRUCT:\n", " # get data (not dsdat_)\n", " if CONSTRUCT:\n", @@ -314,32 +313,32 @@ "metadata": {}, "outputs": [], "source": [ - "# Get SS mass normalization\n", - "use_snr=False\n", - "# ssmtot = []\n", - "# ss_dp = []\n", - "if use_snr:\n", - " mt_hisnr= np.zeros((NPARS, NREALS))\n", - " for ii,dat in enumerate(data):\n", - " # ssmtot.append(dat['sspar'][0])\n", - " snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", - " # print(snr_ss.shape)\n", - " ssmtot = dat['sspar'][0]\n", - " # print(ssmtot.shape)\n", - " # for each realization, find the frequency with the loudest single source\n", - " for rr in range(len(snr_ss[0])):\n", - " argmax = np.argmax(snr_ss[:,rr,:,:])\n", - " fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", - " # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", - " mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", - "\n", - " mt_hisnr = np.log10(mt_hisnr/MSOL)\n", - " vmin = np.min(mt_hisnr)\n", - " vmax = np.max(mt_hisnr)\n", - " norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", - "\n", - "print(f\"{vmin=}, {vmax=}\")\n", - "print(mt_hisnr.shape)" + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NPARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" ] }, { @@ -357,7 +356,21 @@ "outputs": [], "source": [ "norm_by_maxDPmass = True\n", - "if norm_by_maxDPmass" + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NPARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "# include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" ] }, { @@ -392,12 +405,12 @@ " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", " yy.append(dp_ss/dp_bg)\n", " for rr in range(len(yy[0])):\n", - " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(mt_hisnr[ii,rr])), alpha=0.5,)\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", "xx = np.array(xx)\n", "yy = np.array(yy)\n", "print(yy.shape)\n", "plot.draw_med_conf(ax, xx, yy)\n", - "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M_\\mathrm{max\\ SNR} / [\\mathrm{M}_\\odot]$',)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", "fig.tight_layout()\n", "\n", "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", From 366648bb2b1c302751762909a09b3fbe4e93d902 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 16:39:57 -0700 Subject: [PATCH 155/291] Set all files, loading settings, and save fig settings at the top. Run Phi0 --- .../tk10D_everyrealcalib.ipynb | 94 ++++++++++--------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb index e95aabcb..88e1e854 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb @@ -36,16 +36,16 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "CONSTRUCT = False\n", + "CONSTRUCT = True\n", "JUST_DETSTATS = False\n", - "SAVEFIGS = False\n", + "SAVEFIG = True\n", "\n", - "NPARS = 3\n", + "NVARS = 21\n", "\n", "NPSRS = 40\n", "NSKIES = 25\n", - "TARGET = 'hard_time'\n", - "TITLE = '$\\log( M_\\mathrm{char,0} / \\mathrm{M}_\\odot )$'" + "TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", + "TITLE = '$\\Phi_0$' # EDIT AS NEEDED" ] }, { @@ -55,14 +55,16 @@ "outputs": [], "source": [ "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", - "load_data_from_file = path+f'/{TARGET}_{NPARS}vars_clbrt_reals.npz' \n", - "save_data_to_file = path+f'/{TARGET}_{NPARS}vars_clbrt_reals.npz' \n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", "\n", "if CONSTRUCT is False:\n", " import os\n", " if os.path.exists(load_data_from_file) is False:\n", " err = 'load data file does not exist, you need to construct it.'\n", - " raise Exception(err)" + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" ] }, { @@ -151,13 +153,11 @@ "metadata": {}, "outputs": [], "source": [ - "NPSRS = 40\n", - "\n", "if JUST_DETSTATS or CONSTRUCT:\n", " # get data (not dsdat_)\n", " if CONSTRUCT:\n", - " params_list = np.linspace(0,1,NPARS)\n", - " data, params, = vary_parameter(target_param=TARGET, params_list=params_list, get_ds=False)\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", " else:\n", " file = np.load(load_data_from_file, allow_pickle=True)\n", " print(file.files)\n", @@ -241,13 +241,15 @@ "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", "print(text)\n", "\n", - "param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "\n", "\n", "\n", "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", "fig1.tight_layout()\n", - "# if SAVEFIGS: fig1.savefig(param_path+f'/ss_vs_bg_w_{TARGET}_21vars.png')\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", "\n", "\n", "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", @@ -262,33 +264,33 @@ "outputs": [], "source": [ "\n", - "xlabel=TITLE\n", - "ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", - "colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", - "\n", - "\n", - "fig, ax = plot.figax(xscale='linear',)\n", - "ax.set_ylabel(ylabel, fontsize=14)\n", - "ax.set_xlabel(xlabel, fontsize=14)\n", - "\n", - "target=TARGET\n", - "xx = []\n", - "yy = []\n", - "for ii, par in enumerate(params):\n", - " xx.append(params[ii][target])\n", - " dp_bg = dsdat[ii]['dp_bg']\n", - " dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", - " yy.append(dp_ss/dp_bg)\n", - " for rr in range(len(yy[0])):\n", - " ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", - "xx = np.array(xx)\n", - "yy = np.array(yy)\n", - "print(yy.shape)\n", - "# for rr, yi in enumerate(yy):\n", - "# ax.scatter(xx,yy[:,rr])\n", - "plot.draw_med_conf(ax, xx, yy)\n", - "# for rr in range(len(yy[0])):\n", - "# ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" ] }, { @@ -318,7 +320,7 @@ "# # ssmtot = []\n", "# # ss_dp = []\n", "# if use_snr:\n", - "# mt_hisnr= np.zeros((NPARS, NREALS))\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", "# for ii,dat in enumerate(data):\n", "# # ssmtot.append(dat['sspar'][0])\n", "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", @@ -355,9 +357,11 @@ "metadata": {}, "outputs": [], "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", "norm_by_maxDPmass = True\n", "if norm_by_maxDPmass:\n", - " normcol = np.zeros((NPARS, NREALS))\n", + " normcol = np.zeros((NVARS, NREALS))\n", " for ii, dat in enumerate(data):\n", " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", " ssmtot = dat['sspar'][0] # (F,R,L)\n", @@ -368,7 +372,7 @@ " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", " normcol = np.log10(normcol/MSOL)\n", "\n", - "# include other colorbar options here, to set normcol values\n", + "#### could include other colorbar options here, to set normcol values\n", "\n", "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" ] @@ -414,7 +418,7 @@ "fig.tight_layout()\n", "\n", "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", - "# fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars.png' % (TARGET, NPARS))" + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" ] }, { From 84625d13e6a58277e0381dd52e6960a5dace7d87 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 16:44:41 -0700 Subject: [PATCH 156/291] Make folder for tk10D type parameter detstats calculations, to copy notebook for each param. --- .../tk10D_mmbulge_scatter_dex.ipynb | 453 ++++++++++++++++++ 1 file changed, 453 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb new file mode 100644 index 00000000..762e4cea --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb @@ -0,0 +1,453 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = True\n", + "JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "TITLE = 'MMB Scatter $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if JUST_DETSTATS or CONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if CONSTRUCT:\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs[0]\n", + " cad = 1.0/(2*fobs[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + " _dsdat = detstats.detect_pspace_model_clbrt_psrs(fobs, hc_ss, hc_bg, NPSRS, NSKIES, maxtrials=1)\n", + " dsdat.append(_dsdat)\n", + " \n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 9826fde8bfa6bf4bb63cb6fc335a3e22ce11cc6b Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 19:50:12 -0700 Subject: [PATCH 157/291] Write function to calibrate pta for each realization, instead of just calibrating sigma. --- holodeck/detstats.py | 88 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 4 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 68722f9d..f4d88070 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1997,9 +1997,49 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, return dsdata -def detect_pspace_model_clbrt_psrs(fobs_cents, hc_ss, hc_bg, +def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, npsrs, nskies, maxtrials=1, thresh=DEF_THRESH, debug=False): + """ Detect pspace model using individual sigma calibration for each realization + + """ + dur = 1.0/fobs_cents[0] + cad = 1.0/(2*fobs_cents[-1]) + + nfreqs, nreals, nloudest = [*hc_ss.shape] + + # form arrays for individual realization detstats + dp_ss = np.zeros((nreals, nskies)) + dp_bg = np.zeros(nreals) + snr_ss = np.zeros((nfreqs, nreals, nskies, nloudest)) + snr_bg = np.zeros((nreals)) + gamma_ssi = np.zeros((nfreqs, nreals, nskies, nloudest)) + + # for each realization, + for rr in range(nreals): + # get calibrated psrs + psrs = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, + sigmin=1e-9, sigmax=1e-4) + + # use those psrs to calculate realization detstats + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) + dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() + _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], ret_snr=True) + dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() + + ev_ss = expval_of_ss(gamma_ssi) + df_ss, df_bg = detfrac_of_reals(dp_ss, dp_bg) + _dsdat = { + 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, + 'dp_bg':dp_bg, 'snr_bg':snr_bg, + 'df_ss':df_ss, 'df_bg':df_bg, 'ev_ss':ev_ss, + } + return _dsdat + + +def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, + npsrs, nskies, ): """ Detect pspace model using individual PTA calibration for each realization """ @@ -2008,7 +2048,7 @@ def detect_pspace_model_clbrt_psrs(fobs_cents, hc_ss, hc_bg, nfreqs, nreals, nloudest = [*hc_ss.shape] # get calibrated sigmas - sigmas, avg_dps, std_dps = calibrate_every_real(hc_bg, fobs_cents, npsrs, maxtrials=maxtrials) + sigmas, avg_dps, std_dps = calibrate_all_sigma(hc_bg, fobs_cents, npsrs, maxtrials=maxtrials) # form arrays for individual realization detstats dp_ss = np.zeros((nreals, nskies)) @@ -2092,7 +2132,7 @@ def _get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad,): std_dp = np.std(all_dp) return avg_dp, std_dp -def calibrate_every_real(hc_bg, fobs, npsrs, maxtrials, +def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, sig_start = 1e-6, sig_min=1e-9, sig_max=1e-4, debug=False): """ Calibrate the PTA independently for each background realizations @@ -2124,4 +2164,44 @@ def calibrate_every_real(hc_bg, fobs, npsrs, maxtrials, hc_bg_rr, fobs, npsrs, maxtrials, debug=debug, sig_start = sig_start, sig_min=sig_min, sig_max=sig_max, ) - return rsigmas, avg_dps, std_dps \ No newline at end of file + return rsigmas, avg_dps, std_dps + +def calibrate_one_pta(hc_bg, fobs, npsrs, + sigmin=1e-9, sigmax=1e-4, debug=False): + """ Calibrate the specific PTA for a given realization, and return that PTA + + Parameters + ---------- + hc_bg : (F,) 1Darray + The background characteristic strain for one realization. + fobs : (F,) 1Darray + Observed GW frequencies. + npsrs : integer + Number of pulsars. + + Returns + ------- + psrs : hasasia.sim.pta object + Calibrated PTA. + """ + + # get duration and cadence from fobs + dur = 1.0/fobs[0] + cad = 1.0/(2.0*fobs[-1]) + + # randomize pulsar positions + phis = np.random.uniform(0, 2*np.pi, size = npsrs) + thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + + # calibrate sigma + while dp_bg<0.495 or dp_bg>0.505: + sigma = np.mean([sigmin, sigmax]) + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + phi=phis, theta=thetas) + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg) + + if dp_bg<0.49: # dp too low, lower sigma + sigmax = sigma + elif dp_bg>0.51: # dp too high, raise sigma + sigmin = sigma + return psrs From 162d4d9ec165bb204686cc38254e41d883d151ca Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 19:51:10 -0700 Subject: [PATCH 158/291] Clean up --- .../calibration_function.ipynb | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index 0e8c5361..3d3f20b6 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -400,24 +400,6 @@ "%time rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 4)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%time rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 5)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%time rsigmas, avg_dps, std_dps = detstats.calibrate_every_real(hc_bg_all[nn], fobs, NPSRS, 5, debug=True)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -425,60 +407,6 @@ "outputs": [], "source": [] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Try with Fsolve" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def sigma_function(sigma, hc_bg=hc_bg_all[nsort[0]], npsrs=NPSRS, trials=3, fobs=fobs, nreals=NREALS):\n", - " dur = 1.0/fobs[0]\n", - " cad = 1.0/(2*fobs[-1])\n", - " all_dp = np.zeros((trials, nreals))\n", - " for ii in range(trials):\n", - " # build PTA\n", - " phis = np.random.uniform(0, 2*np.pi, size = npsrs)\n", - " thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs)\n", - " print(f\"{sigma=}\")\n", - " psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma[0],\n", - " phi=phis, theta=thetas)\n", - " # calculate bg dp for this trial\n", - " all_dp[ii] = detstats.detect_bg_pta(psrs, fobs, hc_bg=hc_bg)\n", - " # find mean dp of all trials\n", - " avg_dp = np.mean(all_dp)\n", - "\n", - " # function that we want to be zero\n", - " zero = avg_dp-0.5\n", - " return zero" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "root = sp.optimize.fsolve(sigma_function, SIG_START)\n", - "print(get_dpbg(hc_bg_all[nn], NPSRS, root, 3, fobs, dur, cad, nreals=NREALS))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(get_dpbg(hc_bg_all[nsort[0]], NPSRS, sigma, trials=1))" - ] - }, { "cell_type": "code", "execution_count": null, From c2984b1992bdd1473757acaeef0d28eca5f02e53 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:01:31 -0700 Subject: [PATCH 159/291] Calibrate individual pta for each realization with maxbads to handle when it gets stuck, and optional tolerance setting. --- .../tk10D_everyrealcalib.ipynb | 23 ++++++++---- .../tk10D_mmbulge_scatter_dex.ipynb | 16 ++++---- holodeck/detstats.py | 37 +++++++++++++------ 3 files changed, 50 insertions(+), 26 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb index 88e1e854..709443af 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_everyrealcalib.ipynb @@ -36,8 +36,8 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "CONSTRUCT = True\n", - "JUST_DETSTATS = False\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = True\n", "SAVEFIG = True\n", "\n", "NVARS = 21\n", @@ -56,7 +56,7 @@ "source": [ "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", - "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", "\n", "if CONSTRUCT is False:\n", " import os\n", @@ -147,6 +147,15 @@ "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(NFREQS, NREALS)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -165,9 +174,9 @@ " params = file['params']\n", " file.close()\n", "\n", - " fobs = data[1]['fobs_cents'] \n", - " dur = 1.0/fobs[0]\n", - " cad = 1.0/(2*fobs[-1])\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", " \n", " # get dsdat for each data/param\n", " dsdat = []\n", @@ -176,7 +185,7 @@ " # get strain info\n", " hc_bg = _data['hc_bg']\n", " hc_ss = _data['hc_ss']\n", - " _dsdat = detstats.detect_pspace_model_clbrt_psrs(fobs, hc_ss, hc_bg, NPSRS, NSKIES, maxtrials=1)\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=0.005)\n", " dsdat.append(_dsdat)\n", " \n", " np.savez(save_data_to_file,\n", diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb index 762e4cea..1748fa60 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmbulge_scatter_dex.ipynb @@ -36,9 +36,11 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "CONSTRUCT = True\n", - "JUST_DETSTATS = False\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = True\n", "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=20\n", "\n", "NVARS = 21\n", "\n", @@ -56,7 +58,7 @@ "source": [ "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", - "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", "\n", "if CONSTRUCT is False:\n", " import os\n", @@ -165,9 +167,9 @@ " params = file['params']\n", " file.close()\n", "\n", - " fobs = data[1]['fobs_cents'] \n", - " dur = 1.0/fobs[0]\n", - " cad = 1.0/(2*fobs[-1])\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", " \n", " # get dsdat for each data/param\n", " dsdat = []\n", @@ -176,7 +178,7 @@ " # get strain info\n", " hc_bg = _data['hc_bg']\n", " hc_ss = _data['hc_ss']\n", - " _dsdat = detstats.detect_pspace_model_clbrt_psrs(fobs, hc_ss, hc_bg, NPSRS, NSKIES, maxtrials=1)\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=TOL, maxbads=MAXBADS)\n", " dsdat.append(_dsdat)\n", " \n", " np.savez(save_data_to_file,\n", diff --git a/holodeck/detstats.py b/holodeck/detstats.py index f4d88070..9516ed2f 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1997,9 +1997,9 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, return dsdata -def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, +def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, maxtrials=1, - thresh=DEF_THRESH, debug=False): + thresh=DEF_THRESH, debug=False, maxbads=20, tol=0.03): """ Detect pspace model using individual sigma calibration for each realization """ @@ -2017,9 +2017,10 @@ def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, # for each realization, for rr in range(nreals): + if debug: print(f"{rr=}") # get calibrated psrs psrs = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, - sigmin=1e-9, sigmax=1e-4) + sigmin=1e-9, sigmax=1e-4, debug=debug, maxbads=maxbads, tol=tol) # use those psrs to calculate realization detstats _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) @@ -2027,7 +2028,7 @@ def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], ret_snr=True) dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() - + ev_ss = expval_of_ss(gamma_ssi) df_ss, df_bg = detfrac_of_reals(dp_ss, dp_bg) _dsdat = { @@ -2038,8 +2039,8 @@ def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, return _dsdat -def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, - npsrs, nskies, ): +def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, + npsrs, nskies, maxtrials=1): """ Detect pspace model using individual PTA calibration for each realization """ @@ -2081,7 +2082,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, ############################ Calibrate PTA ############################# ######################################################################## -def binary_pta_calibration(hc_bg, fobs, npsrs, maxtrials=2, debug=False, +def binary_sigma_calibration(hc_bg, fobs, npsrs, maxtrials=2, debug=False, sig_start = 1e-6, sig_min = 1e-10, sig_max = 1e-3, ): """ Calibrate the PTA to a 50% target DP for a given model, average over many realizations @@ -2160,14 +2161,14 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, for rr in range(nreals): hc_bg_rr = hc_bg[:,rr:rr+1] # print(hc_bg_rr.shape) - rsigmas[rr], avg_dps[rr], std_dps[rr] = binary_pta_calibration( + rsigmas[rr], avg_dps[rr], std_dps[rr] = binary_sigma_calibration( hc_bg_rr, fobs, npsrs, maxtrials, debug=debug, sig_start = sig_start, sig_min=sig_min, sig_max=sig_max, ) return rsigmas, avg_dps, std_dps def calibrate_one_pta(hc_bg, fobs, npsrs, - sigmin=1e-9, sigmax=1e-4, debug=False): + sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2192,16 +2193,28 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, # randomize pulsar positions phis = np.random.uniform(0, 2*np.pi, size = npsrs) thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigstart, + phi=phis, theta=thetas) + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis])[0] + print(dp_bg) + nbads=0 # calibrate sigma - while dp_bg<0.495 or dp_bg>0.505: + while np.abs(dp_bg-0.50)>tol: sigma = np.mean([sigmin, sigmax]) psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg) - + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg)[0] + # if debug: print(f"{dp_bg=}") if dp_bg<0.49: # dp too low, lower sigma sigmax = sigma elif dp_bg>0.51: # dp too high, raise sigma sigmin = sigma + else: + nbads += 1 # check how many attempts between 0.49 and 0.51 fail + if nbads>maxbads: # if many fail, we're stuck; expand sampling range + if debug: print(f"{nbads=}", f"{dp_bg=}") + sigmin = sigmin/10 + sigmax = sigmax*10 + nbads=0 return psrs From e8498a8a662d8b6021063459a83aac6d9b3ec3e6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:16:47 -0700 Subject: [PATCH 160/291] Correct missing nskies specification in detect_pspace_model_clbrt_pta --- holodeck/detstats.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 9516ed2f..71a921f3 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2007,6 +2007,8 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, cad = 1.0/(2*fobs_cents[-1]) nfreqs, nreals, nloudest = [*hc_ss.shape] + if debug: print(f"{[*hc_ss.shape]=}") + if debug: print(f"{nskies=}") # form arrays for individual realization detstats dp_ss = np.zeros((nreals, nskies)) @@ -2026,7 +2028,8 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( - psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], ret_snr=True) + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True) + if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() ev_ss = expval_of_ss(gamma_ssi) From 673f0e0039232dba220ebda1d2b1bbab01510d8e Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:17:55 -0700 Subject: [PATCH 161/291] Compare different maxbads for tol=0.01 --- .../calibration_function.ipynb | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index 3d3f20b6..fc636419 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -405,7 +405,41 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "print(hc_ss_all.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ss = hc_ss_all[nn]\n", + "print(hc_ss.shape)\n", + "hc_bg = hc_bg_all[nn]\n", + "NSKIES=20\n", + "\n", + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss, hc_bg, NPSRS, nskies=20, debug=True, tol=0.01, maxbads=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=0.01, maxbads=20)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=0.01, maxbads=30)" + ] }, { "cell_type": "code", From c535bb4a1c6e91c867779eaef1ab6bd97ae642db Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:22:36 -0700 Subject: [PATCH 162/291] Compare maxbads for lower tolerance, lower maxbads seems faster. --- .../calibration_function.ipynb | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index fc636419..ba63850e 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -441,12 +441,49 @@ "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=0.01, maxbads=30)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## varying maxbads for dif tol" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss[:,:20], hc_bg[:,:20], NPSRS, nskies=20, debug=True, tol=0.005, maxbads=10)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss[:,:20], hc_bg[:,:20], NPSRS, nskies=20, debug=True, tol=0.005, maxbads=30)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss[:,:20], hc_bg[:,:20], NPSRS, nskies=20, debug=True, tol=0.005, maxbads=5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss[:,:20], hc_bg[:,:20], NPSRS, nskies=20, debug=True, tol=0.005, maxbads=5)" + ] } ], "metadata": { From 9de33e7695c8934956ec890acb3b76f4cc162f83 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:23:03 -0700 Subject: [PATCH 163/291] Change bads adjust from * or / 10 to * or / 5 --- holodeck/detstats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 71a921f3..e20b0b66 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2217,7 +2217,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, nbads += 1 # check how many attempts between 0.49 and 0.51 fail if nbads>maxbads: # if many fail, we're stuck; expand sampling range if debug: print(f"{nbads=}", f"{dp_bg=}") - sigmin = sigmin/10 - sigmax = sigmax*10 + sigmin = sigmin/5 + sigmax = sigmax*5 nbads=0 return psrs From ad8769b81bec116720b28a4e63fe8af9ac1c6def Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:25:59 -0700 Subject: [PATCH 164/291] Find low maxbad is fastest --- .../detstats_functions/calibration_function.ipynb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ecg-notebooks/detstats_functions/calibration_function.ipynb b/ecg-notebooks/detstats_functions/calibration_function.ipynb index ba63850e..f0c07894 100644 --- a/ecg-notebooks/detstats_functions/calibration_function.ipynb +++ b/ecg-notebooks/detstats_functions/calibration_function.ipynb @@ -484,6 +484,13 @@ "source": [ "%time detstats.detect_pspace_model_clbrt_pta(fobs, hc_ss[:,:20], hc_bg[:,:20], NPSRS, nskies=20, debug=True, tol=0.005, maxbads=5)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From beb5e91a0261ed0f028003d26342b95014cbd2c6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 22:51:10 -0700 Subject: [PATCH 165/291] Run pta-calibrated detstats for each varying parameter. --- .../tk10D_gsmf_mchar0_log10.ipynb | 455 ++++++++++++++++++ .../tk10D_gsmf_phi0.ipynb | 455 ++++++++++++++++++ .../tk10D_hard_gamma_inner.ipynb | 455 ++++++++++++++++++ .../tk10D_hard_time.ipynb | 455 ++++++++++++++++++ .../tk10D_mmb_mamp_log10.ipynb | 455 ++++++++++++++++++ 5 files changed, 2275 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_mchar0_log10.ipynb create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_phi0.ipynb create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_gamma_inner.ipynb create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_mchar0_log10.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_mchar0_log10.ipynb new file mode 100644 index 00000000..decb008f --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_mchar0_log10.ipynb @@ -0,0 +1,455 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = True\n", + "JUST_DETSTATS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "TITLE = 'GSMF log($M_{\\psi,0} / \\mathrm{M}_\\odot$) ' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if JUST_DETSTATS or CONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if CONSTRUCT:\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=TOL, maxbads=MAXBADS)\n", + " dsdat.append(_dsdat)\n", + " \n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_phi0.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_phi0.ipynb new file mode 100644 index 00000000..3efe7d67 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_gsmf_phi0.ipynb @@ -0,0 +1,455 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = True\n", + "JUST_DETSTATS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", + "TITLE = 'GSMF $\\psi_0$ ' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if JUST_DETSTATS or CONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if CONSTRUCT:\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=TOL, maxbads=MAXBADS)\n", + " dsdat.append(_dsdat)\n", + " \n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_gamma_inner.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_gamma_inner.ipynb new file mode 100644 index 00000000..fd3854c7 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_gamma_inner.ipynb @@ -0,0 +1,455 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = True\n", + "JUST_DETSTATS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if JUST_DETSTATS or CONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if CONSTRUCT:\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=TOL, maxbads=MAXBADS)\n", + " dsdat.append(_dsdat)\n", + " \n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb new file mode 100644 index 00000000..22c3e358 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb @@ -0,0 +1,455 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = True\n", + "JUST_DETSTATS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if JUST_DETSTATS or CONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if CONSTRUCT:\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=TOL, maxbads=MAXBADS)\n", + " dsdat.append(_dsdat)\n", + " \n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb new file mode 100644 index 00000000..bb2762fb --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb @@ -0,0 +1,455 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 30\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = True\n", + "JUST_DETSTATS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "TITLE = 'MMB log($\\mu / \\mathrm{M}_\\odot$) ' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "save_data_to_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Construct Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names\n", + "num_pars = len(param_names)\n", + "pars = 0.5*np.ones(num_pars)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def vary_parameter(\n", + " target_param, # the name of the parameter, has to exist in `param_names`\n", + " params_list = [0.0, 0.5, 1.0], # the values we'll check\n", + " pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None),\n", + " nreals=NREALS, nfreqs=NFREQS,\n", + " pars=None, save_dir=None, \n", + " ):\n", + " # get the parameter names from this library-space\n", + " param_names = pspace.param_names\n", + " num_pars = len(pspace.param_names)\n", + " print(f\"{num_pars=} :: {param_names=}\")\n", + "\n", + " # choose each parameter to be half-way across the range provided by the library\n", + " if pars is None:\n", + " pars = 0.5 * np.ones(num_pars) \n", + " str_pars = str(pars).replace(\" \", \"_\").replace(\"[\", \"\").replace(\"]\", \"\")\n", + " # Choose parameter to vary\n", + " param_idx = param_names.index(target_param)\n", + "\n", + " data = []\n", + " params = []\n", + " for ii, par in enumerate(params_list):\n", + " pars[param_idx] = par\n", + " print(f\"{ii=}, {pars=}\")\n", + " # _params = pspace.param_samples[0]*pars\n", + " _params = pspace.normalized_params(pars)\n", + " params.append(_params)\n", + " # construct `sam` and `hard` instances based on these parameters\n", + " sam, hard = pspace.model_for_params(_params, pspace.sam_shape)\n", + " if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM):\n", + " hard_name = 'Fixed Time'\n", + " elif isinstance(hard, holo.hardening.Hard_GW):\n", + " hard_name = 'GW Only'\n", + " # run this model, retrieving binary parameters and the GWB\n", + " _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=NLOUDEST,\n", + " gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True)\n", + " data.append(_data)\n", + " if save_dir is not None:\n", + " str_shape = str(sam.shape).replace(\", \", \"_\").replace(\"(\", \"\").replace(\")\", \"\")\n", + " filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape)\n", + " np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param )\n", + " print('saved to %s' % filename)\n", + "\n", + " return (data, params)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Calculate Data (if CONSTRUCT) and Individual DetStats (if CONSTRUCT or JUST_DETSTAATS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if JUST_DETSTATS or CONSTRUCT:\n", + " # get data (not dsdat_)\n", + " if CONSTRUCT:\n", + " params_list = np.linspace(0,1,NVARS)\n", + " data, params, = vary_parameter(target_param=TARGET, params_list=params_list)\n", + " else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " fobs_cents = data[1]['fobs_cents'] \n", + " dur = 1.0/fobs_cents[0]\n", + " cad = 1.0/(2*fobs_cents[-1])\n", + " \n", + " # get dsdat for each data/param\n", + " dsdat = []\n", + " for ii, _data in enumerate(data):\n", + " print(f\"{ii=}\")\n", + " # get strain info\n", + " hc_bg = _data['hc_bg']\n", + " hc_ss = _data['hc_ss']\n", + " _dsdat = detstats.detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, NPSRS, NSKIES, debug=True, tol=TOL, maxbads=MAXBADS)\n", + " dsdat.append(_dsdat)\n", + " \n", + " np.savez(save_data_to_file,\n", + " data = data, dsdat=dsdat, params=params)\n", + "else:\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " print(file.files)\n", + " data = file['data']\n", + " params = file['params']\n", + " dsdat = file['dsdat']\n", + " file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = dsdat[ii]['dp_bg']\n", + " dp_ss = np.mean(dsdat[ii]['ev_ss'], axis=-1)\n", + " yy.append(dp_ss/dp_bg)\n", + " for rr in range(len(yy[0])):\n", + " ax.scatter(xx[ii], yy[ii][rr], color=cmap(norm(normcol[ii,rr])), alpha=0.5,)\n", + "xx = np.array(xx)\n", + "yy = np.array(yy)\n", + "print(yy.shape)\n", + "plot.draw_med_conf(ax, xx, yy)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 005b98029c0914a6f9b869eca8f553d5ebb44654 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 23:29:38 -0700 Subject: [PATCH 166/291] Set facecolor to black --- .../take9B_numberdensity_binned.ipynb | 35 ++----------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb index b998b553..a012b499 100644 --- a/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb +++ b/ecg-notebooks/parameter_investigation/take9B_numberdensity_binned.ipynb @@ -175,11 +175,13 @@ "\n", " ax = axs[0]\n", " ax.set_title('$h_c^2$-weighted Background')\n", + " ax.set_facecolor('k')\n", " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist_bg), cmap='viridis')\n", " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", " ax = axs[1]\n", " ax.set_title('Single Sources')\n", + " ax.set_facecolor('k')\n", " ax.set_ylabel(None)\n", " im = ax.pcolormesh(mtgrid, ffgrid, np.log10(hist_ss), cmap='inferno')\n", " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", @@ -247,39 +249,6 @@ "source": [ "plot_best_index(None)" ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Individual Frequency" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "hist_ss, ffe, mte, = np.histogram2d(ssfrq, ssmtt, bins=(ff_edges, mt_edges))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "sspar = h" - ] } ], "metadata": { From a25f6aee1308882d7ce41dddd62f71c3d3802de4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 23:30:12 -0700 Subject: [PATCH 167/291] Plot mass vs frequency for one dat variation. --- .../tk11_hard_time.ipynb | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb new file mode 100644 index 00000000..629d769f --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb @@ -0,0 +1,208 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "import os\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "NVARS = 21" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_reals.npz' \n", + "\n", + "if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Data from File" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "dsdat = file['dsdat']\n", + "file.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Shapes, Edges, Frequency Info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nfreqs, nreals, nloudest = [*data[0]['hc_ss'].shape]\n", + "fobs_cents = data[0]['fobs_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# mass edges\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mm_edges = sam.mtot/MSOL\n", + "\n", + "# frequency bin edges\n", + "ff_edges = data[0]['fobs_edges']/10**9\n", + "\n", + "# get frequencies\n", + "ssfrq = np.repeat(fobs_cents, nreals*nloudest)/10**9 # nHz\n", + "bgfrq = np.repeat(fobs_cents, nreals)/10**9 # nHz" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(data[0]['sspar'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dat = data[0]\n", + "parm = params[0]\n", + "\n", + "# get masses\n", + "ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + "bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "\n", + "\n", + "# get histograms\n", + "hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + "hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + "\n", + "fig, axs = plot.figax(ncols=2, ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(8,4))\n", + "ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", + "# print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + "\n", + "ax = axs[0]\n", + "ax.set_title('$h_c^2$-weighted Background')\n", + "ax.set_facecolor('k')\n", + "im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis')\n", + "cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + "ax = axs[1]\n", + "ax.set_title('Single Sources')\n", + "ax.set_facecolor('k')\n", + "ax.set_ylabel(None)\n", + "im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno')\n", + "cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(ssmtt))\n", + "print(holo.utils.stats(bgmtt))\n", + "print(holo.utils.stats(ssfrq))\n", + "print(holo.utils.stats(bgfrq))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 0d541320f57be968bb1a18170b9cce91d21bdab6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 23:34:51 -0700 Subject: [PATCH 168/291] Plot mass vs frequency for many hard_time variations. --- .../tk11_hard_time.ipynb | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb index 629d769f..a206b4a7 100644 --- a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb @@ -135,33 +135,35 @@ "source": [ "dat = data[0]\n", "parm = params[0]\n", + "for ii, dat in enumerate(data):\n", + " parm = params[ii]\n", + " # get masses\n", + " ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + " bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", "\n", - "# get masses\n", - "ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", - "bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + " # get histograms\n", + " hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + " hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", "\n", + " fig, axs = plot.figax(ncols=2, ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(8,4))\n", + " ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", + " # print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", "\n", - "# get histograms\n", - "hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", - "hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + " ax = axs[0]\n", + " ax.set_title('$h_c^2$-weighted Background')\n", + " ax.set_facecolor('k')\n", + " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis')\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", - "fig, axs = plot.figax(ncols=2, ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(8,4))\n", - "ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", - "# print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + " ax = axs[1]\n", + " ax.set_title('Single Sources')\n", + " ax.set_facecolor('k')\n", + " ax.set_ylabel(None)\n", + " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno')\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", - "ax = axs[0]\n", - "ax.set_title('$h_c^2$-weighted Background')\n", - "ax.set_facecolor('k')\n", - "im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis')\n", - "cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", - "\n", - "ax = axs[1]\n", - "ax.set_title('Single Sources')\n", - "ax.set_facecolor('k')\n", - "ax.set_ylabel(None)\n", - "im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno')\n", - "cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", - "\n" + " fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", + " fig.tight_layout()\n" ] }, { @@ -170,10 +172,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(holo.utils.stats(ssmtt))\n", - "print(holo.utils.stats(bgmtt))\n", - "print(holo.utils.stats(ssfrq))\n", - "print(holo.utils.stats(bgfrq))" + "print(parm)" ] }, { From b115730c4ecaaef85b91ae31b66e4a6655a7f63d Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 24 Jun 2023 23:41:50 -0700 Subject: [PATCH 169/291] Finish mmb mamp and hard time 21vars and plots. --- .../tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb | 4 ++-- .../tk10D_mmb_mamp_log10.ipynb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb index 22c3e358..589f493b 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_hard_time.ipynb @@ -36,8 +36,8 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "CONSTRUCT = True\n", - "JUST_DETSTATS = True\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb index bb2762fb..31e8be3e 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/tk10D_mmb_mamp_log10.ipynb @@ -36,8 +36,8 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "CONSTRUCT = True\n", - "JUST_DETSTATS = True\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", From b0ae86948e0de71ae14a7aef8b3f848cfdda8f7e Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 01:00:54 -0700 Subject: [PATCH 170/291] Attempt colored SS to BG DP for mass vs freq plot, uninteresting. --- .../tk11_hard_time.ipynb | 109 +++++++++++++++--- 1 file changed, 96 insertions(+), 13 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb index a206b4a7..33d77ee7 100644 --- a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb @@ -111,20 +111,20 @@ ] }, { - "attachments": {}, - "cell_type": "markdown", + "cell_type": "code", + "execution_count": null, "metadata": {}, + "outputs": [], "source": [ - "# Plot 1" + "print(np.log10(28))" ] }, { - "cell_type": "code", - "execution_count": null, + "attachments": {}, + "cell_type": "markdown", "metadata": {}, - "outputs": [], "source": [ - "print(data[0]['sspar'].shape)" + "# Plot Mass vs Frequency" ] }, { @@ -133,8 +133,28 @@ "metadata": {}, "outputs": [], "source": [ - "dat = data[0]\n", - "parm = params[0]\n", + "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/params/mass_vs_freq_hard_time_21vars'\n", + "vmin = 0\n", + "vmax_bg = 0\n", + "vmax_ss = 0\n", + "# find maxes\n", + "for ii, dat in enumerate(data):\n", + " parm = params[ii]\n", + " # get masses\n", + " ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + " bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "\n", + " # get histograms\n", + " hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + " hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + "\n", + " print(f\"{np.max(hist_ss)=}, {np.max(hist_bg)=}\")\n", + " if np.max(np.log10(hist_ss)) > vmax_ss:\n", + " vmax_ss = np.max(np.log10(hist_ss))\n", + " if np.max(np.log10(hist_bg)) > vmax_bg:\n", + " vmax_bg = np.max(np.log10(hist_bg))\n", + "\n", + "# plot\n", "for ii, dat in enumerate(data):\n", " parm = params[ii]\n", " # get masses\n", @@ -152,18 +172,80 @@ " ax = axs[0]\n", " ax.set_title('$h_c^2$-weighted Background')\n", " ax.set_facecolor('k')\n", - " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis')\n", + " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis', vmin=vmin, vmax=vmax_ss)\n", " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", " ax = axs[1]\n", " ax.set_title('Single Sources')\n", " ax.set_facecolor('k')\n", " ax.set_ylabel(None)\n", - " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno')\n", + " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno', vmin=vmin, vmax=vmax_ss)\n", " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", " fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", - " fig.tight_layout()\n" + " fig.tight_layout()\n", + " fig.savefig(saveloc+f'/hard_time_mvsf_{ii:02d}.png')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot Detection Probability for masses" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dat = data[0]\n", + "parm = params[0]\n", + "dsd = dsdat[0]\n", + "\n", + "ssmtt = dat['sspar'][0]/MSOL\n", + "ssfrq = np.repeat(fobs_cents, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + "\n", + "\n", + "# gamma_ssi = dsd['gamma_ssi']\n", + "gamma_ssi = np.mean(dsd['gamma_ssi'], axis=2)\n", + "print(gamma_ssi.shape)\n", + "dp_bg = dsd['dp_bg']\n", + "print(dp_bg.shape)\n", + "\n", + "ratio = gamma_ssi/dp_bg[np.newaxis,:,np.newaxis]\n", + "print(ratio.shape, ssmtt.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Normalize for detstats" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Individual detection probability of each single source" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "norm = mpl.colors.Normalize()\n", + "\n", + "cmap = cm.rainbow\n", + "fig, ax = plot.figax(xlabel = '$f$ [nHz]', ylabel = '$M$ [M$_\\odot$]')\n", + "ax.scatter(ssfrq.flatten(), ssmtt.flatten(), color=cmap(norm(ratio.flatten())), alpha=0.01)" ] }, { @@ -172,7 +254,8 @@ "metadata": {}, "outputs": [], "source": [ - "print(parm)" + "print(norm(ratio.flatten()\n", + " ))" ] }, { From 57316d797b0a15e4640791bf9c6c843500b8b11b Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 11:02:45 -0700 Subject: [PATCH 171/291] Rename ss bvs bg dp and save figures. --- .../tk11_hard_time.ipynb | 44 ++++++++++++++++--- ...eqs.ipynb => tk12_lib_ssdp_vs_freqs.ipynb} | 13 +----- 2 files changed, 39 insertions(+), 18 deletions(-) rename ecg-notebooks/parameter_investigation/{tk11_ssdp_vs_freqs.ipynb => tk12_lib_ssdp_vs_freqs.ipynb} (97%) diff --git a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb index 33d77ee7..56b0f316 100644 --- a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_hard_time.ipynb @@ -201,12 +201,12 @@ "metadata": {}, "outputs": [], "source": [ - "dat = data[0]\n", - "parm = params[0]\n", - "dsd = dsdat[0]\n", + "dat = data[-1]\n", + "parm = params[-1]\n", + "dsd = dsdat[-1]\n", "\n", "ssmtt = dat['sspar'][0]/MSOL\n", - "ssfrq = np.repeat(fobs_cents, nreals*nloudest).reshape(nfreqs, nreals, nloudest)\n", + "ssfrq = np.repeat(fobs_cents, nreals*nloudest).reshape(nfreqs, nreals, nloudest)/10**9\n", "\n", "\n", "# gamma_ssi = dsd['gamma_ssi']\n", @@ -216,9 +216,16 @@ "print(dp_bg.shape)\n", "\n", "ratio = gamma_ssi/dp_bg[np.newaxis,:,np.newaxis]\n", - "print(ratio.shape, ssmtt.shape)" + "print(ratio.shape, ssmtt.shape, ssfrq.shape)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "attachments": {}, "cell_type": "markdown", @@ -241,11 +248,34 @@ "metadata": {}, "outputs": [], "source": [ - "norm = mpl.colors.Normalize()\n", + "colval = np.log10(ratio)\n", + "\n", + "vmin=np.min(colval)\n", + "# vmax=np.max(colval)\n", + "vmax=np.max(colval)\n", + "# vmax=-5\n", + "norm = mpl.colors.TwoSlopeNorm(vmin=vmin, vcenter=0, vmax=vmax,)\n", "\n", "cmap = cm.rainbow\n", "fig, ax = plot.figax(xlabel = '$f$ [nHz]', ylabel = '$M$ [M$_\\odot$]')\n", - "ax.scatter(ssfrq.flatten(), ssmtt.flatten(), color=cmap(norm(ratio.flatten())), alpha=0.01)" + "# for ff in range(30,40):\n", + "# for rr in range(10):\n", + "# for ll in range(5):\n", + "# im = ax.scatter(ssfrq[ff,rr,ll], ssmtt[ff,rr,ll], color=cmap(norm(ratio[ff,rr,ll])), alpha=0.5)\n", + "# print(ratio[ff,rr,ll], norm(ratio[ff,rr,ll]))\n", + "# im = ax.scatter(ssfrq.flatten(), ssmtt.flatten(), color=cmap(norm(colval.flatten())), alpha=0.01)\n", + "im = ax.pcolormesh(ssfrq, ssmtt, colval)\n", + "cbar = plt.colorbar(im) #, vmin=vmin, vmax=vmax)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(colval))\n", + "print(vmin, vmax)" ] }, { diff --git a/ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb b/ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb similarity index 97% rename from ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb rename to ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb index 8b40a925..442485df 100644 --- a/ecg-notebooks/parameter_investigation/tk11_ssdp_vs_freqs.ipynb +++ b/ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb @@ -200,16 +200,6 @@ " return target_params, norm" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(target_params.shape)\n", - "print(dp_ss.shape)" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -272,7 +262,8 @@ " fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", " cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", - " label=target, shrink=0.75 )" + " label=target, shrink=0.75 )\n", + " # fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/params/ss_vs_bg_dp_lib09A_single_pta/{target}.png')" ] }, { From 03e7e0493c5606567f7540bf8c37615659ac6a6a Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 11:10:08 -0700 Subject: [PATCH 172/291] Vary any parameter in tk11_anytarget.ipynb. --- .../tk11_anytarget.ipynb | 392 ++++++++++++++++++ .../tk12_lib_ssdp_vs_freqs.ipynb | 332 --------------- 2 files changed, 392 insertions(+), 332 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb delete mode 100644 ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb new file mode 100644 index 00000000..f200e7dc --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb @@ -0,0 +1,392 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "import os\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "TITLE = '$\\\\nu_\\mathrm{inner}$' # EDIT AS NEEDED\n", + "NVARS = 21" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Data from File" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "dsdat = file['dsdat']\n", + "file.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Shapes, Edges, Frequency Info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nfreqs, nreals, nloudest = [*data[0]['hc_ss'].shape]\n", + "fobs_cents = data[0]['fobs_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# mass edges\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mm_edges = sam.mtot/MSOL\n", + "\n", + "# frequency bin edges\n", + "ff_edges = data[0]['fobs_edges']/10**9\n", + "\n", + "# get frequencies\n", + "ssfrq = np.repeat(fobs_cents, nreals*nloudest)/10**9 # nHz\n", + "bgfrq = np.repeat(fobs_cents, nreals)/10**9 # nHz" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.log10(28))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot Mass vs Frequency" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "saveloc = f'/Users/emigardiner/GWs/holodeck/output/figures/params/mass_vs_freq_{TARGET}_{NVARS}vars'\n", + "if os.path.exists(saveloc) is False:\n", + " os.makedirs(saveloc)\n", + "vmin = 0\n", + "vmax_bg = 0\n", + "vmax_ss = 0\n", + "# find maxes\n", + "for ii, dat in enumerate(data):\n", + " parm = params[ii]\n", + " # get masses\n", + " ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + " bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "\n", + " # get histograms\n", + " hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + " hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + "\n", + " print(f\"{np.max(hist_ss)=}, {np.max(hist_bg)=}\")\n", + " if np.max(np.log10(hist_ss)) > vmax_ss:\n", + " vmax_ss = np.max(np.log10(hist_ss))\n", + " if np.max(np.log10(hist_bg)) > vmax_bg:\n", + " vmax_bg = np.max(np.log10(hist_bg))\n", + "\n", + "# plot\n", + "for ii, dat in enumerate(data):\n", + " parm = params[ii]\n", + " # get masses\n", + " ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + " bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "\n", + " # get histograms\n", + " hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + " hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + "\n", + " fig, axs = plot.figax(ncols=2, ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(8,4))\n", + " ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", + " # print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + "\n", + " ax = axs[0]\n", + " ax.set_title('$h_c^2$-weighted Background')\n", + " ax.set_facecolor('k')\n", + " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis', vmin=vmin, vmax=vmax_ss)\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + " ax = axs[1]\n", + " ax.set_title('Single Sources')\n", + " ax.set_facecolor('k')\n", + " ax.set_ylabel(None)\n", + " im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno', vmin=vmin, vmax=vmax_ss)\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + " fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", + " fig.tight_layout()\n", + " fig.savefig(saveloc+f'/{TARGET}_mvsf_{ii:02d}.png')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Put both on same colormap" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# saveloc = f'/Users/emigardiner/GWs/holodeck/output/figures/params/mass_vs_freq_{TARGET}_{NVARS}vars'\n", + "# if os.path.exists(saveloc) is False:\n", + "# os.makedirs(saveloc)\n", + "# vmin = 0\n", + "# vmax_bg = 0\n", + "# vmax_ss = 0\n", + "# # find maxes\n", + "# for ii, dat in enumerate(data):\n", + "# parm = params[ii]\n", + "# # get masses\n", + "# ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + "# bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "\n", + "# # get histograms\n", + "# hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + "# hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + "\n", + "# print(f\"{np.max(hist_ss)=}, {np.max(hist_bg)=}\")\n", + "# if np.max(np.log10(hist_ss)) > vmax_ss:\n", + "# vmax_ss = np.max(np.log10(hist_ss))\n", + "# if np.max(np.log10(hist_bg)) > vmax_bg:\n", + "# vmax_bg = np.max(np.log10(hist_bg))\n", + "\n", + "# # plot\n", + "# for ii, dat in enumerate(data):\n", + "# parm = params[ii]\n", + "# # get masses\n", + "# ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + "# bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "\n", + "# # get histograms\n", + "# hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + "# hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + "\n", + "# fig, axs = plot.figax(ncols=2, ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(8,4))\n", + "# ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", + "# # print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + "\n", + "# ax = axs[0]\n", + "# ax.set_title('$h_c^2$-weighted Background')\n", + "# ax.set_facecolor('k')\n", + "# im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis', vmin=vmin, vmax=vmax_ss)\n", + "# cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + "# ax = axs[1]\n", + "# ax.set_title('Single Sources')\n", + "# ax.set_facecolor('k')\n", + "# ax.set_ylabel(None)\n", + "# im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno', vmin=vmin, vmax=vmax_ss)\n", + "# cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + "\n", + "# fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", + "# fig.tight_layout()\n", + "# fig.savefig(saveloc+f'/{TARGET}_mvsf_{ii:02d}.png')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot Detection Probability for masses" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dat = data[-1]\n", + "parm = params[-1]\n", + "dsd = dsdat[-1]\n", + "\n", + "ssmtt = dat['sspar'][0]/MSOL\n", + "ssfrq = np.repeat(fobs_cents, nreals*nloudest).reshape(nfreqs, nreals, nloudest)/10**9\n", + "\n", + "\n", + "# gamma_ssi = dsd['gamma_ssi']\n", + "gamma_ssi = np.mean(dsd['gamma_ssi'], axis=2)\n", + "print(gamma_ssi.shape)\n", + "dp_bg = dsd['dp_bg']\n", + "print(dp_bg.shape)\n", + "\n", + "ratio = gamma_ssi/dp_bg[np.newaxis,:,np.newaxis]\n", + "print(ratio.shape, ssmtt.shape, ssfrq.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Normalize for detstats" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Individual detection probability of each single source" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# colval = np.log10(ratio)\n", + "\n", + "# vmin=np.min(colval)\n", + "# # vmax=np.max(colval)\n", + "# vmax=np.max(colval)\n", + "# # vmax=-5\n", + "# norm = mpl.colors.TwoSlopeNorm(vmin=vmin, vcenter=0, vmax=vmax,)\n", + "\n", + "# cmap = cm.rainbow\n", + "# fig, ax = plot.figax(xlabel = '$f$ [nHz]', ylabel = '$M$ [M$_\\odot$]')\n", + "# # for ff in range(30,40):\n", + "# # for rr in range(10):\n", + "# # for ll in range(5):\n", + "# # im = ax.scatter(ssfrq[ff,rr,ll], ssmtt[ff,rr,ll], color=cmap(norm(ratio[ff,rr,ll])), alpha=0.5)\n", + "# # print(ratio[ff,rr,ll], norm(ratio[ff,rr,ll]))\n", + "# # im = ax.scatter(ssfrq.flatten(), ssmtt.flatten(), color=cmap(norm(colval.flatten())), alpha=0.01)\n", + "# im = ax.pcolormesh(ssfrq, ssmtt, colval)\n", + "# cbar = plt.colorbar(im) #, vmin=vmin, vmax=vmax)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(colval))\n", + "print(vmin, vmax)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(norm(ratio.flatten()\n", + " ))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb b/ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb deleted file mode 100644 index 442485df..00000000 --- a/ecg-notebooks/parameter_investigation/tk12_lib_ssdp_vs_freqs.ipynb +++ /dev/null @@ -1,332 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%reload_ext autoreload\n", - "%autoreload 2\n", - "from importlib import reload\n", - "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import matplotlib.cm as cm\n", - "import matplotlib as mpl\n", - "import h5py\n", - "import tqdm\n", - "\n", - "\n", - "from holodeck import plot, detstats\n", - "import holodeck.single_sources as sings\n", - "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", - "import holodeck as holo\n", - "from holodeck.sams import sam\n", - "\n", - "import hasasia.sim as hsim\n", - "\n", - "import sys\n", - "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", - "import anatomy as anat" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10'\n", - "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", - "\n", - "print(hdf.keys())\n", - "sample_params = hdf['sample_params'][...]\n", - "hc_ss = hdf['hc_ss'][...]\n", - "hc_bg = hdf['hc_bg'][...]\n", - "sspar = hdf['sspar'][...]\n", - "bgpar = hdf['bgpar'][...]\n", - "fobs_gw_cents = hdf['fobs'][:]\n", - "hdf.close()\n", - "\n", - "dur = 1/fobs_gw_cents[0]\n", - "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", - "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", - "print(npz.files)\n", - "param_names = npz['param_names']\n", - "print(param_names)\n", - "print(npz['class_name'])\n", - "lib_name = '%s v%s, %d samples' % (npz['class_name'], npz['librarian_version'], nsamps)\n", - "print(lib_name)\n", - "# print(npz['sam_shape'])\n", - "npz.close()" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Load detstats" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "npz = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10/detstats/psrs40_sigma4.31e-06/detstats.npz')\n", - "\n", - "dp_ss = npz['dp_ss']\n", - "dp_bg = npz['dp_bg']\n", - "df_ss = npz['df_ss']\n", - "df_bg = npz['df_bg']\n", - "ev_ss = npz['ev_ss']\n", - "print(f\"{ev_ss.shape=}, {dp_ss.shape=}\")\n", - "npz.close()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sample_params[0])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# def_draw_ev(ax):\n", - "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", - "# plt.rcParams[\"font.family\"] = \"serif\"\n", - "\n", - "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", - " color='k', mean=True, errors=False,\n", - " ms=2):\n", - " xx = dp_bg # shape (R,)\n", - " if mean:\n", - " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", - " else: \n", - " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", - " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", - " if errors:\n", - " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", - " linestyle='', capsize=3, marker='o', alpha=0.05, markersize=ms)\n", - " else: \n", - " hh = ax.scatter(xx, yy, color=color, label=label,\n", - " linestyle='', marker='o', alpha=0.05, s=ms)\n", - " return hh\n", - "\n", - "def plot_dpss_vs_dpbg(dp_ss, dp_bg, target_params=None, norm=None, \n", - " use_ev=False, errors=False, ms=2, alpha=0.05, color='tab:blue', cmap=cm.rainbow):\n", - " # colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", - " # cmin = \n", - "\n", - " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", - " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", - " ylabel='$\\langle$ Single Source %s $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", - " ) \n", - " \n", - " for ii in range(len(dp_ss)):\n", - " # label = '%.2f' % params[ii][target_param]\n", - " if target_params is not None and norm is not None:\n", - " color = cmap(norm(target_params[ii]))\n", - " detss = dp_ss[ii] # use_ev else ds['dp_ss']\n", - " hh = draw_skies_vs_bg(ax, detss, dp_bg[ii], color=color, errors=errors, ms=ms) #, label=label)\n", - "\n", - "\n", - " fig.tight_layout()\n", - " return fig\n", - "\n", - "\n", - "\n", - "\n", - "# fig2 = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, errors=True)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig1 = plot_dpss_vs_dpbg(dp_ss, dp_bg, use_ev=False)\n", - "fig2 = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Color by params" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "target = 'hard_time'\n", - "def normalize_target(target, param_names=param_names, sample_params=sample_params):\n", - " idx = list(param_names).index(target)\n", - " target_params = sample_params[:,idx]\n", - " mintarget = np.min(target_params)\n", - " maxtarget = np.max(target_params)\n", - " norm = mpl.colors.Normalize(vmin=mintarget, vmax=maxtarget)\n", - " return target_params, norm" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Connect to hard_time" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "target_params, norm = normalize_target('hard_time')\n", - "cmap=cm.rainbow\n", - "fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", - " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", - "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", - " label='$\\\\tau_\\mathrm{hard}$', shrink=0.75 )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(nsamps, nfreqs, nreals)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(ev_ss.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(param_names)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "cmap=cm.rainbow\n", - "\n", - "for tt, target in enumerate(param_names):\n", - " target_params, norm = normalize_target(target)\n", - " fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", - " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", - " cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", - " label=target, shrink=0.75 )\n", - " # fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/params/ss_vs_bg_dp_lib09A_single_pta/{target}.png')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig.axes[0].set_ylim(10**-1, 4)\n", - "fig" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Diverging Colorbar for ratio!!\n", - "## make this for individual sample" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## make this for whole library" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "holo310", - "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.10" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From d9aeb9ee40bf7a7dfa99c533680054c73b0d7fa9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 11:19:41 -0700 Subject: [PATCH 173/291] Plot combined bg and ss mass vs freq on one pcolormesh, save for hard_time and hard_gamma_inner. --- .../tk11_anytarget.ipynb | 105 +++++++++--------- 1 file changed, 55 insertions(+), 50 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb index f200e7dc..1e7ccbd0 100644 --- a/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb +++ b/ecg-notebooks/parameter_investigation/tk11_varpar_massfreqs.ipynb/tk11_anytarget.ipynb @@ -31,9 +31,10 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", - "TITLE = '$\\\\nu_\\mathrm{inner}$' # EDIT AS NEEDED\n", - "NVARS = 21" + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "NVARS = 21\n", + "SAVEFIG = True" ] }, { @@ -186,7 +187,7 @@ "\n", " fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", " fig.tight_layout()\n", - " fig.savefig(saveloc+f'/{TARGET}_mvsf_{ii:02d}.png')" + " # if SAVEFIG: fig.savefig(saveloc+f'/{TARGET}_mvsf_{ii:02d}.png')" ] }, { @@ -203,60 +204,64 @@ "metadata": {}, "outputs": [], "source": [ - "# saveloc = f'/Users/emigardiner/GWs/holodeck/output/figures/params/mass_vs_freq_{TARGET}_{NVARS}vars'\n", - "# if os.path.exists(saveloc) is False:\n", - "# os.makedirs(saveloc)\n", - "# vmin = 0\n", - "# vmax_bg = 0\n", - "# vmax_ss = 0\n", - "# # find maxes\n", - "# for ii, dat in enumerate(data):\n", - "# parm = params[ii]\n", - "# # get masses\n", - "# ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", - "# bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "saveloc = f'/Users/emigardiner/GWs/holodeck/output/figures/params/mass_vs_freq_{TARGET}_{NVARS}vars_combined'\n", + "if os.path.exists(saveloc) is False:\n", + " os.makedirs(saveloc)\n", + "vmin = 0\n", + "vmax_bg = 0\n", + "vmax_ss = 0\n", + "# find maxes\n", + "for ii, dat in enumerate(data):\n", + " parm = params[ii]\n", + " # get masses\n", + " ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + " bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", "\n", - "# # get histograms\n", - "# hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", - "# hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + " # get histograms\n", + " hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + " hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", "\n", - "# print(f\"{np.max(hist_ss)=}, {np.max(hist_bg)=}\")\n", - "# if np.max(np.log10(hist_ss)) > vmax_ss:\n", - "# vmax_ss = np.max(np.log10(hist_ss))\n", - "# if np.max(np.log10(hist_bg)) > vmax_bg:\n", - "# vmax_bg = np.max(np.log10(hist_bg))\n", + " print(f\"{np.max(hist_ss)=}, {np.max(hist_bg)=}\")\n", + " if np.max(np.log10(hist_ss)) > vmax_ss:\n", + " vmax_ss = np.max(np.log10(hist_ss))\n", + " if np.max(np.log10(hist_bg)) > vmax_bg:\n", + " vmax_bg = np.max(np.log10(hist_bg))\n", "\n", - "# # plot\n", - "# for ii, dat in enumerate(data):\n", - "# parm = params[ii]\n", - "# # get masses\n", - "# ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", - "# bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", + "# plot\n", + "for ii, dat in enumerate(data):\n", + " parm = params[ii]\n", + " # get masses\n", + " ssmtt = dat['sspar'][0].flatten() /MSOL # msol\n", + " bgmtt = dat['bgpar'][0].flatten() /MSOL # msol\n", "\n", - "# # get histograms\n", - "# hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", - "# hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", + " # get histograms\n", + " hist_ss, mme, ffe = np.histogram2d(ssmtt, ssfrq, bins=(mm_edges, ff_edges))\n", + " hist_bg, mme, ffe = np.histogram2d(bgmtt, bgfrq, bins=(mm_edges, ff_edges))\n", "\n", - "# fig, axs = plot.figax(ncols=2, ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(8,4))\n", - "# ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", - "# # print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", + " fig, ax = plot.figax(ylabel='$M$ [M$_\\odot$]', xlabel = '$f$ [nHz]', figsize=(7,5))\n", + " ffgrid, mtgrid, = np.meshgrid(ffe, mme)\n", + " # print(f\"{mtgrid.shape=}, {ffgrid.shape=}\")\n", "\n", - "# ax = axs[0]\n", - "# ax.set_title('$h_c^2$-weighted Background')\n", - "# ax.set_facecolor('k')\n", - "# im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis', vmin=vmin, vmax=vmax_ss)\n", - "# cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", + " # ax = axs[0]\n", + " # ax.set_title('$h_c^2$-weighted Background')\n", + " ax.set_facecolor('k')\n", + " im2 = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno', \n", + " vmin=vmin, vmax=vmax_ss, alpha=0.75)\n", + " cbar2 = plt.colorbar(im2, ax=ax, label='$\\log N$', orientation='vertical',)\n", + " im1 = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_bg), cmap='viridis', \n", + " vmin=vmin, vmax=vmax_ss, alpha=0.75)\n", + " cbar1 = plt.colorbar(im1, ax=ax, label='$\\log N$', orientation='vertical',)\n", "\n", - "# ax = axs[1]\n", - "# ax.set_title('Single Sources')\n", - "# ax.set_facecolor('k')\n", - "# ax.set_ylabel(None)\n", - "# im = ax.pcolormesh(ffgrid, mtgrid, np.log10(hist_ss), cmap='inferno', vmin=vmin, vmax=vmax_ss)\n", - "# cbar = plt.colorbar(im, ax=ax, label='$\\log N$', orientation='horizontal', pad=0.2)\n", "\n", - "# fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", - "# fig.tight_layout()\n", - "# fig.savefig(saveloc+f'/{TARGET}_mvsf_{ii:02d}.png')" + " # ax = axs[1]\n", + " # ax.set_title('Single Sources')\n", + " # ax.set_facecolor('k')\n", + " # ax.set_ylabel(None)\n", + " \n", + " fig.suptitle((f\"{TARGET}={parm[TARGET]:.2f}\"))\n", + " fig.tight_layout()\n", + " if SAVEFIG: \n", + " fig.savefig(saveloc+f'/{TARGET}_mvsf_{ii:02d}.png')" ] }, { From 9e6024c4232c23f365bd33707ebc649cde2d46a9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 12:20:31 -0700 Subject: [PATCH 174/291] Setup script to run individual PTA calibration on entire library. --- holodeck/detstats.py | 201 ++++++++++++++++++++++++++++++++++- scripts/detect_lib_script.py | 38 +++++-- 2 files changed, 226 insertions(+), 13 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index e20b0b66..e60dff6e 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -11,6 +11,8 @@ import h5py import matplotlib.pyplot as plt import os +from datetime import datetime + import holodeck as holo from holodeck import utils, cosmo, log, plot, sam_cython @@ -1700,6 +1702,197 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, return data return + +def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, + sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, + plot=True, debug=False, grid_path=GAMMA_RHO_GRID_PATH, + snr_cython = True, save_ssi=False, ret_dict=False): + """ Calculate detection statistics for an ss library output. + + Parameters + ---------- + hdf_fname : String + Name of hdf file, including path. + output_dir : String + Where to store outputs, including full path. + npsrs : int + Number of pulsars to place in pta. + sigma : int or (P,) array + Noise in each pulsar + nskies : int + Number of sky realizationt to create. + thresh : float + Threshold for detection in realization. + plot : Bool + Whether or not to make and save plots. + debug : Bool + Whether to print info along the way. + grid_path : string + Path to snr interpolation grid + snr_cython : Bool + Whether to use cython interpolation for ss snr calculation. + save_ssi : Bool + Whether to store gamma_ssi in npz arrays + + Returns + ------- + dp_ss : (N,R,S) Ndarray + Single source detection probability for each of + - N parameter space samples + - R strain realizations + - S sky realizations + dp_bg : (N,R) Ndarray + Background detectin probability. + snr_ss : (N,F,R,S,L) + Signal to noise ratio for every single source in every + realization at each of + - F frequencies + - L loudest at frequency + snr_bg : (N,F,R) + Signal to noise ratio of the background at each + frequency of each realization. + df_ss : (N,) + Fraction of realizations with a single source detection, for each sample. + df_bg : (N,) 1Darray + Fraction of realizations with a background detection, for each sample. + ev_ss : (N,R,) NDarray + Expectation number of single source detections, averaged across realizations, + for each sample. + + """ + + # Read in hdf file + ssfile = h5py.File(hdf_name, 'r') + fobs = ssfile['fobs'][:] + dur = 1.0/fobs[0] + cad = 1.0/(2*fobs[-1]) + # if dfobs is None: dfobs = ssfile['dfobs'][:] + # if dur is None: dur = ssfile['pta_dur'][0] + # if cad is None: cad = ssfile['pta_cad'][0] + hc_ss = ssfile['hc_ss'][...] + hc_bg = ssfile['hc_bg'][...] + shape = hc_ss.shape + nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3] + + # Assign output folder + import os + if (os.path.exists(output_dir) is False): + print('Making output directory.') + os.makedirs(output_dir) + else: + print('Writing to an existing directory.') + + # build PTA pulsar positions + if debug: print('Placing pulsar.') + phis = np.random.uniform(0, 2*np.pi, size = npsrs) + thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + if debug: print(f"{phis.shape=}, {thetas.shape=}, {dur=}, {cad=}") + # psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + # phi=phis, theta=thetas) + + # Build ss skies + if debug: print('Building ss skies.') + theta_ss, phi_ss, Phi0_ss, iota_ss, psi_ss = _build_skies(nfreqs, nskies, nloudest) + + # Calculate DPs, SNRs, and DFs + if debug: print('Calculating SS and BG detection statistics.') + dp_ss = np.zeros((nsamps, nreals, nskies)) # (N,R,S) + dp_bg = np.zeros((nsamps, nreals)) # (N,R) + snr_bg = np.zeros((nsamps, nfreqs, nreals)) + df_ss = np.zeros(nsamps) + df_bg = np.zeros(nsamps) + ev_ss = np.zeros((nsamps, nreals, nskies)) + if save_ssi: + snr_ss = np.zeros((nsamps, nfreqs, nreals, nskies, nloudest)) + gamma_ssi = np.zeros((nsamps, nfreqs, nreals, nskies, nloudest)) + + # # one time calculations + # Num = nfreqs * nloudest # number of single sources in a single strain realization (F*L) + # Fe_bar = _Fe_thresh(Num) # scalar + + for nn in range(nsamps): + if debug: + print('on sample nn=%d out of N=%d' % (nn,nsamps)) + samp_dur = datetime.now() + real_dur = datetime.now() + + # calibrate individual realization PTAs + for rr in range(nreals): + if debug and rr<10: + now = datetime.now() + print(f"{nn=}, {rr=}, {now-real_dur} s") + real_dur = now + + psrs = calibrate_one_pta(hc_bg[nn,:,rr], fobs, npsrs, tol=tol, maxbads=maxbads, + sigmin=sigmin, sigmax=sigmax, sigstart=sigstart) + + # get background detstats + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs, hc_bg[nn,:,rr:rr+1], ret_snr=True) + dp_bg[nn,rr], snr_bg[nn,:,rr] = _dp_bg.squeeze(), _snr_bg.squeeze() + + # get single source detstats + _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( + psrs, fobs, hc_ss[nn,:,rr:rr+1], hc_bg[nn,:,rr:rr+1], + nskies=nskies, ret_snr=True, + theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, + iota_ss=iota_ss, psi_ss=psi_ss) + dp_ss[nn,rr,:] = _dp_ss.squeeze() + if save_ssi: + snr_ss[nn,:,rr] = _snr_ss.squeeze() + gamma_ssi[nn,:,rr] = _gamma_ssi.squeeze() + ev_ss[nn,rr] = expval_of_ss(_gamma_ssi) + if debug: + now = datetime.now() + print(f"Sample {nn} took {now-samp_dur} s") + samp_dur = now + # dp_bg[nn,:], snr_bg[nn,...] = detect_bg_pta(psrs, fobs, hc_bg[nn], ret_snr=True) + # vals_ss = detect_ss_pta(psrs, fobs, hc_ss[nn], hc_bg[nn], + # ret_snr=True, gamma_cython=True, snr_cython=snr_cython, + # theta_ss=theta_ss, phi_ss=phi_ss, Phi0_ss=Phi0_ss, + # iota_ss=iota_ss, psi_ss=psi_ss, grid_path=grid_path) + # dp_ss[nn,:,:] = vals_ss[0] + # if save_ssi: + # snr_ss[nn] = vals_ss[1] + # gamma_ssi[nn] = vals_ss[2] + df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) + + + if plot: + fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], + dp_ss[nn], dp_bg[nn], + df_ss[nn], df_bg[nn], nn=nn) + plot_fname = (output_dir+'/p%06d_detprob.png' % nn) # need to make this directory + fig.savefig(plot_fname, dpi=100) + plt.close(fig) + + if debug: print('Saving npz files and allsamp plots.') + fig1 = plot_detprob(dp_ss, dp_bg, nsamps) + fig2 = plot_detfrac(df_ss, df_bg, nsamps, thresh) + fig1.savefig(output_dir+'/allsamp_detprobs.png', dpi=300) + fig2.savefig(output_dir+'/allsamp_detfracs.png', dpi=300) + plt.close(fig1) + plt.close(fig2) + if save_ssi: + np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss, gamma_ssi=gamma_ssi) + else: + np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + snr_bg=snr_bg, ev_ss = ev_ss) + + # return dictionary + if ret_dict: + data = { + 'dp_ss':dp_ss, 'dp_bg':dp_bg, 'df_ss':df_ss, 'df_bg':df_bg, + 'snr_bg':snr_bg, 'ev_ss':ev_ss + } + if save_ssi: + data.update({'gamma_ssi':gamma_ssi}) + data.update({'snr_ss':snr_ss}) + return data + return + + + def _build_pta(npsrs, sigma, dur, cad): # build PTA phis = np.random.uniform(0, 2*np.pi, size = npsrs) @@ -2171,7 +2364,8 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, return rsigmas, avg_dps, std_dps def calibrate_one_pta(hc_bg, fobs, npsrs, - sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03): + sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, + phis=None, thetas=None): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2194,12 +2388,11 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, cad = 1.0/(2.0*fobs[-1]) # randomize pulsar positions - phis = np.random.uniform(0, 2*np.pi, size = npsrs) - thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + if phis is None: phis = np.random.uniform(0, 2*np.pi, size = npsrs) + if thetas is None: thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigstart, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis])[0] - print(dp_bg) nbads=0 # calibrate sigma diff --git a/scripts/detect_lib_script.py b/scripts/detect_lib_script.py index 904805b2..7e0e7729 100644 --- a/scripts/detect_lib_script.py +++ b/scripts/detect_lib_script.py @@ -41,6 +41,9 @@ DEF_THRESH = 0.5 DEF_SNR_CYTHON = True DEF_SAVE_SSI = False +DEF_CLBRT = False +DEF_TOL = 0.01 +DEF_MAXBADS = 5 GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system @@ -55,11 +58,16 @@ def _setup_argparse(): help='number of frequency bins') # parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, # help='pta duration in yrs') + + parser.add_argument('-t', '--tol', action='store', dest='tol', type=float, default=DEF_TOL, + help='tolerance for BG DP calibration') + parser.add_argument('-b', '--maxbads', action='store', dest='maxbads', type=int, default=DEF_MAXBADS, + help='number of bad sigmas to try before expanding the search range') parser.add_argument('-p', '--npsrs', action='store', dest='npsrs', type=int, default=DEF_NPSRS, help='number of pulsars in pta') parser.add_argument('--sigma', action='store', dest='sigma', type=float, default=DEF_SIGMA, - help='sigma for white noise of pulsars') + help='sigma for white noise of pulsars, or starting sigma if using individual realization calibration') parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, help='number of ss sky realizations') @@ -74,6 +82,8 @@ def _setup_argparse(): help='Use cython for ss snr calculations') parser.add_argument('--save_ssi', action='store_true', default=DEF_SAVE_SSI, help="Save 'gamma_ssi', the detprob of each single source.") + parser.add_argument('--clbrt', action='store_true', default=DEF_CLBRT, + help="Whether or not to calibrate the PTA for individual realizations.") args = parser.parse_args() return args @@ -102,16 +112,26 @@ def main(): hdf_name = args.lib_path+'/sam_lib.hdf5' print('Hdf file:', hdf_name) - - output_dir = (args.lib_path+'/detstats/psrs%d_sigma%.2e' - % (args.npsrs, args.sigma)) + if args.clbrt: + output_dir = (args.lib_path+'/detstats/clbrt_psrs%d' + % (args.npsrs)) + else: + output_dir = (args.lib_path+'/detstats/psrs%d_sigma%.2e' + % (args.npsrs, args.sigma)) print('Output dir:', output_dir) - ds.detect_lib(hdf_name, output_dir, args.npsrs, args.sigma, - nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, - grid_path=args.grid_path, - snr_cython=args.snr_cython, save_ssi=args.save_ssi) - + if args.clbrt: + ds.detect_lib_clbrt_pta(hdf_name, output_dir, args.npsrs, + sigstart = args.sigma, sigmin=1e-8, sigmax=1e-5, tol=args.tol, maxbads=args.maxbads, + nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, + grid_path=args.grid_path, + snr_cython=args.snr_cython, save_ssi=args.save_ssi) + else: + ds.detect_lib(hdf_name, output_dir, args.npsrs, args.sigma, + nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, + grid_path=args.grid_path, + snr_cython=args.snr_cython, save_ssi=args.save_ssi) + if __name__ == "__main__": main() \ No newline at end of file From 834d8b06395b793784bbe4f0f7c255848c7dc2cd Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 12:28:04 -0700 Subject: [PATCH 175/291] Save npz files of individual detstats, even if not all are reached. --- .../tk12_lib_ss_vs_bg_dp.ipynb | 332 ++++++++++++++++++ holodeck/detstats.py | 13 +- 2 files changed, 341 insertions(+), 4 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb b/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb new file mode 100644 index 00000000..442485df --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb @@ -0,0 +1,332 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", + "\n", + "print(hdf.keys())\n", + "sample_params = hdf['sample_params'][...]\n", + "hc_ss = hdf['hc_ss'][...]\n", + "hc_bg = hdf['hc_bg'][...]\n", + "sspar = hdf['sspar'][...]\n", + "bgpar = hdf['bgpar'][...]\n", + "fobs_gw_cents = hdf['fobs'][:]\n", + "hdf.close()\n", + "\n", + "dur = 1/fobs_gw_cents[0]\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", + "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", + "print(npz.files)\n", + "param_names = npz['param_names']\n", + "print(param_names)\n", + "print(npz['class_name'])\n", + "lib_name = '%s v%s, %d samples' % (npz['class_name'], npz['librarian_version'], nsamps)\n", + "print(lib_name)\n", + "# print(npz['sam_shape'])\n", + "npz.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10/detstats/psrs40_sigma4.31e-06/detstats.npz')\n", + "\n", + "dp_ss = npz['dp_ss']\n", + "dp_bg = npz['dp_bg']\n", + "df_ss = npz['df_ss']\n", + "df_bg = npz['df_bg']\n", + "ev_ss = npz['ev_ss']\n", + "print(f\"{ev_ss.shape=}, {dp_ss.shape=}\")\n", + "npz.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sample_params[0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# def_draw_ev(ax):\n", + "# plt.rcParams['mathtext.fontset'] = \"cm\"\n", + "# plt.rcParams[\"font.family\"] = \"serif\"\n", + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True, errors=False,\n", + " ms=2):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + " if errors:\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.05, markersize=ms)\n", + " else: \n", + " hh = ax.scatter(xx, yy, color=color, label=label,\n", + " linestyle='', marker='o', alpha=0.05, s=ms)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dp_ss, dp_bg, target_params=None, norm=None, \n", + " use_ev=False, errors=False, ms=2, alpha=0.05, color='tab:blue', cmap=cm.rainbow):\n", + " # colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " # cmin = \n", + "\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) \n", + " \n", + " for ii in range(len(dp_ss)):\n", + " # label = '%.2f' % params[ii][target_param]\n", + " if target_params is not None and norm is not None:\n", + " color = cmap(norm(target_params[ii]))\n", + " detss = dp_ss[ii] # use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, dp_bg[ii], color=color, errors=errors, ms=ms) #, label=label)\n", + "\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "\n", + "\n", + "\n", + "# fig2 = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, errors=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig1 = plot_dpss_vs_dpbg(dp_ss, dp_bg, use_ev=False)\n", + "fig2 = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Color by params" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target = 'hard_time'\n", + "def normalize_target(target, param_names=param_names, sample_params=sample_params):\n", + " idx = list(param_names).index(target)\n", + " target_params = sample_params[:,idx]\n", + " mintarget = np.min(target_params)\n", + " maxtarget = np.max(target_params)\n", + " norm = mpl.colors.Normalize(vmin=mintarget, vmax=maxtarget)\n", + " return target_params, norm" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Connect to hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target_params, norm = normalize_target('hard_time')\n", + "cmap=cm.rainbow\n", + "fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", + " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", + "cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", + " label='$\\\\tau_\\mathrm{hard}$', shrink=0.75 )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(nsamps, nfreqs, nreals)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(ev_ss.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(param_names)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cmap=cm.rainbow\n", + "\n", + "for tt, target in enumerate(param_names):\n", + " target_params, norm = normalize_target(target)\n", + " fig = plot_dpss_vs_dpbg(ev_ss, dp_bg, use_ev=True, target_params=target_params, norm=norm, \n", + " errors=False, cmap=cmap, ms=5, alpha=0.1)\n", + " cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), \n", + " label=target, shrink=0.75 )\n", + " # fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/params/ss_vs_bg_dp_lib09A_single_pta/{target}.png')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig.axes[0].set_ylim(10**-1, 4)\n", + "fig" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Diverging Colorbar for ratio!!\n", + "## make this for individual sample" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## make this for whole library" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/holodeck/detstats.py b/holodeck/detstats.py index e60dff6e..611665f2 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1775,7 +1775,6 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, nsamps, nfreqs, nreals, nloudest = shape[0], shape[1], shape[2], shape[3] # Assign output folder - import os if (os.path.exists(output_dir) is False): print('Making output directory.') os.makedirs(output_dir) @@ -1856,7 +1855,13 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, # gamma_ssi[nn] = vals_ss[2] df_ss[nn], df_bg[nn] = detfrac_of_reals(dp_ss[nn], dp_bg[nn], thresh) - + if save_ssi: + np.savez(output_dir+f'/detstats_p{nn:06d}.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss, gamma_ssi=gamma_ssi) + else: + np.savez(output_dir+f'/detstats_p{nn:06d}.npz', dp_ss=dp_ss[nn], dp_bg=dp_bg[nn], df_ss=df_ss[nn], df_bg=df_bg[nn], + snr_bg=snr_bg[nn], ev_ss = ev_ss[nn]) + if plot: fig = plot_sample_nn(fobs, hc_ss[nn], hc_bg[nn], dp_ss[nn], dp_bg[nn], @@ -1873,10 +1878,10 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, plt.close(fig1) plt.close(fig2) if save_ssi: - np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + np.savez(output_dir+'/detstats_lib.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, snr_ss=snr_ss, snr_bg=snr_bg, ev_ss = ev_ss, gamma_ssi=gamma_ssi) else: - np.savez(output_dir+'/detstats.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, + np.savez(output_dir+'/detstats_lib.npz', dp_ss=dp_ss, dp_bg=dp_bg, df_ss=df_ss, df_bg=df_bg, snr_bg=snr_bg, ev_ss = ev_ss) # return dictionary From 9bdb0d6c16d1b79ccc2d18b9ab90e57fccaaa142 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 14:08:00 -0700 Subject: [PATCH 176/291] Improve detect_lib_clbrt_pta with sigmin and sigmax setting by previous realization, etc --- holodeck/detstats.py | 45 ++++++++++++++++++++++++++---------- scripts/detect_lib_script.py | 6 ++++- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 611665f2..97dea8ca 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1811,19 +1811,26 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, for nn in range(nsamps): if debug: - print('on sample nn=%d out of N=%d' % (nn,nsamps)) + print('\non sample nn=%d out of N=%d' % (nn,nsamps)) samp_dur = datetime.now() real_dur = datetime.now() # calibrate individual realization PTAs for rr in range(nreals): - if debug and rr<10: + if debug: now = datetime.now() - print(f"{nn=}, {rr=}, {now-real_dur} s") + if (rr%5==0): + print(f"{nn=}, {rr=}, {now-real_dur} s per realization") real_dur = now - psrs = calibrate_one_pta(hc_bg[nn,:,rr], fobs, npsrs, tol=tol, maxbads=maxbads, - sigmin=sigmin, sigmax=sigmax, sigstart=sigstart) + # use sigmin and sigmax from previous realization, + # unless it's the first realization of the sample + if nn==0: + _sigstart, _sigmin, _sigmax = sigstart, sigmin, sigmax + psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[nn,:,rr], fobs, npsrs, tol=tol, maxbads=maxbads, + sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True) + _sigmin /= 10 + _sigmax *= 10 # get background detstats _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs, hc_bg[nn,:,rr:rr+1], ret_snr=True) @@ -2370,7 +2377,7 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, def calibrate_one_pta(hc_bg, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None): + phis=None, thetas=None, ret_sig = False): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2395,11 +2402,13 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, # randomize pulsar positions if phis is None: phis = np.random.uniform(0, 2*np.pi, size = npsrs) if thetas is None: thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) - psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigstart, + sigma = sigstart + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis])[0] - nbads=0 + nclose=0 # number of attempts close to 0.5, could be stuck close + nfar=0 # number of attempts far from 0.5, could be stuck far # calibrate sigma while np.abs(dp_bg-0.50)>tol: sigma = np.mean([sigmin, sigmax]) @@ -2407,15 +2416,27 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg)[0] # if debug: print(f"{dp_bg=}") + if dp_bg<0.1 or dp_bg>0.9: + nfar +=1 + if nfar>3*maxbads: + if debug: print(f"{nfar=}, {dp_bg=}, {sigmin=:e}, {sigmax=:e}") + if dp_bg<0.1: # stuck way too low, allow much lower sigmin to raise DP + sigmin = sigmin/10**3 + if dp_bg>0.9: # stuck way too high, allow much higher sigmax to lower DP + sigmax = sigmax*10**3 + nfar = 0 if dp_bg<0.49: # dp too low, lower sigma sigmax = sigma elif dp_bg>0.51: # dp too high, raise sigma sigmin = sigma else: - nbads += 1 # check how many attempts between 0.49 and 0.51 fail - if nbads>maxbads: # if many fail, we're stuck; expand sampling range - if debug: print(f"{nbads=}", f"{dp_bg=}") + nclose += 1 # check how many attempts between 0.49 and 0.51 fail + if nclose>maxbads: # if many fail, we're stuck; expand sampling range + if debug: print(f"{nclose=}", f"{dp_bg=}") sigmin = sigmin/5 sigmax = sigmax*5 - nbads=0 + nclose=0 + if ret_sig: + return psrs, sigma, sigmin, sigmax return psrs + diff --git a/scripts/detect_lib_script.py b/scripts/detect_lib_script.py index 7e0e7729..8404716e 100644 --- a/scripts/detect_lib_script.py +++ b/scripts/detect_lib_script.py @@ -68,6 +68,10 @@ def _setup_argparse(): help='number of pulsars in pta') parser.add_argument('--sigma', action='store', dest='sigma', type=float, default=DEF_SIGMA, help='sigma for white noise of pulsars, or starting sigma if using individual realization calibration') + parser.add_argument('--sigmin', action='store', dest='sigmin', type=float, default=1e-10, + help='sigma minimum for calibration') + parser.add_argument('--sigmax', action='store', dest='sigmax', type=float, default=1e-3, + help='sigma maximum for calibration') parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, help='number of ss sky realizations') @@ -122,7 +126,7 @@ def main(): if args.clbrt: ds.detect_lib_clbrt_pta(hdf_name, output_dir, args.npsrs, - sigstart = args.sigma, sigmin=1e-8, sigmax=1e-5, tol=args.tol, maxbads=args.maxbads, + sigstart = args.sigma, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, grid_path=args.grid_path, snr_cython=args.snr_cython, save_ssi=args.save_ssi) From 973c0cc51f864cfd8dff0490ee076ab23829cadb Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 14:57:37 -0700 Subject: [PATCH 177/291] Improve check for expanding sigma guess range in pta calibration; check if the bounds are very close and we're far from our goal. --- holodeck/detstats.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 97dea8ca..50d0618b 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1817,20 +1817,20 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, # calibrate individual realization PTAs for rr in range(nreals): + if rr==0: + _sigstart, _sigmin, _sigmax = sigstart, sigmin, sigmax if debug: now = datetime.now() if (rr%5==0): - print(f"{nn=}, {rr=}, {now-real_dur} s per realization") + print(f"{nn=}, {rr=}, {now-real_dur} s per realization, {_sigmin=:.2e}, {_sigmax=:.2e}, {_sigstart=:.2e}") real_dur = now # use sigmin and sigmax from previous realization, # unless it's the first realization of the sample - if nn==0: - _sigstart, _sigmin, _sigmax = sigstart, sigmin, sigmax psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[nn,:,rr], fobs, npsrs, tol=tol, maxbads=maxbads, sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True) - _sigmin /= 10 - _sigmax *= 10 + _sigmin /= 2 + _sigmax *= 2 # get background detstats _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs, hc_bg[nn,:,rr:rr+1], ret_snr=True) @@ -2409,30 +2409,38 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, nclose=0 # number of attempts close to 0.5, could be stuck close nfar=0 # number of attempts far from 0.5, could be stuck far + # calibrate sigma while np.abs(dp_bg-0.50)>tol: - sigma = np.mean([sigmin, sigmax]) + sigma = np.mean([sigmin, sigmax]) # a weighted average would be better psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg)[0] + # if debug: print(f"{dp_bg=}") - if dp_bg<0.1 or dp_bg>0.9: + if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): nfar +=1 - if nfar>3*maxbads: - if debug: print(f"{nfar=}, {dp_bg=}, {sigmin=:e}, {sigmax=:e}") - if dp_bg<0.1: # stuck way too low, allow much lower sigmin to raise DP - sigmin = sigmin/10**3 - if dp_bg>0.9: # stuck way too high, allow much higher sigmax to lower DP - sigmax = sigmax*10**3 + + if (nfar>5*maxbads # if we've had many bad guesses + or (sigmin/sigmax > 0.99 # or our range is small and we are far from the goal + and (dp_bg<0.4 or dp_bg>0.6))): + + # then we must expand the range + if debug: print(f"STUCK! {nfar=}, {dp_bg=}, {sigmin=:e}, {sigmax=:e}") + if dp_bg < 0.5-tol: # stuck way too low, allow much lower sigmin to raise DP + sigmin = sigmin/3 + if dp_bg > 0.5+tol: # stuck way too high, allow much higher sigmax to lower DP + sigmax = sigmax*3 + nfar = 0 - if dp_bg<0.49: # dp too low, lower sigma + if dp_bg<0.5-tol: # dp too low, lower sigma sigmax = sigma - elif dp_bg>0.51: # dp too high, raise sigma + elif dp_bg>0.5+tol: # dp too high, raise sigma sigmin = sigma else: nclose += 1 # check how many attempts between 0.49 and 0.51 fail if nclose>maxbads: # if many fail, we're stuck; expand sampling range - if debug: print(f"{nclose=}", f"{dp_bg=}") + if debug: print(f"{nclose=}, {dp_bg=}, {sigmin=:e}, {sigmax=:e}") sigmin = sigmin/5 sigmax = sigmax*5 nclose=0 From a9efaead84443793aca64b23b8d26fd815e303a2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 15:03:51 -0700 Subject: [PATCH 178/291] Add comments. --- holodeck/detstats.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 50d0618b..4c7308dd 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2393,6 +2393,12 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, ------- psrs : hasasia.sim.pta object Calibrated PTA. + sigmin : float + minimum of the final sigma range used, returned only if ret_sig=True + sigmax : float, returned only if ret_sig=True + maximum of the final sigma range used + sigma : float + final sigma, returned only if ret_sig=True """ # get duration and cadence from fobs @@ -2421,6 +2427,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): nfar +=1 + # check if we need to expand the range if (nfar>5*maxbads # if we've had many bad guesses or (sigmin/sigmax > 0.99 # or our range is small and we are far from the goal and (dp_bg<0.4 or dp_bg>0.6))): @@ -2432,17 +2439,22 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, if dp_bg > 0.5+tol: # stuck way too high, allow much higher sigmax to lower DP sigmax = sigmax*3 + # reset count for far guesses nfar = 0 + + # check how we should narrow our range if dp_bg<0.5-tol: # dp too low, lower sigma sigmax = sigma elif dp_bg>0.5+tol: # dp too high, raise sigma sigmin = sigma else: nclose += 1 # check how many attempts between 0.49 and 0.51 fail + + # check if we are stuck near the goal value with a bad range if nclose>maxbads: # if many fail, we're stuck; expand sampling range if debug: print(f"{nclose=}, {dp_bg=}, {sigmin=:e}, {sigmax=:e}") - sigmin = sigmin/5 - sigmax = sigmax*5 + sigmin = sigmin/3 + sigmax = sigmax*3 nclose=0 if ret_sig: return psrs, sigma, sigmin, sigmax From 95e9750634a86d8860bd6c80b17a5d78523cd349 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 25 Jun 2023 15:23:30 -0700 Subject: [PATCH 179/291] Add TODO comments for detstats select sample calculations. --- holodeck/detstats.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 4c7308dd..745122dd 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1759,6 +1759,9 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, Expectation number of single source detections, averaged across realizations, for each sample. + # TODO: Add an option to calculate just for a particular selection of samples, + e.g. pass in nn_min and nn_max and use for nn in range(nn_min, nn_max) instead of + nn in range(neals). Then combine these into an hdf file separately. """ # Read in hdf file From b18c999a50cdc3348bef707cf1dbd66f471a2ebf Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 08:52:56 -0700 Subject: [PATCH 180/291] Improve detstats. --- .../tk12_lib_ss_vs_bg_dp.ipynb | 183 +++++++++++++++++- holodeck/detstats.py | 2 +- scripts/detect_lib_script.py | 8 +- 3 files changed, 186 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb b/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb index 442485df..fde403a2 100644 --- a/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb +++ b/ecg-notebooks/parameter_investigation/tk12_lib_ss_vs_bg_dp.ipynb @@ -86,7 +86,8 @@ "outputs": [], "source": [ "npz = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss64_09Bn1000_2023-06-22_uniform-09b_n1000_r100_f40_l10/detstats/psrs40_sigma4.31e-06/detstats.npz')\n", - "\n", + "print(npz.files)\n", + "# print(npz['snr_ss'].shape)\n", "dp_ss = npz['dp_ss']\n", "dp_bg = npz['dp_bg']\n", "df_ss = npz['df_ss']\n", @@ -281,8 +282,15 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Diverging Colorbar for ratio!!\n", - "## make this for individual sample" + "# Number Density of Ratio vs. Parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ratio" ] }, { @@ -290,14 +298,179 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "nskies = ev_ss.shape[-1]\n", + "ratio = ev_ss/dp_bg[:,:,np.newaxis]\n", + "nbins=40\n", + "ratio_edges = np.geomspace(np.min(ratio), np.max(ratio), nbins)\n", + "print(f\"{ratio.shape=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Ratio vs Hardening Time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "thard = np.repeat(sample_params[:,0], nreals*nskies).reshape(nsamps, nreals, nskies)\n", + "print(f\"{thard.shape=}\")\n", + "th_edges = np.geomspace(np.min(sample_params[:,0]), np.max(sample_params[:,0]), nbins)\n", + "hist, dpe, the = np.histogram2d(ratio.flatten(), thard.flatten(), bins=(ratio_edges, th_edges))\n", + "\n", + "DP, TH = np.meshgrid(ratio_edges, th_edges)\n", + "fig, ax = plot.figax(xlabel='Hardening Time $\\\\tau_\\mathrm{hard}$', ylabel='Ratio $\\langle N_\\mathrm{SS} \\\\rangle / \\mathrm{DP}_\\mathrm{BG}$')\n", + "ax.set_facecolor('k')\n", + "im = ax.pcolormesh(TH, DP, np.log10(hist))\n", + "cbar = plt.colorbar(im, ax=ax, label='$\\log N$')" + ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "## make this for whole library" + "### Ratio vs GSMF Mchar0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(param_names)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mchar = np.repeat(sample_params[:,2], nreals*nskies).reshape(nsamps, nreals, nskies)\n", + "print(f\"{mchar.shape=}\")\n", + "mc_edges = np.linspace(np.min(sample_params[:,2]), np.max(sample_params[:,2]), nbins)\n", + "hist, mce, the = np.histogram2d(ratio.flatten(), mchar.flatten(), bins=(ratio_edges, mc_edges))\n", + "\n", + "DP, MC = np.meshgrid(ratio_edges, mc_edges)\n", + "fig, ax = plot.figax(xlabel='log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot)$', ylabel='Ratio $\\langle N_\\mathrm{SS} \\\\rangle / \\mathrm{DP}_\\mathrm{BG}$',\n", + " xscale='linear')\n", + "ax.set_facecolor('k')\n", + "im = ax.pcolormesh(MC, DP, np.log10(hist))\n", + "cbar = plt.colorbar(im, ax=ax, label='$\\log N$')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Background DP vs Param" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_2D_hist(xx, yy, xlabel, ylabel, xscale, nbins=40):\n", + " if xscale == 'linear':\n", + " xx_edges = np.linspace(np.min(xx), np.max(xx), nbins)\n", + " else:\n", + " xx_edges = np.geomspace(np.min(xx), np.max(xx), nbins)\n", + " print(f\"{np.min(xx)=}, {np.max(xx)=}, {np.min(yy)=}, {np.max(yy)=}\")\n", + " yy_edges = np.geomspace(np.min(yy), np.max(yy), nbins)\n", + " print(f\"{xx.shape=}, {yy.shape=}\")\n", + "\n", + " hist, temp1, temp2 = np.histogram2d(dp_bg.flatten(), thard.flatten(), bins=(yy_edges, xx_edges))\n", + "\n", + " YY, XX = np.meshgrid(yy_edges, xx_edges)\n", + " fig, ax = plot.figax_single(xlabel=xlabel, ylabel=ylabel,\n", + " xscale=xscale)\n", + " ax.set_facecolor('k')\n", + " im = ax.pcolormesh(XX, YY, np.log10(hist))\n", + " cbar = plt.colorbar(im, ax=ax, label='$\\log N$')\n", + " return fig, hist" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### hard time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = np.repeat(sample_params[:,0], nreals).reshape(nsamps, nreals)\n", + "yy = dp_bg\n", + "xlabel = '$\\\\tau_\\mathrm{hard}$'\n", + "ylabel = '$\\mathrm{DP}_\\mathrm{BG}$'\n", + "xscale = 'linear'\n", + "fig, hist = plot_2D_hist(xx,yy,xlabel,ylabel,xscale)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### gsmf phi0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "plt.hist(sample_params[:,1], bins=200)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = np.repeat(sample_params[:,1], nreals).reshape(nsamps, nreals)\n", + "yy = dp_bg\n", + "xlabel = 'GSMF $\\psi_0$'\n", + "ylabel = '$\\mathrm{DP}_\\mathrm{BG}$'\n", + "xscale = 'linear'\n", + "fig, hist = plot_2D_hist(xx,yy,xlabel,ylabel,xscale,)\n", + "\n", + "print(f\"{holo.utils.stats(xx)=}, \\n{holo.utils.stats(yy)=}, \\n{holo.utils.stats(hist)=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = np.repeat(sample_params[:,3], nreals).reshape(nsamps, nreals)\n", + "yy = dp_bg\n", + "xlabel = 'MMB $\\log(M_\\mathrm{amp}/\\mathrm{M}_\\odot)$'\n", + "ylabel = '$\\mathrm{DP}_\\mathrm{BG}$'\n", + "xscale = 'linear'\n", + "fig, hist = plot_2D_hist(xx,yy,xlabel,ylabel,xscale)\n", + "\n", + "print(f\"{holo.utils.stats(xx)=}, \\n{holo.utils.stats(yy)=}, \\n{holo.utils.stats(hist)=}\")" ] }, { diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 745122dd..70b4234d 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -1824,7 +1824,7 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, _sigstart, _sigmin, _sigmax = sigstart, sigmin, sigmax if debug: now = datetime.now() - if (rr%5==0): + if (rr%10==0): print(f"{nn=}, {rr=}, {now-real_dur} s per realization, {_sigmin=:.2e}, {_sigmax=:.2e}, {_sigstart=:.2e}") real_dur = now diff --git a/scripts/detect_lib_script.py b/scripts/detect_lib_script.py index 8404716e..94e20a31 100644 --- a/scripts/detect_lib_script.py +++ b/scripts/detect_lib_script.py @@ -30,6 +30,8 @@ from holodeck.constants import YR import numpy as np import argparse +from datetime import datetime + DEF_NFREQS = holo.librarian.DEF_NUM_FBINS # DEF_PTA_DUR = holo.librarian.DEF_PTA_DUR @@ -102,6 +104,9 @@ def _setup_argparse(): # return dur, cad, dfobs def main(): + + start_time = datetime.now() + print(f"starting at {start_time}") # setup command line arguments args = _setup_argparse() print('npsrs=%d, sigma=%e s, nskies=%d, thresh=%f' % @@ -135,7 +140,8 @@ def main(): nskies=args.nskies, thresh=args.thresh, plot=args.plot, debug=args.debug, grid_path=args.grid_path, snr_cython=args.snr_cython, save_ssi=args.save_ssi) - + end_time = datetime.now() + print(f"Start time: {start_time}\nEnd time: {end_time}\nTotal time: {end_time-start_time}") if __name__ == "__main__": main() \ No newline at end of file From 5b79ff13371c097c2668d708069eab6f47e24077 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 12:17:16 -0700 Subject: [PATCH 181/291] Setup args in detect_model_clbrt_pta.py --- .../detect_model_clbrt_pta.py | 203 ++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py new file mode 100644 index 00000000..b98c3721 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -0,0 +1,203 @@ +import numpy as np +import holodeck as holo +import argparse +from holodeck import detstats +from datetime import datetime + +# sample +SHAPE = None +DEF_NLOUDEST = 10 +DEF_NREALS = 100 +DEF_NFREQS = 40 +DEF_NVARS = 21 + +# pta calibration +DEF_NSKIES = 100 +DEF_NPSRS = 40 + +DEF_TOL = 0.01 +DEF_MAXBADS = 5 +GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' + +# settings to vary +CONSTRUCT_ALL = False +CONSTRUCT_DETSTATS = False + + + +def main(): + start_time = datetime.now() + print("-----------------------------------------") + print(f"starting at {start_time}") + print("-----------------------------------------") + + load_data_from_file = args.anatomy_path+f'/{args.target}_{args.nvars}vars_clbrt_pta.npz' + save_data_to_file = args.anatomy_path+f'/{args.target}_{args.nvars}vars_clbrt_pta.npz' + + args = _setup_argparse() + print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" + % (args.nreals, args.nskies, args.npsrs, args.target)) + if args.construct or args.detstats: + if args.construct: + params_list = np.linsapce(0,1,args.nvars) + data, params, = vary_parameter(target_param=args.target, params_list=params_list, + nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest) + else: + file = np.load(load_data_from_file, allow_pickle=True) + print(file.files) + data = file['data'] + params = file['params'] + file.close() + dsdat = [] + for ii, _data in enumerate(data): + if args.debug: print(f"on var {ii=} out of {args.nvars}") + else: + print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") + + + + + + end_time = datetime.now() + print("-----------------------------------------") + print(f"ending at {end_time}") + print(f"total time: {end_time - start_time}") + print("-----------------------------------------") + +if __name__ == "__main__": + main() + + + + + + + +def _setup_argparse(): + parser = argparse.ArgumentParser() + parser.add_argument('target', action='store', type=str, + help="target parameter to vary") + # parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + # help="gamma-rho interpolation grid path") + + # sample models setup + parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, + help='number of frequency bins') + parser.add_argument('-f', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, + help='number of strain realizations') + parser.add_argument('-l', '--nloudest', action='store', dest='nloudest', type=int, default=DEF_NLOUDEST, + help='number of loudest single sources') + parser.add_argument('-v', '--nvars', actions='store', dest='nvars', type=int, default=DEF_NVARS, + help='number of variations on target param') + # parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, + # help='pta duration in yrs') + + + + # pta setup + parser.add_argument('-p', '--npsrs', action='store', dest='npsrs', type=int, default=DEF_NPSRS, + help='number of pulsars in pta') + parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, + help='number of ss sky realizations') + + # pta calibration settings + parser.add_argument('--sigstart', action='store', dest='sigma', type=float, default=1e-7, + help='starting sigma if for realization calibration') + parser.add_argument('--sigmin', action='store', dest='sigmin', type=float, default=1e-10, + help='sigma minimum for calibration') + parser.add_argument('--sigmax', action='store', dest='sigmax', type=float, default=1e-4, + help='sigma maximum for calibration') + parser.add_argument('--thresh', action='store', dest='thresh', type=float, default=0.5, + help='threshold for detection fractions') + parser.add_argument('-t', '--tol', action='store', dest='tol', type=float, default=DEF_TOL, + help='tolerance for BG DP calibration') + parser.add_argument('-b', '--maxbads', action='store', dest='maxbads', type=int, default=DEF_MAXBADS, + help='number of bad sigmas to try before expanding the search range') + + # general settings + parser.add_argument('--construct', action='store_true', default=CONSTRUCT_ALL, + help='construct data and detstats for each varying param') + parser.add_argument('--detstats', action='store_true', default=CONSTRUCT_DETSTATS, + help='construct detstats, using saved data') + parser.add_argument('--debug', action='store_true', default=False, + help='print steps along the way') + + # rarely need changing + parser.add_argument('--snr_cython', action='store_true', default=True, + help='Use cython for ss snr calculations') + parser.add_argument('--save_ssi', action='store_true', default=True, + help="Save 'gamma_ssi', the detprob of each single source.") + parser.add_argument('--clbrt', action='store_true', default=True, + help="Whether or not to calibrate the PTA for individual realizations.") + parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + help="gamma-rho interpolation grid path") + parser.add_argument('--anatomy_path', action='store', dest ='anatomy_path', type=str, default=ANATOMY_PATH, + help="path to load and save anatomy files") + + args = parser.parse_args() + return args + + + + + + + + + + + + + + + + +# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this +pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None) + +def vary_parameter( + target_param, # the name of the parameter, has to exist in `param_names` + params_list, # the values we'll check + nreals, nfreqs, nloudest, + pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None), + pars=None, save_dir=None, + ): + + # get the parameter names from this library-space + param_names = pspace.param_names + num_pars = len(pspace.param_names) + print(f"{num_pars=} :: {param_names=}") + + # choose each parameter to be half-way across the range provided by the library + if pars is None: + pars = 0.5 * np.ones(num_pars) + str_pars = str(pars).replace(" ", "_").replace("[", "").replace("]", "") + # Choose parameter to vary + param_idx = param_names.index(target_param) + + data = [] + params = [] + for ii, par in enumerate(params_list): + pars[param_idx] = par + print(f"{ii=}, {pars=}") + # _params = pspace.param_samples[0]*pars + _params = pspace.normalized_params(pars) + params.append(_params) + # construct `sam` and `hard` instances based on these parameters + sam, hard = pspace.model_for_params(_params, pspace.sam_shape) + if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM): + hard_name = 'Fixed Time' + elif isinstance(hard, holo.hardening.Hard_GW): + hard_name = 'GW Only' + # run this model, retrieving binary parameters and the GWB + _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=nloudest, + gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True) + data.append(_data) + if save_dir is not None: + str_shape = str(sam.shape).replace(", ", "_").replace("(", "").replace(")", "") + filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape) + np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param ) + print('saved to %s' % filename) + + return (data, params) \ No newline at end of file From b7044c720220bb725dd0efe0f184e4332384e09f Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 13:40:07 -0700 Subject: [PATCH 182/291] Fix script for clbrtd pta models --- .../parameter_investigation/anatomy.py | 2 +- .../detect_model_clbrt_pta.py | 145 +++++---- .../tk13_clbrted_lib.ipynb | 274 ++++++++++++++++++ .../tk14_one_source.ipynb | 172 +++++++++++ holodeck/detstats.py | 53 ++-- 5 files changed, 552 insertions(+), 94 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb create mode 100644 ecg-notebooks/parameter_investigation/tk14_one_source.ipynb diff --git a/ecg-notebooks/parameter_investigation/anatomy.py b/ecg-notebooks/parameter_investigation/anatomy.py index 063897ec..c2b28e50 100644 --- a/ecg-notebooks/parameter_investigation/anatomy.py +++ b/ecg-notebooks/parameter_investigation/anatomy.py @@ -24,7 +24,7 @@ def detect_pspace_model(data, dur=DUR, fobs_cents = data['fobs_cents'] hc_ss = data['hc_ss'] hc_bg = data['hc_bg'] - dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, dur, + dsdata = detstats.detect_pspace_model(fobs_cents, hc_ss, hc_bg, npsrs, sigma, nskies, thresh) return dsdata diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index b98c3721..138f0bdf 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -5,7 +5,7 @@ from datetime import datetime # sample -SHAPE = None +DEF_SHAPE = None DEF_NLOUDEST = 10 DEF_NREALS = 100 DEF_NFREQS = 40 @@ -25,55 +25,6 @@ CONSTRUCT_DETSTATS = False - -def main(): - start_time = datetime.now() - print("-----------------------------------------") - print(f"starting at {start_time}") - print("-----------------------------------------") - - load_data_from_file = args.anatomy_path+f'/{args.target}_{args.nvars}vars_clbrt_pta.npz' - save_data_to_file = args.anatomy_path+f'/{args.target}_{args.nvars}vars_clbrt_pta.npz' - - args = _setup_argparse() - print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" - % (args.nreals, args.nskies, args.npsrs, args.target)) - if args.construct or args.detstats: - if args.construct: - params_list = np.linsapce(0,1,args.nvars) - data, params, = vary_parameter(target_param=args.target, params_list=params_list, - nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest) - else: - file = np.load(load_data_from_file, allow_pickle=True) - print(file.files) - data = file['data'] - params = file['params'] - file.close() - dsdat = [] - for ii, _data in enumerate(data): - if args.debug: print(f"on var {ii=} out of {args.nvars}") - else: - print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") - - - - - - end_time = datetime.now() - print("-----------------------------------------") - print(f"ending at {end_time}") - print(f"total time: {end_time - start_time}") - print("-----------------------------------------") - -if __name__ == "__main__": - main() - - - - - - - def _setup_argparse(): parser = argparse.ArgumentParser() parser.add_argument('target', action='store', type=str, @@ -84,12 +35,14 @@ def _setup_argparse(): # sample models setup parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, help='number of frequency bins') - parser.add_argument('-f', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, + parser.add_argument('-r', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, help='number of strain realizations') parser.add_argument('-l', '--nloudest', action='store', dest='nloudest', type=int, default=DEF_NLOUDEST, help='number of loudest single sources') - parser.add_argument('-v', '--nvars', actions='store', dest='nvars', type=int, default=DEF_NVARS, + parser.add_argument('-v', '--nvars', action='store', dest='nvars', type=int, default=DEF_NVARS, help='number of variations on target param') + parser.add_argument('--shape', action='store', dest='shape', type=int, default=DEF_SHAPE, + help='sam shape') # parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, # help='pta duration in yrs') @@ -102,7 +55,7 @@ def _setup_argparse(): help='number of ss sky realizations') # pta calibration settings - parser.add_argument('--sigstart', action='store', dest='sigma', type=float, default=1e-7, + parser.add_argument('--sigstart', action='store', dest='sigstart', type=float, default=1e-7, help='starting sigma if for realization calibration') parser.add_argument('--sigmin', action='store', dest='sigmin', type=float, default=1e-10, help='sigma minimum for calibration') @@ -139,35 +92,21 @@ def _setup_argparse(): return args - - - - - - - - - - - - - - -# construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this -pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None) +# # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this +# pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None) def vary_parameter( target_param, # the name of the parameter, has to exist in `param_names` params_list, # the values we'll check nreals, nfreqs, nloudest, - pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None), - pars=None, save_dir=None, + pspace, + pars=None, save_dir=None, debug=True ): # get the parameter names from this library-space param_names = pspace.param_names num_pars = len(pspace.param_names) - print(f"{num_pars=} :: {param_names=}") + if debug: print(f"{num_pars=} :: {param_names=}") # choose each parameter to be half-way across the range provided by the library if pars is None: @@ -180,7 +119,7 @@ def vary_parameter( params = [] for ii, par in enumerate(params_list): pars[param_idx] = par - print(f"{ii=}, {pars=}") + if debug: print(f"{ii=}, {pars=}") # _params = pspace.param_samples[0]*pars _params = pspace.normalized_params(pars) params.append(_params) @@ -198,6 +137,62 @@ def vary_parameter( str_shape = str(sam.shape).replace(", ", "_").replace("(", "").replace(")", "") filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape) np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param ) - print('saved to %s' % filename) + if debug: print('saved to %s' % filename) + + return (data, params) + + + +def main(): + start_time = datetime.now() + print("-----------------------------------------") + print(f"starting at {start_time}") + print("-----------------------------------------") + + args = _setup_argparse() + print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" + % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) + + load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + + if args.construct or args.detstats: + if args.construct: + params_list = np.linspace(0,1,args.nvars) + data, params, = vary_parameter( + target_param=args.target, params_list=params_list, + nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, + pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=args.shape, seed=None),) + else: + file = np.load(load_data_from_file, allow_pickle=True) + print('loaded files:', file.files) + data = file['data'] + params = file['params'] + file.close() + + fobs_cents = data[0]['fobs_cents'] + + # get dsdat for each data/param + dsdat = [] + for ii, _data in enumerate(data): + if args.debug: print(f"on var {ii=} out of {args.nvars}") + hc_bg = _data['hc_bg'] + hc_ss = _data['hc_ss'] + _dsdat = detstats.detect_pspace_model_clbrt_pta( + fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, + sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, + thresh=args.thresh, debug=args.debug) + dsdat.append(_dsdat) + np.savez(save_data_to_file, data=data, dsdat=dsdat,params=params) + else: + print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") + + end_time = datetime.now() + print("-----------------------------------------") + print(f"ending at {end_time}") + print(f"total time: {end_time - start_time}") + print("-----------------------------------------") + +if __name__ == "__main__": + main() - return (data, params) \ No newline at end of file diff --git a/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb b/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb new file mode 100644 index 00000000..6fe6b2aa --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb @@ -0,0 +1,274 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", + "\n", + "print(hdf.keys())\n", + "sample_params = hdf['sample_params'][...]\n", + "hc_ss = hdf['hc_ss'][...]\n", + "hc_bg = hdf['hc_bg'][...]\n", + "sspar = hdf['sspar'][...]\n", + "bgpar = hdf['bgpar'][...]\n", + "fobs_gw_cents = hdf['fobs'][:]\n", + "hdf.close()\n", + "\n", + "dur = 1/fobs_gw_cents[0]\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", + "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", + "print(npz.files)\n", + "param_names = npz['param_names']\n", + "print(param_names)\n", + "print(npz['class_name'])\n", + "lib_name = '%s v%s, %d samples' % (npz['class_name'], npz['librarian_version'], nsamps)\n", + "print(lib_name)\n", + "# print(npz['sam_shape'])\n", + "npz.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load detstats" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10/detstats/clbrt_psrs40/detstats_lib.npz')\n", + "print(npz.files)\n", + "# print(npz['snr_ss'].shape)\n", + "dp_ss = npz['dp_ss']\n", + "dp_bg = npz['dp_bg']\n", + "df_ss = npz['df_ss']\n", + "df_bg = npz['df_bg']\n", + "ev_ss = npz['ev_ss']\n", + "nskies = dp_ss.shape[-1]\n", + "print(f\"{ev_ss.shape=}, {dp_ss.shape=}\")\n", + "npz.close()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Make plot shapes (N,R,S)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ratio = dp_ss/dp_bg[:,:,np.newaxis]\n", + "print(f\"{ratio.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "thard = np.repeat(sample_params[:,0], nreals*nskies).reshape(nsamps, nreals, nskies)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='hard_time', ylabel='ev_ss/dp_bg')\n", + "ax.scatter(thard, ratio, s=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mchar = sample_params[:,2]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def normalize(xx, log=True, diverging=False, center=None):\n", + " xmin = np.min(xx)\n", + " xmax = np.max(xx)\n", + " if log:\n", + " xmin = np.log10(xmin)\n", + " xmax = np.log10(xmax)\n", + " print(f\"{xmin=}, {xmax=}\")\n", + " if diverging:\n", + " norm = mpl.colors.TwoSlopeNorm(vmin=xmin, vmax=xmax, center=center)\n", + " else:\n", + " norm = mpl.colors.Normalize(vmin=xmin, vmax=xmax)\n", + " return norm\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "mchar = np.repeat(sample_params[:,2], nreals*nskies)\n", + "thard = np.repeat(sample_params[:,0], nreals*nskies)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cmap='PiYG'\n", + "def scatter_with_color(xx, yy, cc, norm, xlabel=None, ylabel=None, clabel=None,\n", + " xscale='log', yscale='log', ccent=0, cmap='PiYG'):\n", + " fig, ax = plot.figax(xlabel=xlabel, ylabel=ylabel, yscale=yscale, xscale=xscale)\n", + " sax = ax.scatter(xx.flatten(), yy.flatten(), c=cc.flatten(), cmap=cmap, norm=norm)\n", + " cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + " return fig\n", + "# create the colorbar\n", + "# # Create the colorbar\n", + "# smap = plt.cm.ScalarMappable(cmap='PiYG', norm=norm)\n", + "# cbar = fig.colorbar(smap, ax=ax, fraction=0.1, shrink = 0.8)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = thard\n", + "yy = mchar\n", + "cc = np.log10(ratio.flatten())\n", + "xlabel = 'hard_time'\n", + "ylabel = 'GSMF mchar0 log10'\n", + "clabel = 'SS/BG Detprob'\n", + "yscale='linear'\n", + "xscale='log'\n", + "norm = normalize(cc, center=0)\n", + "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", + "\n", + "fig = scatter_with_color(\n", + " xx, yy, cc, norm, xlabel, ylabel, clabel, \n", + " xscale=xscale, yscale=yscale, ccent=0, cmap='PiYG')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = thard\n", + "yy = np.repeat(sample_params[:,1], nreals*nskies)\n", + "cc = np.log10(ratio.flatten())\n", + "xlabel = 'hard_time'\n", + "ylabel = 'GSMF Phi0'\n", + "clabel = 'SS/BG Detprob'\n", + "yscale='linear'\n", + "xscale='log'\n", + "norm = normalize(cc, center=0)\n", + "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", + "\n", + "fig = scatter_with_color(\n", + " xx, yy, cc, norm, xlabel, ylabel, clabel, \n", + " xscale=xscale, yscale=yscale, ccent=0, cmap='PiYG')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb b/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb new file mode 100644 index 00000000..f8522bac --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb @@ -0,0 +1,172 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "import tqdm\n", + "import os\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "NVARS = 21\n", + "SAVEFIG = True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "# print(save_data_to_file)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load Data from File" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "dsdat = file['dsdat']\n", + "file.close()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Shapes, Edges, Frequency Info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nfreqs, nreals, nloudest = [*data[0]['hc_ss'].shape]\n", + "fobs_cents = data[0]['fobs_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# mass edges\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mm_edges = sam.mtot/MSOL\n", + "\n", + "# frequency bin edges\n", + "ff_edges = data[0]['fobs_edges']/10**9\n", + "\n", + "# get frequencies\n", + "ssfrq = np.repeat(fobs_cents, nreals*nloudest)/10**9 # nHz\n", + "bgfrq = np.repeat(fobs_cents, nreals)/10**9 # nHz" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot characteristic strain vs frequency with individual source gamma_ssi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(str(None))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 70b4234d..8e1e4b50 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2205,9 +2205,9 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, return dsdata -def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, - npsrs, nskies, maxtrials=1, - thresh=DEF_THRESH, debug=False, maxbads=20, tol=0.03): +def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, + sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, + thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True): """ Detect pspace model using individual sigma calibration for each realization """ @@ -2215,8 +2215,6 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, cad = 1.0/(2*fobs_cents[-1]) nfreqs, nreals, nloudest = [*hc_ss.shape] - if debug: print(f"{[*hc_ss.shape]=}") - if debug: print(f"{nskies=}") # form arrays for individual realization detstats dp_ss = np.zeros((nreals, nskies)) @@ -2225,20 +2223,34 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, snr_bg = np.zeros((nreals)) gamma_ssi = np.zeros((nfreqs, nreals, nskies, nloudest)) + # for each realization, + # use sigmin and sigmax from previous realization, + # unless it's the first realization of the sample + _sigstart, _sigmin, _sigmax = sigstart, sigmin, sigmax + if debug: + mod_start = datetime.now() + real_dur = datetime.now() for rr in range(nreals): - if debug: print(f"{rr=}") - # get calibrated psrs - psrs = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, - sigmin=1e-9, sigmax=1e-4, debug=debug, maxbads=maxbads, tol=tol) - - # use those psrs to calculate realization detstats - _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) - dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() - _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( - psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True) - if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") - dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() + if debug: + now = datetime.now() + if (rr%10==0): + print(f"{rr=}, {now-real_dur} s per realization, {_sigmin=:.2e}, {_sigmax=:.2e}, {_sigstart=:.2e}") + real_dur = now + + # get calibrated psrs + psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, tol=tol, maxbads=maxbads, + sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True) + _sigmin /= 2 + _sigmax *= 2 + + # use those psrs to calculate realization detstats + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) + dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() + _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True) + # if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") + dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() ev_ss = expval_of_ss(gamma_ssi) df_ss, df_bg = detfrac_of_reals(dp_ss, dp_bg) @@ -2247,6 +2259,11 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, 'dp_bg':dp_bg, 'snr_bg':snr_bg, 'df_ss':df_ss, 'df_bg':df_bg, 'ev_ss':ev_ss, } + if save_gamma_ssi: + _dsdat.update(gamma_ssi=gamma_ssi) + if save_snr_ss: + _dsdat.update(snr_ss=snr_ss) + print(f"Model took {datetime.now() - mod_start} s") return _dsdat @@ -2380,7 +2397,7 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, def calibrate_one_pta(hc_bg, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None, ret_sig = False): + phis=None, thetas=None, ret_sig = False,): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters From baf68e54fb4467388e4253da70c98d97fe5c198a Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 17:57:16 -0700 Subject: [PATCH 183/291] Mess with plotting individual DPs, set aside for now. --- .../tk14_one_source.ipynb | 61 +++++++++++++------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb b/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb index f8522bac..d2b613ce 100644 --- a/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb +++ b/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb @@ -41,7 +41,10 @@ "TARGET = 'hard_time' # EDIT AS NEEDED\n", "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", "NVARS = 21\n", - "SAVEFIG = True" + "NREALS=100\n", + "NSKIES=100\n", + "SAVEFIG = True\n", + "SHAPE=None" ] }, { @@ -50,8 +53,8 @@ "metadata": {}, "outputs": [], "source": [ - "path = '/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation/anatomy_09B'\n", - "load_data_from_file = path+f'/{TARGET}_{NVARS}vars_clbrt_pta.npz' \n", + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", "\n", "if os.path.exists(load_data_from_file) is False:\n", " err = 'load data file does not exist, you need to construct it.'\n", @@ -75,10 +78,12 @@ "source": [ "file = np.load(load_data_from_file, allow_pickle=True)\n", "print(file.files)\n", - "data = file['data']\n", - "params = file['params']\n", - "dsdat = file['dsdat']\n", - "file.close()" + "nn=10\n", + "\n", + "data = file['data'][nn]\n", + "params = file['params'][nn]\n", + "dsdat = file['dsdat'][nn]\n", + "file.close()\n" ] }, { @@ -94,8 +99,9 @@ "metadata": {}, "outputs": [], "source": [ - "nfreqs, nreals, nloudest = [*data[0]['hc_ss'].shape]\n", - "fobs_cents = data[0]['fobs_cents']" + "nfreqs, nreals, nloudest = [*data['hc_ss'].shape]\n", + "nskies = dsdat['dp_ss'].shape[-1]\n", + "fobs_cents = data['fobs_cents']" ] }, { @@ -105,15 +111,11 @@ "outputs": [], "source": [ "# mass edges\n", - "sam = holo.sams.Semi_Analytic_Model()\n", - "mm_edges = sam.mtot/MSOL\n", + "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE)\n", + "# mm_edges = sam.mtot/MSOL\n", "\n", "# frequency bin edges\n", - "ff_edges = data[0]['fobs_edges']/10**9\n", - "\n", - "# get frequencies\n", - "ssfrq = np.repeat(fobs_cents, nreals*nloudest)/10**9 # nHz\n", - "bgfrq = np.repeat(fobs_cents, nreals)/10**9 # nHz" + "# ff_edges = data['fobs_edges']/10**9" ] }, { @@ -129,7 +131,32 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "xx = data['fobs_cents']\n", + "\n", + "x1 = np.repeat(xx, nreals*)\n", + "y1 = np.repeat(data['hc_ss'], nskies).reshape(nfreqs, nreals, nskies, nloudest)\n", + "c1 = dsdat['gamma_ssi']\n", + "print(f\"{y1.shape=}, {c1.shape=}\")\n", + "\n", + "\n", + "y2 = data['hc_bg']\n", + "c2 = dsdat['dp_bg']\n", + "print(f\"{y2.shape=}, {c2.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='Frequency (1/yr)',\n", + " ylabel='Characteristic Strain')\n", + "plot.draw_med_conf(ax, xx, y2)\n", + "\n", + "sax = ax.scatter()" + ] }, { "cell_type": "code", From 9f9d9fc324f58ee8e796cfe982ec4594156d83f1 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 18:01:40 -0700 Subject: [PATCH 184/291] Save data before detstats, in case of crash. --- .../parameter_investigation/detect_model_clbrt_pta.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 138f0bdf..7f83e3b8 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -163,6 +163,7 @@ def main(): target_param=args.target, params_list=params_list, nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=args.shape, seed=None),) + np.savez(save_data_to_file, data=data, params=params) # save before calculating detstats, in case of crash else: file = np.load(load_data_from_file, allow_pickle=True) print('loaded files:', file.files) @@ -183,7 +184,7 @@ def main(): sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, thresh=args.thresh, debug=args.debug) dsdat.append(_dsdat) - np.savez(save_data_to_file, data=data, dsdat=dsdat,params=params) + np.savez(save_data_to_file, data=data, dsdat=dsdat,params=params) # overwrite else: print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") From 503af69ef48c238e8a0493d377a17ed662e6391e Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 20:16:28 -0700 Subject: [PATCH 185/291] Add option for specifying load or save files. --- .../detect_model_clbrt_pta.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 7f83e3b8..229cac67 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -21,8 +21,8 @@ ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' # settings to vary -CONSTRUCT_ALL = False -CONSTRUCT_DETSTATS = False +DEF_CONSTRUCT = False +DEF_DETSTATS = False def _setup_argparse(): @@ -69,9 +69,9 @@ def _setup_argparse(): help='number of bad sigmas to try before expanding the search range') # general settings - parser.add_argument('--construct', action='store_true', default=CONSTRUCT_ALL, + parser.add_argument('--construct', action='store_true', default=DEF_CONSTRUCT, help='construct data and detstats for each varying param') - parser.add_argument('--detstats', action='store_true', default=CONSTRUCT_DETSTATS, + parser.add_argument('--detstats', action='store_true', default=DEF_DETSTATS, help='construct detstats, using saved data') parser.add_argument('--debug', action='store_true', default=False, help='print steps along the way') @@ -87,6 +87,10 @@ def _setup_argparse(): help="gamma-rho interpolation grid path") parser.add_argument('--anatomy_path', action='store', dest ='anatomy_path', type=str, default=ANATOMY_PATH, help="path to load and save anatomy files") + parser.add_argument('--load_file', action='store', dest ='load_file', type=str, default=None, + help="file to load sample data and params") + parser.add_argument('--save_file', action='store', dest ='save_file', type=str, default=None, + help="file to save sample data, params, and detstats") args = parser.parse_args() return args @@ -153,8 +157,14 @@ def main(): print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) - load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' - save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + if args.load_file is None: + load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + else: + load_data_from_file = args.load_file + if args.save_file is None: + save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + else: + save_data_to_file = args.save_file if args.construct or args.detstats: if args.construct: From 4a1a0358e52073317198a0b678a0a3e9be7d5555 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 20:19:02 -0700 Subject: [PATCH 186/291] Plot smoothe Mchar0 with and without scatter points. --- .../fullsize_hard_time.ipynb | 457 ++++++++++++++++++ 1 file changed, 457 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb new file mode 100644 index 00000000..605e6784 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb @@ -0,0 +1,457 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 100\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# TARGET = 'hard_time' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "\n", + "\n", + "TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get Param Names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "dsdat = file['dsdat']\n", + "file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "if SAVEFIG: \n", + " param_path = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + " fig1.savefig(param_path+f'/ss_vs_bg_{TARGET}_{NVARS}vars_clbrtd.png')\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(dsdat[0]['dp_bg'].shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Normalize with individual gamma ssi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{dsdat[0]['gamma_ssi'].shape=}\")\n", + "print(f\"{dsdat[0]['ev_ss'].shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(dat['sspar'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cc = np.zeros((NVARS, NREALS, NSKIES))\n", + "for ii, dat in enumerate(data):\n", + " for rr in range(NREALS):\n", + " for ss in range(NSKIES):\n", + " argmax = np.argmax(dsdat[ii]['gamma_ssi'][:,rr,ss,:])\n", + " fidx, lidx = np.unravel_index(argmax, shape=(NFREQS, NLOUDEST))\n", + " cc[ii,rr,ss] = np.log10(dat['sspar'][0,fidx,rr,lidx]/MSOL)\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(cc), vmax=np.max(cc))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(xx[:,0,0].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "clabel = '$\\log M / [\\mathrm{M}_\\odot] $)'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = np.repeat(dsdat[ii]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[ii]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + " # for rr in range(len(yy[0])):\n", + "\n", + "x1= np.array(xx)\n", + "yy = np.array(yy)\n", + "\n", + "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", + "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", + "# sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", + "# cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "\n", + "\n", + "print(f\"{xx.shape=}, {yy.shape=}\")\n", + "\n", + "col = 'tab:blue'\n", + "for pp in [50, 95]:\n", + " med, *conf = np.percentile(yy, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(x1, med, alpha=0.5, color=col)\n", + " ax.fill_between(x1, *conf, color=col, alpha=0.25)\n", + "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "# fig.tight_layout()\n", + "\n", + "# figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "# if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From f86c1213cbff5d7471a53f02babf7f9db4cd91f5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 21:31:29 -0700 Subject: [PATCH 187/291] Plot 500s 100r hard_time --- .../fullsize_hard_time.ipynb | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb index 605e6784..3ccbd648 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb @@ -45,13 +45,13 @@ "NVARS = 21\n", "\n", "NPSRS = 40\n", - "NSKIES = 100\n", - "# TARGET = 'hard_time' # EDIT AS NEEDED\n", - "# TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "NSKIES = 500\n", + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", "\n", "\n", - "TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", - "TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" ] }, { @@ -361,15 +361,6 @@ "# Plot with mass colorbar" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(xx[:,0,0].shape)" - ] - }, { "cell_type": "code", "execution_count": null, From 1aa6f20d09fdd91656de2e664589fffed5a62090 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 26 Jun 2023 21:31:44 -0700 Subject: [PATCH 188/291] Plot strain vs freq of midsample --- .../parameter_investigation/tk14_one_source.ipynb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb b/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb index d2b613ce..1c6771ea 100644 --- a/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb +++ b/ecg-notebooks/parameter_investigation/tk14_one_source.ipynb @@ -151,11 +151,10 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = plot.figax(xlabel='Frequency (1/yr)',\n", - " ylabel='Characteristic Strain')\n", - "plot.draw_med_conf(ax, xx, y2)\n", - "\n", - "sax = ax.scatter()" + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR,\n", + " ylabel=plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "# plot.draw_med_conf(ax, xx, y2)\n", + "plot.draw_ss_and_gwb(ax, fobs_cents*YR, data['hc_ss'], data['hc_bg'])" ] }, { From f26b3675be5e2ca6ec9a73eaf916325aae216e7b Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 01:34:12 -0700 Subject: [PATCH 189/291] Plot 500 realization detprob vs hard time --- .../fullsize_hard_time.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb index 3ccbd648..480e91af 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb @@ -32,7 +32,7 @@ "outputs": [], "source": [ "SHAPE = None\n", - "NREALS = 100\n", + "NREALS = 500\n", "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", @@ -45,9 +45,9 @@ "NVARS = 21\n", "\n", "NPSRS = 40\n", - "NSKIES = 500\n", + "NSKIES = 100\n", "TARGET = 'hard_time' # EDIT AS NEEDED\n", - "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", "\n", "\n", "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", From ce6685711aa4e6701a9353d755e5795ac9a586b0 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 01:49:23 -0700 Subject: [PATCH 190/291] Plot detprob of individual loudest single sources vs frequency --- .../parameter_investigation/tk15_dp_ssi.ipynb | 287 ++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb new file mode 100644 index 00000000..d1ea00be --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb @@ -0,0 +1,287 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "\n", + "\n", + "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Load Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "dsdat = file['dsdat']\n", + "file.close()\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Parameter Space" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dat = data[0]\n", + "gamma_ssi = dsdat[0]['gamma_ssi'] # F,R,S,L\n", + "fobs_cents = data[0]['fobs_cents'] # F" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Scatter of All" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# xlabel = plot.LABEL_GW_FREQUENCY_YR\n", + "# ylabel = 'Individual Single Source Detection Probability, $\\gamma_\\mathrm{ssi}$'\n", + "\n", + "# fig, ax = plot.figax(xlabel=xlabel, ylabel=ylabel)\n", + "# colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "# alpha=0.1\n", + "\n", + "# for ii, dat in enumerate(data):\n", + "# xx = np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", + "# yy = dsdat[ii]['gamma_ssi'] # (F,S,R,L)\n", + "# ax.scatter(xx[:,:,:,0], yy[:,:,:,0], color=colors[ii], edgecolor='k', alpha=alpha)\n", + "# ax.scatter(xx[:,:,:,1:], yy[:,:,:,1:], color=colors[ii], alpha=alpha)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Just The Single Loudest" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "param_names.index(TARGET)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(params[0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel = plot.LABEL_GW_FREQUENCY_YR\n", + "ylabel = 'Detection Probability, $\\gamma_\\mathrm{ss,i}$'\n", + "\n", + "fig, ax = plot.figax(xlabel=xlabel, ylabel=ylabel)\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "alpha=0.1\n", + "\n", + "# tt = param_names.index(TARGET)\n", + "\n", + "handles = []\n", + "labels = []\n", + "for ii, dat in enumerate(data):\n", + " if ii%2==0:\n", + " print(ii)\n", + " xx = fobs_cents # F, #np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", + " yy = dsdat[ii]['gamma_ssi'][...,0] # (F,S,R)\n", + " yy = yy.reshape(NFREQS, NSKIES * NREALS)\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, color=colors[ii],)\n", + " handles.append(hh)\n", + " labels.append(f\"{params[ii][TARGET]:.2f}\")\n", + " # ax.scatter(xx[:,:,:,0], yy[:,:,:,0], color=colors[ii], edgecolor='k', alpha=0.1)\n", + " # ax.scatter(xx[:,:,:,1:], yy[:,:,:,1:], color=colors[ii], alpha=0.1)\n", + "\n", + "ax.legend(handles=handles, labels=labels, title=TARGET)\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/anatomy_09B'\n", + " +f'/dp_vs_freq_{TARGET}_r{NREALS}_s{NSKIES}.png')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel = plot.LABEL_GW_FREQUENCY_YR\n", + "ylabel = 'Detection Probability, $\\gamma_\\mathrm{ss,i}$'\n", + "\n", + "fig, ax = plot.figax(xlabel=xlabel, ylabel=ylabel)\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "alpha=0.1\n", + "\n", + "# tt = param_names.index(TARGET)\n", + "\n", + "handles = []\n", + "labels = []\n", + "for ii, dat in enumerate(data):\n", + " if ii%2==0:\n", + " print(ii)\n", + " xx = fobs_cents # F, #np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", + " yy = dsdat[ii]['gamma_ssi'][...,0] # (F,S,R)\n", + " # yy = yy.reshape(NFREQS, NSKIES * NREALS)\n", + " yy = yy[:,0,:]\n", + " hh = plot.draw_med_conf_color(ax, xx, yy, color=colors[ii],)\n", + " handles.append(hh)\n", + " labels.append(f\"{params[ii][TARGET]:.2f}\")\n", + " # ax.scatter(xx[:,:,:,0], yy[:,:,:,0], color=colors[ii], edgecolor='k', alpha=0.1)\n", + " # ax.scatter(xx[:,:,:,1:], yy[:,:,:,1:], color=colors[ii], alpha=0.1)\n", + "\n", + "ax.legend(handles=handles, labels=labels, title=TARGET)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "arr = np.array([[1,2],[3,4]], [[5,5],[5,5,]], [[6,6],[6,6]])\n", + "print(arr.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From d3e04293f4bffa8c07553e48eb2270b3337c90f6 Mon Sep 17 00:00:00 2001 From: emiko Date: Tue, 27 Jun 2023 10:13:27 -0700 Subject: [PATCH 191/291] Separate data/param and detstats file saving --- .../detect_model_clbrt_pta.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 229cac67..9d93495e 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -88,9 +88,9 @@ def _setup_argparse(): parser.add_argument('--anatomy_path', action='store', dest ='anatomy_path', type=str, default=ANATOMY_PATH, help="path to load and save anatomy files") parser.add_argument('--load_file', action='store', dest ='load_file', type=str, default=None, - help="file to load sample data and params") + help="file to load sample data and params, excluding .npz suffice") parser.add_argument('--save_file', action='store', dest ='save_file', type=str, default=None, - help="file to save sample data, params, and detstats") + help="file to save sample data, excluding .npz suffix") args = parser.parse_args() return args @@ -160,11 +160,13 @@ def main(): if args.load_file is None: load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' else: - load_data_from_file = args.load_file + load_data_from_file = args.load_file+'.npz' if args.save_file is None: save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds.npz' else: - save_data_to_file = args.save_file + save_data_to_file = args.save_file+'.npz' + save_dets_to_file = args.save_file+'_ds.npz' if args.construct or args.detstats: if args.construct: @@ -194,7 +196,7 @@ def main(): sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, thresh=args.thresh, debug=args.debug) dsdat.append(_dsdat) - np.savez(save_data_to_file, data=data, dsdat=dsdat,params=params) # overwrite + np.savez(save_dets_to_file, dsdat=dsdat) # overwrite else: print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") From d9a495c9e67694a39f24d481781b6daf388f8fba Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 13:24:17 -0700 Subject: [PATCH 192/291] Look at noise spectral density, SNR, etc. --- .../ds10_dpvsfreq_troubleshooting.ipynb | 335 ++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb diff --git a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb new file mode 100644 index 00000000..fa439056 --- /dev/null +++ b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb @@ -0,0 +1,335 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "from holodeck import plot, detstats, utils\n", + "from holodeck.constants import YR, MSOL, MPC, GYR\n", + "import holodeck as holo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents, fobs_edges = utils.pta_freqs()\n", + "sam = holo.sams.Semi_Analytic_Model() \n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get Strain Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NLOUDEST = 10\n", + "NREALS = 30" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(fobs_gw_edges=fobs_edges, realize=NREALS, \n", + " loudest=NLOUDEST, params=True)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Psrs Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NSKIES = 25\n", + "NPSRS = 10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# for the 0th realization\n", + "psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True)\n", + "print(f\"{sigmin=}, {sigmax=}, {sigma=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Noise Spectral Density\n", + "Noise from all but one source" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Sh_rest = detstats._Sh_rest_noise(hc_ss, hc_bg, fobs_cents)\n", + "print(f\"{Sh_rest.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = fobs_cents * YR\n", + "y1 = Sh_rest[:,:,0]\n", + "label1 = 'S_h,rest (all but 1st loudest)'\n", + "\n", + "y2 = Sh_rest[:,:,9]\n", + "label2 = 'S_h,rest (all but 10th loudest)'\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Power Spectral Density (Hz$^{-1}$)')\n", + "h1 = plot.draw_med_conf(ax, xx, y1)\n", + "h2 = plot.draw_med_conf(ax, xx, y2)\n", + "ax.legend(handles=[h1, h2], labels=[label1, label2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Sh_rest = hc^2 / (12 pi^2 freqs^3)\n", + "\n", + "# power spectral density of single loudest source\n", + "\n", + "l1 = detstats._power_spectral_density(hc_ss[:,:,0], fobs_cents)\n", + "l2 = detstats._power_spectral_density(hc_ss[:,:,9], fobs_cents)\n", + "label3 = '1st loudest'\n", + "label4 = '10th loudest'\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Power Spectral Density')\n", + "h1 = plot.draw_med_conf(ax, xx, y1)\n", + "h2 = plot.draw_med_conf(ax, xx, y2)\n", + "c1 = h1[0].get_color()\n", + "c2 = h2[0].get_color()\n", + "ax.legend(handles=[h1, h2], labels=[label1, label2])\n", + "for rr in range(NREALS):\n", + " h3 = ax.scatter(xx, l1[:,rr], ec=c1, fc=None, alpha=0.1)\n", + " h4 = ax.scatter(xx, l2[:,rr], ec=c2, fc=None, alpha=0.1)\n", + "\n", + "ax.legend(handles=[h1, h2, h3, h4], labels=[label1, label2, label3, label4])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dur = 1.0/fobs_cents[0]\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "sigmas = np.ones(NPSRS)*sigma\n", + "\n", + "rr=0\n", + "\n", + "y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents)[0,:,:,0]\n", + "y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", + "y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + "label1 = 'total noise'\n", + "label2 = 'hc-rest noise'\n", + "label3 = 'white noise'\n", + "# label4 = '10th loudest'\n", + "print(f\"{y1.shape=}, {y2.shape=}, {y3.shape=}\")\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel='Noise Spectral Density (Hz$^{-3}$)')\n", + "h1 = plot.draw_med_conf(ax, xx, y1)\n", + "h2 = plot.draw_med_conf(ax, xx, y2)\n", + "h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", + "# c1 = h1[0].get_color()\n", + "# c2 = h2[0].get_color()\n", + "# ax.legend(handles=[h1, h2], labels=[label1, label2])\n", + "# for rr in range(NREALS):\n", + "# h3 = ax.scatter(xx, l1[:,rr], ec=c1, fc=None, alpha=0.1)\n", + "# h4 = ax.scatter(xx, l2[:,rr], ec=c2, fc=None, alpha=0.1)\n", + "\n", + "ax.legend(handles=[h1, h2, h3,], labels=[label1, label2, label3,])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(l3)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Total noise (Sh_rest + white noise)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## SNR_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Detection Probability" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", + " nskies=NSKIES, ret_snr=True)\n", + "dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True)\n", + "\n", + "print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", + "\n", + "xx = fobs_cents*YR\n", + "y1 = dp_bg[0] # 1\n", + "y2 = gamma_ssi[:,0,:,0] # F, S\n", + "y3 = dp_ss[0] # S\n", + "label1 = 'BG Detprob'\n", + "label2 = '1st Loudest Detprob, for each sky realization'\n", + "label3 = 'Overall SS Detprob, for each sky realization'\n", + "\n", + "h1 = ax.axhline(y1)\n", + "h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + "for ss in range(NSKIES):\n", + " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + "\n", + "ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SNR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='SNR')\n", + "\n", + "xx = fobs_cents*YR\n", + "y1 = snr_bg[0] # F,\n", + "y2 = snr_ss[:,0,:,0] # F, S\n", + "# y3 = dp_ss[0] # S\n", + "label1 = 'BG SNR'\n", + "label2 = '1st Loudest SNR, for each sky realization'\n", + "\n", + "h1 = ax.axhline(y1)\n", + "h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + "# for ss in range(NSKIES):\n", + "# h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + "\n", + "ax.legend(handles=[h1,h2,], labels=[label1, label2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From e47e348330052830dfc7007411abbdc7aed20dd5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 16:35:12 -0700 Subject: [PATCH 193/291] Plot mmb_scatter_dex ratio vs var --- .../fullsize_hard_time.ipynb | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb index 480e91af..54fe4edc 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb @@ -46,9 +46,12 @@ "\n", "NPSRS = 40\n", "NSKIES = 100\n", - "TARGET = 'hard_time' # EDIT AS NEEDED\n", - "TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", "\n", + "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'hard_time' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", "\n", "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" @@ -62,6 +65,7 @@ "source": [ "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "load_dets_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds.npz' \n", "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", "\n", "if CONSTRUCT is False:\n", @@ -109,7 +113,12 @@ "print(file.files)\n", "data = file['data']\n", "params = file['params']\n", + "file.close()\n", + "\n", + "file = np.load(load_dets_from_file, allow_pickle=True)\n", + "print(file.files)\n", "dsdat = file['dsdat']\n", + "\n", "file.close()\n" ] }, @@ -392,8 +401,8 @@ "\n", "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", - "# sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", - "# cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", + "cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", "\n", "\n", "print(f\"{xx.shape=}, {yy.shape=}\")\n", From fcce59ebb6a09bd2cd62306aa503601d8bdfbb32 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 16:35:43 -0700 Subject: [PATCH 194/291] Look at DP vs freq, and power vs freq --- .../ds11_dpvsfreq_pspacemodel.ipynb | 359 ++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb diff --git a/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb b/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb new file mode 100644 index 00000000..dae99e1e --- /dev/null +++ b/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb @@ -0,0 +1,359 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "\n", + "from holodeck import plot, detstats, utils\n", + "from holodeck.constants import YR, MSOL, MPC, GYR\n", + "import holodeck as holo" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get Strain Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", + "\n", + "\n", + "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", + "\n", + "if CONSTRUCT is False:\n", + " import os\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "print(load_data_from_file)\n", + "# print(save_data_to_file)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data'][-1] # longest hardening time = lowest BG DP\n", + "params = file['params'][-1]\n", + "# dsdat = file['dsdat'][-1]\n", + "file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_bg = data['hc_bg']\n", + "hc_ss = data['hc_ss']\n", + "fobs_cents = data['fobs_cents']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Psrs Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# for the 0th realization\n", + "psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True)\n", + "print(f\"{sigmin=}, {sigmax=}, {sigma=}\")" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Noise Spectral Density\n", + "Noise from all but one source" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "Sh_rest = detstats._Sh_rest_noise(hc_ss, hc_bg, fobs_cents)\n", + "print(f\"{Sh_rest.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = fobs_cents * YR\n", + "y1 = Sh_rest[:,:,0]\n", + "label1 = 'S_h,rest (all but 1st loudest)'\n", + "\n", + "y2 = Sh_rest[:,:,9]\n", + "label2 = 'S_h,rest (all but 10th loudest)'\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Power Spectral Density (Hz$^{-1}$)')\n", + "h1 = plot.draw_med_conf(ax, xx, y1)\n", + "h2 = plot.draw_med_conf(ax, xx, y2)\n", + "ax.legend(handles=[h1, h2], labels=[label1, label2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Sh_rest = hc^2 / (12 pi^2 freqs^3)\n", + "\n", + "# power spectral density of single loudest source\n", + "\n", + "l1 = detstats._power_spectral_density(hc_ss[:,:,0], fobs_cents)\n", + "l2 = detstats._power_spectral_density(hc_ss[:,:,9], fobs_cents)\n", + "label3 = '1st loudest'\n", + "label4 = '10th loudest'\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Power Spectral Density')\n", + "h1 = plot.draw_med_conf(ax, xx, y1)\n", + "h2 = plot.draw_med_conf(ax, xx, y2)\n", + "c1 = h1[0].get_color()\n", + "c2 = h2[0].get_color()\n", + "ax.legend(handles=[h1, h2], labels=[label1, label2])\n", + "for rr in range(NREALS):\n", + " h3 = ax.scatter(xx, l1[:,rr], ec=c1, fc=None, alpha=0.1)\n", + " h4 = ax.scatter(xx, l2[:,rr], ec=c2, fc=None, alpha=0.1)\n", + "\n", + "ax.legend(handles=[h1, h2, h3, h4], labels=[label1, label2, label3, label4])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dur = 1.0/fobs_cents[0]\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "sigmas = np.ones(NPSRS)*sigma\n", + "\n", + "rr=0\n", + "\n", + "y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents)[0,:,:,0]\n", + "y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", + "y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + "label1 = 'total noise'\n", + "label2 = 'hc-rest noise'\n", + "label3 = 'white noise'\n", + "# label4 = '10th loudest'\n", + "print(f\"{y1.shape=}, {y2.shape=}, {y3.shape=}\")\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel='Noise Spectral Density (Hz$^{-3}$)')\n", + "h1 = plot.draw_med_conf(ax, xx, y1)\n", + "h2 = plot.draw_med_conf(ax, xx, y2)\n", + "h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", + "# c1 = h1[0].get_color()\n", + "# c2 = h2[0].get_color()\n", + "# ax.legend(handles=[h1, h2], labels=[label1, label2])\n", + "# for rr in range(NREALS):\n", + "# h3 = ax.scatter(xx, l1[:,rr], ec=c1, fc=None, alpha=0.1)\n", + "# h4 = ax.scatter(xx, l2[:,rr], ec=c2, fc=None, alpha=0.1)\n", + "\n", + "ax.legend(handles=[h1, h2, h3,], labels=[label1, label2, label3,])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Total noise (Sh_rest + white noise)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## SNR_ss" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Detection Probability" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", + " nskies=NSKIES, ret_snr=True)\n", + "dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True)\n", + "\n", + "print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", + "\n", + "xx = fobs_cents*YR\n", + "y1 = dp_bg[0] # 1\n", + "y2 = gamma_ssi[:,0,:,0] # F, S\n", + "y3 = dp_ss[0] # S\n", + "label1 = 'BG Detprob'\n", + "label2 = '1st Loudest Detprob, for each sky realization'\n", + "label3 = 'Overall SS Detprob, for each sky realization'\n", + "\n", + "h1 = ax.axhline(y1)\n", + "h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + "for ss in range(NSKIES):\n", + " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + "\n", + "ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SNR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='SNR')\n", + "\n", + "xx = fobs_cents*YR\n", + "y1 = snr_bg[0] # F,\n", + "y2 = snr_ss[:,0,:,0] # F, S\n", + "# y3 = dp_ss[0] # S\n", + "label1 = 'BG SNR'\n", + "label2 = '1st Loudest SNR, for each sky realization'\n", + "\n", + "h1 = ax.axhline(y1)\n", + "h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + "# for ss in range(NSKIES):\n", + "# h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + "\n", + "ax.legend(handles=[h1,h2,], labels=[label1, label2])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 54118ea0b52dd01186b03059d6d9e851cbdfcb89 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 19:12:39 -0700 Subject: [PATCH 195/291] Add red noise to bg detstats --- .../ds11_dpvsfreq_pspacemodel.ipynb | 8 ++++ holodeck/detstats.py | 41 +++++++++++-------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb b/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb index dae99e1e..7a24eda9 100644 --- a/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb +++ b/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb @@ -327,6 +327,14 @@ "ax.legend(handles=[h1,h2,], labels=[label1, label2])" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add red noise" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 8e1e4b50..8d5bf868 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -242,9 +242,9 @@ def _sigma0_Bstatistic(noise, Gamma, Sh0_bg): # P_j in shape (1,P,1,1) numer = (Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2 - * noise[:,np.newaxis,np.newaxis,np.newaxis] * noise[np.newaxis,:,np.newaxis,np.newaxis]) - denom = ((noise[:,np.newaxis,np.newaxis,np.newaxis] + Sh0_bg[np.newaxis, np.newaxis,:]) - * (noise[np.newaxis,:,np.newaxis,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + * noise[:,np.newaxis,:,np.newaxis] * noise[np.newaxis,:,:,np.newaxis]) + denom = ((noise[:,np.newaxis,:,np.newaxis] + Sh0_bg[np.newaxis, np.newaxis,:]) + * (noise[np.newaxis,:,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2)**2 sum = np.sum(numer/denom, axis=(0,1,2)) @@ -287,12 +287,12 @@ def _sigma1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): # P_j in shape (1,P,1,1) numer = (Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2 - * ((noise[:,np.newaxis,np.newaxis,np.newaxis] + Sh_bg[np.newaxis,np.newaxis,:]) - * (noise[np.newaxis,:,np.newaxis,np.newaxis] + Sh_bg[np.newaxis,np.newaxis,:]) + * ((noise[:,np.newaxis,:,np.newaxis] + Sh_bg[np.newaxis,np.newaxis,:]) + * (noise[np.newaxis,:,:,np.newaxis] + Sh_bg[np.newaxis,np.newaxis,:]) + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh_bg[np.newaxis,np.newaxis,:]**2)) - denom = ((noise[:,np.newaxis,np.newaxis,np.newaxis] + Sh0_bg[np.newaxis, np.newaxis,:]) - * (noise[np.newaxis,:,np.newaxis,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + denom = ((noise[:,np.newaxis,:,np.newaxis] + Sh0_bg[np.newaxis, np.newaxis,:]) + * (noise[np.newaxis,:,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2)**2 sum = np.sum(numer/denom, axis=(0,1,2)) @@ -305,7 +305,7 @@ def _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): Parameters ---------- - noise : (P,) 1darray of scalars + noise : (P,F,) Ndarray of scalars Noise spectral density of each pulsar. Gamma : (P,P) 2Darray of scalars Overlap reduction function for j>i, 0 otherwise. @@ -336,8 +336,8 @@ def _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): numer = (Gamma[:,:,np.newaxis,np.newaxis] **2 * Sh_bg[np.newaxis,np.newaxis,:] * Sh0_bg[np.newaxis,np.newaxis,:]) - denom = ((noise[:,np.newaxis,np.newaxis,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) - * (noise[np.newaxis,:,np.newaxis,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + denom = ((noise[:,np.newaxis,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + * (noise[np.newaxis,:,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis, np.newaxis, :]**2) # Requires Gamma have all jj<=ii parts to zero @@ -438,7 +438,7 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False # print('Sh_bg:', Sh_bg.shape) # Noise - noise = _white_noise(cad, sigmas) + noise = _white_noise(cad, sigmas)[:,np.newaxis] # P, F # print('noise:', noise.shape) sigma_0B = _sigma0_Bstatistic(noise, Gamma, Sh0_bg) @@ -462,7 +462,8 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False -def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False): +def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False, + amp_red=None, gamma_red=None, ): """ Calculate the background detection probability, and all the intermediary steps from a list of hasasia.Pulsar objects. @@ -511,7 +512,11 @@ def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False): Sh_bg = _power_spectral_density(hc_bg[:], fobs) Sh0_bg = Sh_bg # note this refers to same object, not a copy - noise = _white_noise(cad, sigmas) + noise = _white_noise(cad, sigmas)[:,np.newaxis] # P,1 + if (amp_red is not None) and (gamma_red is not None): + red_noise = _red_noise(amp_red, gamma_red)[np.newaxis,:] # (1,F,) + noise = noise + red_noise # (P,F,) + mu_1B = _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg) @@ -1316,7 +1321,7 @@ def _ss_detection_probability(gamma_ss_i): def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, theta_ss, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, - Amp_red=None, gamma_red=None, alpha_0=0.001, ret_snr=False,): + amp_red=None, gamma_red=None, alpha_0=0.001, ret_snr=False,): """ Calculate the single source detection probability, and all intermediary steps. Parameters @@ -1395,7 +1400,7 @@ def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, pi_hat) # (P,F,S,L) # noise spectral density - S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, Amp_red, gamma_red) + S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, amp_red, gamma_red) # amplitudw amp = _amplitude(hc_ss, fobs, dfobs) # (F,R,L) @@ -1417,7 +1422,7 @@ def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, theta_ss=None, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, nskies=25, - Fe_bar = None, Amp_red=None, gamma_red=None, alpha_0=0.001, Fe_bar_guess=15, + Fe_bar = None, amp_red=None, gamma_red=None, alpha_0=0.001, Fe_bar_guess=15, ret_snr=False, print_nans=False, snr_cython=True, gamma_cython=True, grid_path=GAMMA_RHO_GRID_PATH): """ Calculate the single source detection probability, and all intermediary steps for R strain realizations and S sky realizations. @@ -1451,7 +1456,7 @@ def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, If None, random values between 0 and pi will be assigned. Fe_bar : scalar or None Threshold F-statistic - Amp_red : scalar or None + amp_red : scalar or None Amplitude of pulsar red noise. gamma_red : scalar or None Power law index of pulsar red noise. @@ -1512,7 +1517,7 @@ def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, pi_hat) # (P,F,S,L) # noise spectral density - S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, Amp_red, gamma_red) + S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, amp_red, gamma_red) # amplitudw amp = _amplitude(hc_ss, fobs, dfobs) # (F,R,L) From 3e9b0c308f9f5609837312868eb22a5c6e54cd8f Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 20:20:58 -0700 Subject: [PATCH 196/291] Fix and test red noise --- .../ds10_dpvsfreq_troubleshooting.ipynb | 33 ++++++++----------- holodeck/detstats.py | 15 +++++---- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb index fa439056..c085ed3b 100644 --- a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb +++ b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb @@ -74,7 +74,9 @@ "outputs": [], "source": [ "NSKIES = 25\n", - "NPSRS = 10" + "NPSRS = 10\n", + "AMP_RED = 4e-15\n", + "GAMMA_RED = -3.5" ] }, { @@ -169,33 +171,22 @@ "y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents)[0,:,:,0]\n", "y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", "y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + "y4 = detstats._red_noise(AMP_RED, GAMMA_RED, fobs_cents) # (F,)\n", "label1 = 'total noise'\n", "label2 = 'hc-rest noise'\n", "label3 = 'white noise'\n", - "# label4 = '10th loudest'\n", + "label4 = 'red noise'\n", "print(f\"{y1.shape=}, {y2.shape=}, {y3.shape=}\")\n", "\n", "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel='Noise Spectral Density (Hz$^{-3}$)')\n", "h1 = plot.draw_med_conf(ax, xx, y1)\n", "h2 = plot.draw_med_conf(ax, xx, y2)\n", "h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", - "# c1 = h1[0].get_color()\n", - "# c2 = h2[0].get_color()\n", - "# ax.legend(handles=[h1, h2], labels=[label1, label2])\n", - "# for rr in range(NREALS):\n", - "# h3 = ax.scatter(xx, l1[:,rr], ec=c1, fc=None, alpha=0.1)\n", - "# h4 = ax.scatter(xx, l2[:,rr], ec=c2, fc=None, alpha=0.1)\n", + "h4, = ax.plot(xx, y4, color='tab:red', linestyle='--')\n", "\n", - "ax.legend(handles=[h1, h2, h3,], labels=[label1, label2, label3,])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(l3)" + "\n", + "ax.legend(handles=[h1, h2, h3, h4], \n", + " labels=[label1, label2, label3, label4])" ] }, { @@ -242,8 +233,10 @@ "outputs": [], "source": [ "dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", - " nskies=NSKIES, ret_snr=True)\n", - "dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True)\n", + " nskies=NSKIES, ret_snr=True,\n", + " amp_red=AMP_RED, gamma_red=GAMMA_RED)\n", + "dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True,\n", + " amp_red=AMP_RED, gamma_red=GAMMA_RED)\n", "\n", "print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")" ] diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 8d5bf868..87b06b9c 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -514,7 +514,7 @@ def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False, noise = _white_noise(cad, sigmas)[:,np.newaxis] # P,1 if (amp_red is not None) and (gamma_red is not None): - red_noise = _red_noise(amp_red, gamma_red)[np.newaxis,:] # (1,F,) + red_noise = _red_noise(amp_red, gamma_red, fobs)[np.newaxis,:] # (1,F,) noise = noise + red_noise # (P,F,) @@ -864,7 +864,7 @@ def _Sh_rest_noise(hc_ss, hc_bg, freqs): Sh_rest = hc2_rest / freqs[:,np.newaxis,np.newaxis]**3 /(12 * np.pi**2) # (F,R,L) return Sh_rest -def _red_noise(A_red, gamma_red, freqs): +def _red_noise(A_red, gamma_red, freqs, f_ref=1/YR): """ Calculate the red noise for a given pulsar (or array of pulsars) A_red * f sigma_i^gamma_red @@ -882,8 +882,11 @@ def _red_noise(A_red, gamma_red, freqs): P_red : (P,F) NDarray Red noise spectral density for the ith pulsar. + Defined by Eq. (8) in Kelley et al. 2018 + ### what is f_ref + """ - P_red = A_red * freqs**gamma_red + P_red = A_red**2 / (12*np.pi**2) * (freqs/f_ref)**gamma_red * (f_ref)**-3 return P_red @@ -917,7 +920,7 @@ def _total_noise(delta_t, sigmas, hc_ss, hc_bg, freqs, A_red=None, gamma_red=Non Sh_rest = _Sh_rest_noise(hc_ss, hc_bg, freqs) # (F,R,L,) noise = noise[:,np.newaxis,np.newaxis,np.newaxis] + Sh_rest[np.newaxis,:,:,:] # (P,F,R,L) if (A_red is not None) and (gamma_red is not None): - red_noise = _red_noise(A_red, gamma_red) # (F,) + red_noise = _red_noise(A_red, gamma_red, freqs) # (F,) noise = noise + red_noise[np.newaxis,:,np.newaxis,np.newaxis] # (P,F,R,L) return noise @@ -2402,7 +2405,7 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, def calibrate_one_pta(hc_bg, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None, ret_sig = False,): + phis=None, thetas=None, ret_sig = False, amp_red=None, gamma_red=None): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2446,7 +2449,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigma = np.mean([sigmin, sigmax]) # a weighted average would be better psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg, amp_red=amp_red, gamma_red=gamma_red)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): From f0c249e80331b3122919274cce0c10f060c4fec5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 20:22:47 -0700 Subject: [PATCH 197/291] Add red noise to detect_pspace_model_clbrt_pta() --- holodeck/detstats.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 87b06b9c..33a85036 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2215,7 +2215,8 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, - thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True): + thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, + amp_red=None, gamma_red=None): """ Detect pspace model using individual sigma calibration for each realization """ @@ -2248,15 +2249,16 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, # get calibrated psrs psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, tol=tol, maxbads=maxbads, - sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True) + sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, + amp_red=amp_red, gamma_red=gamma_red,) _sigmin /= 2 _sigmax *= 2 # use those psrs to calculate realization detstats - _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True) + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, amp_red=amp_red, gamma_red=gamma_red) dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( - psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True) + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, amp_red=amp_red, gamma_red=gamm_red) # if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() From 0f7dfcc1a4d37d8e780be0c576326a343241d833 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 23:47:13 -0700 Subject: [PATCH 198/291] Rename all amp_red to red_amp and gamma_red to red_gamma --- holodeck/detstats.py | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 33a85036..28366084 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -463,7 +463,7 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False, - amp_red=None, gamma_red=None, ): + red_amp=None, red_gamma=None, ): """ Calculate the background detection probability, and all the intermediary steps from a list of hasasia.Pulsar objects. @@ -513,8 +513,8 @@ def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False, Sh0_bg = Sh_bg # note this refers to same object, not a copy noise = _white_noise(cad, sigmas)[:,np.newaxis] # P,1 - if (amp_red is not None) and (gamma_red is not None): - red_noise = _red_noise(amp_red, gamma_red, fobs)[np.newaxis,:] # (1,F,) + if (red_amp is not None) and (red_gamma is not None): + red_noise = _red_noise(red_amp, red_gamma, fobs)[np.newaxis,:] # (1,F,) noise = noise + red_noise # (P,F,) @@ -864,15 +864,15 @@ def _Sh_rest_noise(hc_ss, hc_bg, freqs): Sh_rest = hc2_rest / freqs[:,np.newaxis,np.newaxis]**3 /(12 * np.pi**2) # (F,R,L) return Sh_rest -def _red_noise(A_red, gamma_red, freqs, f_ref=1/YR): +def _red_noise(red_amp, red_gamma, freqs, f_ref=1/YR): """ Calculate the red noise for a given pulsar (or array of pulsars) - A_red * f sigma_i^gamma_red + red_amp * f sigma_i^red_gamma Parameters ---------- - A_red : scalar + red_amp : scalar Amplitude of red noise. - gamma_red : scalar + red_gamma : scalar Power-law index of red noise freqs : (F,) 1Darray of scalars Frequency bin centers. @@ -886,12 +886,12 @@ def _red_noise(A_red, gamma_red, freqs, f_ref=1/YR): ### what is f_ref """ - P_red = A_red**2 / (12*np.pi**2) * (freqs/f_ref)**gamma_red * (f_ref)**-3 + P_red = red_amp**2 / (12*np.pi**2) * (freqs/f_ref)**red_gamma * (f_ref)**-3 return P_red -def _total_noise(delta_t, sigmas, hc_ss, hc_bg, freqs, A_red=None, gamma_red=None): +def _total_noise(delta_t, sigmas, hc_ss, hc_bg, freqs, red_amp=None, red_gamma=None): """ Calculate the noise spectral density of each pulsar, as it pertains to single source detections, i.e., including the background as a noise source. @@ -919,8 +919,8 @@ def _total_noise(delta_t, sigmas, hc_ss, hc_bg, freqs, A_red=None, gamma_red=Non noise = _white_noise(delta_t, sigmas) # (P,) Sh_rest = _Sh_rest_noise(hc_ss, hc_bg, freqs) # (F,R,L,) noise = noise[:,np.newaxis,np.newaxis,np.newaxis] + Sh_rest[np.newaxis,:,:,:] # (P,F,R,L) - if (A_red is not None) and (gamma_red is not None): - red_noise = _red_noise(A_red, gamma_red, freqs) # (F,) + if (red_amp is not None) and (red_gamma is not None): + red_noise = _red_noise(red_amp, red_gamma, freqs) # (F,) noise = noise + red_noise[np.newaxis,:,np.newaxis,np.newaxis] # (P,F,R,L) return noise @@ -1324,7 +1324,7 @@ def _ss_detection_probability(gamma_ss_i): def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, theta_ss, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, - amp_red=None, gamma_red=None, alpha_0=0.001, ret_snr=False,): + red_amp=None, red_gamma=None, alpha_0=0.001, ret_snr=False,): """ Calculate the single source detection probability, and all intermediary steps. Parameters @@ -1360,9 +1360,9 @@ def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, psi_ss : (F,S,L) NDarray or None Polarization of each single source. If None, random values between 0 and pi will be assigned. - A_red : scalar or None + red_amp : scalar or None Amplitude of pulsar red noise. - gamma_red : scalar or None + red_gamma : scalar or None Power law index of pulsar red noise. alpha_0 : scalar False alarm probability @@ -1403,7 +1403,7 @@ def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, pi_hat) # (P,F,S,L) # noise spectral density - S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, amp_red, gamma_red) + S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, red_amp, red_gamma) # amplitudw amp = _amplitude(hc_ss, fobs, dfobs) # (F,R,L) @@ -1425,7 +1425,7 @@ def detect_ss(thetas, phis, sigmas, fobs, hc_ss, hc_bg, def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, theta_ss=None, phi_ss=None, Phi0_ss=None, iota_ss=None, psi_ss=None, nskies=25, - Fe_bar = None, amp_red=None, gamma_red=None, alpha_0=0.001, Fe_bar_guess=15, + Fe_bar = None, red_amp=None, red_gamma=None, alpha_0=0.001, Fe_bar_guess=15, ret_snr=False, print_nans=False, snr_cython=True, gamma_cython=True, grid_path=GAMMA_RHO_GRID_PATH): """ Calculate the single source detection probability, and all intermediary steps for R strain realizations and S sky realizations. @@ -1459,9 +1459,9 @@ def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, If None, random values between 0 and pi will be assigned. Fe_bar : scalar or None Threshold F-statistic - amp_red : scalar or None + red_amp : scalar or None Amplitude of pulsar red noise. - gamma_red : scalar or None + red_gamma : scalar or None Power law index of pulsar red noise. alpha_0 : scalar False alarm probability @@ -1520,7 +1520,7 @@ def detect_ss_pta(pulsars, fobs, hc_ss, hc_bg, pi_hat) # (P,F,S,L) # noise spectral density - S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, amp_red, gamma_red) + S_i = _total_noise(cad, sigmas, hc_ss, hc_bg, fobs, red_amp, red_gamma) # amplitudw amp = _amplitude(hc_ss, fobs, dfobs) # (F,R,L) @@ -2216,7 +2216,7 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, - amp_red=None, gamma_red=None): + red_amp=None, red_gamma=None): """ Detect pspace model using individual sigma calibration for each realization """ @@ -2250,15 +2250,15 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, # get calibrated psrs psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, tol=tol, maxbads=maxbads, sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, - amp_red=amp_red, gamma_red=gamma_red,) + red_amp=red_amp, red_gamma=red_gamma,) _sigmin /= 2 _sigmax *= 2 # use those psrs to calculate realization detstats - _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, amp_red=amp_red, gamma_red=gamma_red) + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( - psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, amp_red=amp_red, gamma_red=gamm_red) + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, red_amp=red_amp, red_gamma=gamm_red) # if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() @@ -2407,7 +2407,7 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, def calibrate_one_pta(hc_bg, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None, ret_sig = False, amp_red=None, gamma_red=None): + phis=None, thetas=None, ret_sig = False, red_amp=None, red_gamma=None): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2451,7 +2451,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigma = np.mean([sigmin, sigmax]) # a weighted average would be better psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg, amp_red=amp_red, gamma_red=gamma_red)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg, red_amp=red_amp, red_gamma=red_gamma)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): From bab09eb5af4a1970ef0d5b7d09861879facacd26 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 23:47:33 -0700 Subject: [PATCH 199/291] Add red noise to var model script. --- .../detect_model_clbrt_pta.py | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 9d93495e..11802d8c 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -14,6 +14,8 @@ # pta calibration DEF_NSKIES = 100 DEF_NPSRS = 40 +DEF_RED_AMP = None +DEF_RED_GAMMA = None DEF_TOL = 0.01 DEF_MAXBADS = 5 @@ -53,6 +55,10 @@ def _setup_argparse(): help='number of pulsars in pta') parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, help='number of ss sky realizations') + parser.add_argument('--red_amp', action='store', dest='red_amp', type=float, default=DEF_RED_AMP, + help='Red noise amplitude') + parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=int, default=DEF_RED_GAMMA, + help='Red noise gamma') # pta calibration settings parser.add_argument('--sigstart', action='store', dest='sigstart', type=float, default=1e-7, @@ -158,15 +164,19 @@ def main(): % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) if args.load_file is None: - load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' + load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' else: - load_data_from_file = args.load_file+'.npz' + load_data_from_file = args.load_file + if args.save_file is None: - save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}.npz' - save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds.npz' + save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' else: - save_data_to_file = args.save_file+'.npz' - save_dets_to_file = args.save_file+'_ds.npz' + save_data_to_file = args.save_file + + if args.red_amp is not None and args.red_gamma is not None: + save_dets_to_file = save_dets_to_file+'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1e}' + if args.construct or args.detstats: if args.construct: @@ -175,9 +185,9 @@ def main(): target_param=args.target, params_list=params_list, nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=args.shape, seed=None),) - np.savez(save_data_to_file, data=data, params=params) # save before calculating detstats, in case of crash + np.savez(save_data_to_file+'.npz', data=data, params=params) # save before calculating detstats, in case of crash else: - file = np.load(load_data_from_file, allow_pickle=True) + file = np.load(load_data_from_file+'.npz', allow_pickle=True) print('loaded files:', file.files) data = file['data'] params = file['params'] @@ -194,9 +204,9 @@ def main(): _dsdat = detstats.detect_pspace_model_clbrt_pta( fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, - thresh=args.thresh, debug=args.debug) + thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma) dsdat.append(_dsdat) - np.savez(save_dets_to_file, dsdat=dsdat) # overwrite + np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs) # overwrite else: print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") From e397b5ea97b27d83bfe5c98861765cae88d46ac5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 23:47:49 -0700 Subject: [PATCH 200/291] Compare various red noise models. --- .../ds10_dpvsfreq_troubleshooting.ipynb | 149 ++++++++++++------ 1 file changed, 101 insertions(+), 48 deletions(-) diff --git a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb index c085ed3b..a7dcc1ab 100644 --- a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb +++ b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb @@ -75,8 +75,8 @@ "source": [ "NSKIES = 25\n", "NPSRS = 10\n", - "AMP_RED = 4e-15\n", - "GAMMA_RED = -3.5" + "RED_AMP = 1.4e-14\n", + "RED_GAMMA = -6" ] }, { @@ -86,7 +86,9 @@ "outputs": [], "source": [ "# for the 0th realization\n", - "psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True)\n", + "psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True,\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA,\n", + " debug=True)\n", "print(f\"{sigmin=}, {sigmax=}, {sigma=}\")" ] }, @@ -162,31 +164,41 @@ "metadata": {}, "outputs": [], "source": [ + "\n", + "\n", "dur = 1.0/fobs_cents[0]\n", "cad = 1.0/(2*fobs_cents[-1])\n", - "sigmas = np.ones(NPSRS)*sigma\n", + "def plot_noise():\n", + " sigmas = np.ones(NPSRS)*sigma\n", "\n", - "rr=0\n", + " rr=0\n", "\n", - "y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents)[0,:,:,0]\n", - "y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", - "y3 = detstats._white_noise(cad, sigmas) # (P,)\n", - "y4 = detstats._red_noise(AMP_RED, GAMMA_RED, fobs_cents) # (F,)\n", - "label1 = 'total noise'\n", - "label2 = 'hc-rest noise'\n", - "label3 = 'white noise'\n", - "label4 = 'red noise'\n", - "print(f\"{y1.shape=}, {y2.shape=}, {y3.shape=}\")\n", + " y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents,\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA)[0,:,:,0]\n", + " y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", + " y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + " y4 = detstats._red_noise(RED_AMP, RED_GAMMA, fobs_cents) # (F,)\n", + " label1 = 'total noise'\n", + " label2 = 'hc-rest noise'\n", + " label3 = 'white noise'\n", + " label4 = 'red noise'\n", + " print(f\"{y1.shape=}, {y2.shape=}, {y3.shape=}\")\n", + "\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel='Noise Spectral Density (Hz$^{-3}$)')\n", + " h1 = plot.draw_med_conf(ax, xx, y1)\n", + " h2 = plot.draw_med_conf(ax, xx, y2)\n", + " h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", + " h4, = ax.plot(xx, y4, color='tab:red', linestyle='--')\n", "\n", - "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_NHZ, ylabel='Noise Spectral Density (Hz$^{-3}$)')\n", - "h1 = plot.draw_med_conf(ax, xx, y1)\n", - "h2 = plot.draw_med_conf(ax, xx, y2)\n", - "h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", - "h4, = ax.plot(xx, y4, color='tab:red', linestyle='--')\n", "\n", + " ax.legend(handles=[h1, h2, h3, h4], \n", + " labels=[label1, label2, label3, label4])\n", + " ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + " transform=ax.transAxes)\n", + " \n", + " return fig\n", "\n", - "ax.legend(handles=[h1, h2, h3, h4], \n", - " labels=[label1, label2, label3, label4])" + "fig = plot_noise()" ] }, { @@ -234,9 +246,9 @@ "source": [ "dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", " nskies=NSKIES, ret_snr=True,\n", - " amp_red=AMP_RED, gamma_red=GAMMA_RED)\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", "dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True,\n", - " amp_red=AMP_RED, gamma_red=GAMMA_RED)\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", "\n", "print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")" ] @@ -247,22 +259,27 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", + "def plot_dp():\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", "\n", - "xx = fobs_cents*YR\n", - "y1 = dp_bg[0] # 1\n", - "y2 = gamma_ssi[:,0,:,0] # F, S\n", - "y3 = dp_ss[0] # S\n", - "label1 = 'BG Detprob'\n", - "label2 = '1st Loudest Detprob, for each sky realization'\n", - "label3 = 'Overall SS Detprob, for each sky realization'\n", + " xx = fobs_cents*YR\n", + " y1 = dp_bg[0] # 1\n", + " y2 = gamma_ssi[:,0,:,0] # F, S\n", + " y3 = dp_ss[0] # S\n", + " label1 = 'BG Detprob'\n", + " label2 = '1st Loudest Detprob, for each sky realization'\n", + " label3 = 'Overall SS Detprob, for each sky realization'\n", "\n", - "h1 = ax.axhline(y1)\n", - "h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", - "for ss in range(NSKIES):\n", - " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + " h1 = ax.axhline(y1)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + " for ss in range(NSKIES):\n", + " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", "\n", - "ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3])" + " ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3])\n", + " ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + " transform=ax.transAxes)\n", + " return fig\n", + "fig = plot_dp()" ] }, { @@ -279,21 +296,57 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='SNR')\n", + "def plot_snr():\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='SNR')\n", + "\n", + " xx = fobs_cents*YR\n", + " y1 = snr_bg[0] # F,\n", + " y2 = snr_ss[:,0,:,0] # F, S\n", + " # y3 = dp_ss[0] # S\n", + " label1 = 'BG SNR'\n", + " label2 = '1st Loudest SNR, for each sky realization'\n", + "\n", + " h1 = ax.axhline(y1)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + " # for ss in range(NSKIES):\n", + " # h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + "\n", + " ax.legend(handles=[h1,h2,], labels=[label1, label2])\n", + " ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + " transform=ax.transAxes)\n", + " return fig\n", + "fig = plot_snr()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NSKIES = 25\n", + "NPSRS = 10\n", + "RED_AMP = 1.4e-14\n", + "RED_GAMMA = -6\n", "\n", - "xx = fobs_cents*YR\n", - "y1 = snr_bg[0] # F,\n", - "y2 = snr_ss[:,0,:,0] # F, S\n", - "# y3 = dp_ss[0] # S\n", - "label1 = 'BG SNR'\n", - "label2 = '1st Loudest SNR, for each sky realization'\n", + "for RED_GAMMA in [-3, -4, -5, -6, -7, -8]:\n", + " # for the 0th realization\n", + " psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True,\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA,\n", + " debug=True)\n", + " print(f\"{sigmin=}, {sigmax=}, {sigma=}\")\n", + "\n", + " dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", + " nskies=NSKIES, ret_snr=True,\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", + " dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True,\n", + " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", "\n", - "h1 = ax.axhline(y1)\n", - "h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", - "# for ss in range(NSKIES):\n", - "# h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + " print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")\n", "\n", - "ax.legend(handles=[h1,h2,], labels=[label1, label2])" + " fig = plot_noise()\n", + " fig = plot_snr()\n", + " fig = plot_dp()" ] }, { From db04da8677071244a835e166b361c5f7a3a29c24 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 23:51:05 -0700 Subject: [PATCH 201/291] Scratch --- ecg-notebooks/scratch/scratch.ipynb | 86 +++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 ecg-notebooks/scratch/scratch.ipynb diff --git a/ecg-notebooks/scratch/scratch.ipynb b/ecg-notebooks/scratch/scratch.ipynb new file mode 100644 index 00000000..a999fac5 --- /dev/null +++ b/ecg-notebooks/scratch/scratch.ipynb @@ -0,0 +1,86 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x = 1e-6\n", + "print(type(x))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(1.01e-6 / 1.02e-6\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "x = 1e-10\n", + "\n", + "print(x/10**3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import sys \n", + "sys.float_info.min\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def log_mean(arr):\n", + " " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 395b0b24ae0481327ff3ce7ca7bec5bc0a92fc54 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 27 Jun 2023 23:51:42 -0700 Subject: [PATCH 202/291] Add TODO: With red-noise models, check for sigma_max reaching zero & throw out bad models. --- holodeck/detstats.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 28366084..7c58f8ec 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2429,6 +2429,8 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, maximum of the final sigma range used sigma : float final sigma, returned only if ret_sig=True + + TODO: Check if sigma_max hits 0, then return something that essentially says to throw out this model """ # get duration and cadence from fobs From 596a8df9f47914f17e9d620ddfde853c56f7d0d6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 00:34:10 -0700 Subject: [PATCH 203/291] Troubleshoot why detect_bg_pta in calibrate_pta gives 0.5 DP but then in detect_pspace gives different DP. Both use same function and inputs, and sigmas are consistent. --- .../ds11_dpvsfreq_pspacemodel.ipynb | 9 + .../detect_model_clbrt_pta.py | 5 +- .../incl_red_noise.ipynb | 470 ++++++++++++++++++ holodeck/detstats.py | 32 +- 4 files changed, 507 insertions(+), 9 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb diff --git a/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb b/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb index 7a24eda9..aad6c4e9 100644 --- a/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb +++ b/ecg-notebooks/detstats_functions/ds11_dpvsfreq_pspacemodel.ipynb @@ -120,6 +120,15 @@ "print(f\"{sigmin=}, {sigmax=}, {sigma=}\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(psrs[0].__dict__.keys())" + ] + }, { "attachments": {}, "cell_type": "markdown", diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 11802d8c..2a91d5c8 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -175,8 +175,11 @@ def main(): save_data_to_file = args.save_file if args.red_amp is not None and args.red_gamma is not None: - save_dets_to_file = save_dets_to_file+'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1e}' + save_dets_to_file = save_dets_to_file+f'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1f}' + print(f"{load_data_from_file=}.npz") + print(f"{save_data_to_file=}.npz") + print(f"{save_dets_to_file=}.npz") if args.construct or args.detstats: if args.construct: diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb new file mode 100644 index 00000000..2237cc2c --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb @@ -0,0 +1,470 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "# CONSTRUCT = False\n", + "# JUST_DETSTATS = False\n", + "SAVEFIG = False\n", + "# TOL=0.01\n", + "# MAXBADS=5\n", + "\n", + "NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 15\n", + "RED_AMP = 1e-14\n", + "RED_GAMMA = -6\n", + "\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "\n", + "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "load_dets_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + "if RED_AMP is not None and RED_GAMMA is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_ra{RED_AMP:.1e}_rg{RED_GAMMA:.1f}'\n", + "load_dets_from_file = load_dets_from_file+'.npz'\n", + "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", + "print(load_data_from_file)\n", + "print(load_dets_from_file)\n", + "if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get Param Names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "file.close()\n", + "\n", + "file = np.load(load_dets_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "dsdat = file['dsdat']\n", + "\n", + "file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dat in dsdat:\n", + " print(holo.utils.stats(dat['dp_bg']))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(dsdat[0]['dp_bg'].shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Normalize with individual gamma ssi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(f\"{dsdat[0]['gamma_ssi'].shape=}\")\n", + "print(f\"{dsdat[0]['ev_ss'].shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(dat['sspar'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cc = np.zeros((NVARS, NREALS, NSKIES))\n", + "for ii, dat in enumerate(data):\n", + " for rr in range(NREALS):\n", + " for ss in range(NSKIES):\n", + " argmax = np.argmax(dsdat[ii]['gamma_ssi'][:,rr,ss,:])\n", + " fidx, lidx = np.unravel_index(argmax, shape=(NFREQS, NLOUDEST))\n", + " cc[ii,rr,ss] = np.log10(dat['sspar'][0,fidx,rr,lidx]/MSOL)\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(cc), vmax=np.max(cc))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot with mass colorbar" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "clabel = '$\\log M / [\\mathrm{M}_\\odot] $)'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear',)\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = np.repeat(dsdat[ii]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[ii]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + " # for rr in range(len(yy[0])):\n", + "\n", + "x1= np.array(xx)\n", + "yy = np.array(yy)\n", + "\n", + "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", + "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", + "sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", + "cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "\n", + "\n", + "print(f\"{xx.shape=}, {yy.shape=}\")\n", + "\n", + "col = 'tab:blue'\n", + "for pp in [50, 95]:\n", + " med, *conf = np.percentile(yy, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(x1, med, alpha=0.5, color=col)\n", + " ax.fill_between(x1, *conf, color=col, alpha=0.25)\n", + "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "# fig.tight_layout()\n", + "\n", + "# figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "# if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 7c58f8ec..55d1c5f3 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2226,11 +2226,12 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, nfreqs, nreals, nloudest = [*hc_ss.shape] # form arrays for individual realization detstats - dp_ss = np.zeros((nreals, nskies)) - dp_bg = np.zeros(nreals) - snr_ss = np.zeros((nfreqs, nreals, nskies, nloudest)) - snr_bg = np.zeros((nreals)) - gamma_ssi = np.zeros((nfreqs, nreals, nskies, nloudest)) + # set all to nan, only to be replaced if successful pta is found + dp_ss = np.ones((nreals, nskies)) * np.nan + dp_bg = np.ones(nreals) * np.nan + snr_ss = np.ones((nfreqs, nreals, nskies, nloudest)) * np.nan + snr_bg = np.ones((nreals)) * np.nan + gamma_ssi = np.ones((nfreqs, nreals, nskies, nloudest)) * np.nan # for each realization, @@ -2240,6 +2241,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, if debug: mod_start = datetime.now() real_dur = datetime.now() + failed_psrs=0 for rr in range(nreals): if debug: now = datetime.now() @@ -2252,13 +2254,19 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, red_amp=red_amp, red_gamma=red_gamma,) _sigmin /= 2 - _sigmax *= 2 + _sigmax *= 2 + 2e-20 # >1e-20 to make sure it doesnt immediately fail the 0 check + if psrs is None: + failed_psrs += 1 + continue # leave values as nan, if no successful PTA was found + print(holo.utils.stats(psrs[0].toaerrs)) # use those psrs to calculate realization detstats _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) + _dp_bg, = detect_bg_pta(psrs, fobs_cents, hc_bg=hc_bg[:,rr:rr+1], red_amp=red_amp, red_gamma=red_gamma) #, ret_snr=True) + print(f"test2: {_dp_bg=}") dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( - psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, red_amp=red_amp, red_gamma=gamm_red) + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) # if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() @@ -2273,7 +2281,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, _dsdat.update(gamma_ssi=gamma_ssi) if save_snr_ss: _dsdat.update(snr_ss=snr_ss) - print(f"Model took {datetime.now() - mod_start} s") + print(f"Model took {datetime.now() - mod_start} s, {failed_psrs}/{nreals} realizations failed.") return _dsdat @@ -2488,6 +2496,14 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigmin = sigmin/3 sigmax = sigmax*3 nclose=0 + + # check if goal DP is just impossible + if sigmax<1e-20: + psrs=None + if debug: print(f"FAILED! DP_BG=0.5 impossible with {red_amp=}, {red_gamma=}") + break + print(f"test1: {dp_bg=}") + print(f"test1: {sigma=}") if ret_sig: return psrs, sigma, sigmin, sigmax return psrs From c5523a952c405c0bb6201e3c4c68258768a22838 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 11:16:50 -0700 Subject: [PATCH 204/291] Plot red noise ratio vs. parameter and and DP vs frequency --- .../incl_red_noise.ipynb | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb index 2237cc2c..39ecc0a7 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb @@ -39,7 +39,7 @@ "\n", "# CONSTRUCT = False\n", "# JUST_DETSTATS = False\n", - "SAVEFIG = False\n", + "SAVEFIG = True\n", "# TOL=0.01\n", "# MAXBADS=5\n", "\n", @@ -47,8 +47,8 @@ "\n", "NPSRS = 40\n", "NSKIES = 15\n", - "RED_AMP = 1e-14\n", - "RED_GAMMA = -6\n", + "RED_AMP = 1e-15\n", + "RED_GAMMA = -3\n", "\n", "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", @@ -428,14 +428,53 @@ "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", "# fig.tight_layout()\n", "\n", - "# figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", - "# if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "if SAVEFIG: \n", + " figname = path+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED_AMP is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_ra{RED_AMP:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' )" ] }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, + "source": [ + "Individual detprobs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, dsd in enumerate(dsdat):\n", + "\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", + " ax.set_title((TARGET+f' = {params[ii][TARGET]}'))\n", + " xx = data[ii]['fobs_cents']*YR\n", + " y1 = dsd['dp_bg'][0] # 1\n", + " y2 = dsd['gamma_ssi'][:,0,:,0] # F, S\n", + " y3 = dsd['dp_ss'][0] # S\n", + " label1 = 'BG Detprob'\n", + " label2 = '1st Loudest Detprob, for each sky realization'\n", + " label3 = 'Overall SS Detprob, for each sky realization'\n", + "\n", + " h1 = ax.axhline(y1)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + " for ss in range(NSKIES):\n", + " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + "\n", + " ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [] }, { From e4019fa731e231ea9682fe42b59ebf68efa20725 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 11:19:26 -0700 Subject: [PATCH 205/291] Correct red noise calibration and add check for impossible red noise, to return nans. --- holodeck/detstats.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 55d1c5f3..ff988a7e 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2259,11 +2259,14 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, if psrs is None: failed_psrs += 1 continue # leave values as nan, if no successful PTA was found - print(holo.utils.stats(psrs[0].toaerrs)) + # print(f"before calculation: {utils.stats(psrs[0].toaerrs)=}, \n{utils.stats(hc_bg[rr])=},\ + # {utils.stats(fobs_cents)=}") # use those psrs to calculate realization detstats _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) - _dp_bg, = detect_bg_pta(psrs, fobs_cents, hc_bg=hc_bg[:,rr:rr+1], red_amp=red_amp, red_gamma=red_gamma) #, ret_snr=True) - print(f"test2: {_dp_bg=}") + # print(f"{utils.stats(psrs[0].toaerrs)=}, {utils.stats(hc_bg[rr])=},\ + # {_dp_bg=},") + # _dp_bg, = detect_bg_pta(psrs, fobs_cents, hc_bg=hc_bg[:,rr:rr+1], red_amp=red_amp, red_gamma=red_gamma) #, ret_snr=True) + # print(f"test2: {_dp_bg=}") dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) @@ -2451,7 +2454,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigma = sigstart psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis])[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=red_amp, red_gamma=red_gamma)[0] nclose=0 # number of attempts close to 0.5, could be stuck close nfar=0 # number of attempts far from 0.5, could be stuck far @@ -2461,7 +2464,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigma = np.mean([sigmin, sigmax]) # a weighted average would be better psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg, red_amp=red_amp, red_gamma=red_gamma)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=red_amp, red_gamma=red_gamma)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): @@ -2502,8 +2505,10 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, psrs=None if debug: print(f"FAILED! DP_BG=0.5 impossible with {red_amp=}, {red_gamma=}") break - print(f"test1: {dp_bg=}") - print(f"test1: {sigma=}") + # print(f"test1: {dp_bg=}") + # print(f"test1: {sigma=}") + # print(f"in calibration: {utils.stats(psrs[0].toaerrs)=}, \n{utils.stats(hc_bg)=},\ + # {utils.stats(fobs)=}, {dp_bg=}") if ret_sig: return psrs, sigma, sigmin, sigmax return psrs From 0603cc81fa027bb96d6631af938cbd45f960123c Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 12:53:58 -0700 Subject: [PATCH 206/291] Change red_gamma type to float in script. --- ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 2a91d5c8..04ee0bc2 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -57,7 +57,7 @@ def _setup_argparse(): help='number of ss sky realizations') parser.add_argument('--red_amp', action='store', dest='red_amp', type=float, default=DEF_RED_AMP, help='Red noise amplitude') - parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=int, default=DEF_RED_GAMMA, + parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=float, default=DEF_RED_GAMMA, help='Red noise gamma') # pta calibration settings From e89b6356bbdf76db02d1869d7f3fed9cb6bcaa95 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 19:11:47 -0700 Subject: [PATCH 207/291] Plot ratio vs param, DP vs freq, SNR vs freq, hc vs freq. Compare many different red noise models with sigma-calibration. --- .../incl_red_noise.ipynb | 223 +++++++++++++----- 1 file changed, 168 insertions(+), 55 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb index 39ecc0a7..3d908b96 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb @@ -40,6 +40,7 @@ "# CONSTRUCT = False\n", "# JUST_DETSTATS = False\n", "SAVEFIG = True\n", + "SET_YLIM = SAVEFIG\n", "# TOL=0.01\n", "# MAXBADS=5\n", "\n", @@ -47,17 +48,20 @@ "\n", "NPSRS = 40\n", "NSKIES = 15\n", - "RED_AMP = 1e-15\n", - "RED_GAMMA = -3\n", + "RED_AMP = 5e-15\n", + "RED_GAMMA = -1.5\n", "\n", "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", "\n", - "TARGET = 'hard_time' # EDIT AS NEEDED\n", - "TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", + "# TARGET = 'hard_time' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", "\n", "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", - "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" ] }, { @@ -322,15 +326,6 @@ "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(dsdat[0]['dp_bg'].shape)" - ] - }, { "attachments": {}, "cell_type": "markdown", @@ -339,25 +334,6 @@ "# Normalize with individual gamma ssi" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(f\"{dsdat[0]['gamma_ssi'].shape=}\")\n", - "print(f\"{dsdat[0]['ev_ss'].shape=}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(dat['sspar'].shape)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -380,7 +356,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Plot with mass colorbar" + "# Plot ratio vs freq" ] }, { @@ -389,15 +365,24 @@ "metadata": {}, "outputs": [], "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "\n", "xlabel=TITLE\n", "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", "clabel = '$\\log M / [\\mathrm{M}_\\odot] $)'\n", "cmap = cm.rainbow\n", "\n", - "fig, ax = plot.figax(xscale='linear',)\n", + "fig, ax = plot.figax(xscale='linear', figsize=(4,3.5))\n", "ax.set_ylabel(ylabel, fontsize=14)\n", "ax.set_xlabel(xlabel, fontsize=14)\n", + "ax.set_xlim(params[0][TARGET]-0.2, params[NVARS-1][TARGET]+0.05)\n", + "if SET_YLIM: ax.set_ylim(10**-3, 10**1)\n", + "if RED_AMP is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$A_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED_AMP, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", "\n", "target=TARGET\n", "xx = []\n", @@ -414,8 +399,8 @@ "\n", "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", - "sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", - "cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "# sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.2,)\n", + "# cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", "\n", "\n", "print(f\"{xx.shape=}, {yy.shape=}\")\n", @@ -427,13 +412,13 @@ " ax.fill_between(x1, *conf, color=col, alpha=0.25)\n", "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", "# fig.tight_layout()\n", - "\n", - "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", + "fig.tight_layout()\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", "if SAVEFIG: \n", - " figname = path+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " figname = figloc+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", " if RED_AMP is not None and RED_GAMMA is not None:\n", " figname = figname+f'_ra{RED_AMP:.1e}_rg{RED_GAMMA:.1f}'\n", - " fig.savefig(figname+'.png' )" + " fig.savefig(figname+'.png' , bbox_inches='tight')" ] }, { @@ -450,24 +435,93 @@ "metadata": {}, "outputs": [], "source": [ - "for ii, dsd in enumerate(dsdat):\n", + "mpl.rcParams.update({'font.size':8})\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", "\n", - " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", - " ax.set_title((TARGET+f' = {params[ii][TARGET]}'))\n", - " xx = data[ii]['fobs_cents']*YR\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability',\n", + " figsize=(4,3.5))\n", + "if RED_AMP is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$A_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED_AMP, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "ax.set_ylim(1e-6, 2e0)\n", + "xx = data[0]['fobs_cents']*YR\n", + "label1 = 'BG DP'\n", + "label2 = '1st Loudest DP, for each sky+strain realization'\n", + "label3 = 'Total SS DP, for each sky realization'\n", + "\n", + "handles = []\n", + "for ii, dsd in enumerate(dsdat):\n", " y1 = dsd['dp_bg'][0] # 1\n", - " y2 = dsd['gamma_ssi'][:,0,:,0] # F, S\n", - " y3 = dsd['dp_ss'][0] # S\n", - " label1 = 'BG Detprob'\n", - " label2 = '1st Loudest Detprob, for each sky realization'\n", - " label3 = 'Overall SS Detprob, for each sky realization'\n", + " y2 = dsd['gamma_ssi'][:,:,:,0].reshape(NFREQS, NREALS*NSKIES) # F, S\n", + " y3 = dsd['dp_ss']\n", + " y3 = np.repeat(y3, NFREQS).reshape(NREALS*NSKIES, NFREQS)\n", + " y3 = np.swapaxes(y3, 0, 1)\n", "\n", " h1 = ax.axhline(y1)\n", - " h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", - " for ss in range(NSKIES):\n", - " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color=colors[ii])\n", + " # for ss in range(NSKIES*NREALS):\n", + " h3 = plot.draw_med_conf_color(ax, xx, y3, color=colors[ii])\n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "\n", + "leg1 = ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3], loc='upper right',\n", + " fontsize=7)\n", + "leg2 = ax.legend(handles=handles, title=TITLE, loc='lower right')\n", + "ax.add_artist(leg1, )\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", + "if SAVEFIG: \n", + " figname = figloc+f'/DP_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED_AMP is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_ra{RED_AMP:.1e}_rg{RED_GAMMA:.1f}'\n", + " print(figname)\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':10})\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR,\n", + " ylabel=plot.LABEL_CHARACTERISTIC_STRAIN,\n", + " figsize=(5,4))\n", + "\n", + "if RED_AMP is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$A_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED_AMP, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + " \n", + "xx = dat['fobs_cents']*YR\n", + "handles=[]\n", + "for ii, dat in enumerate(data):\n", + " plot.draw_ss_and_gwb(ax, xx, dat['hc_ss'], dat['hc_bg'], color=colors[ii],\n", + " nsamp=2) \n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "ax.legend(handles=handles, loc='lower left', title=TITLE)\n", "\n", - " ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3])" + "if SAVEFIG: \n", + " figname = figloc+f'/hc_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED_AMP is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_ra{RED_AMP:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Noise" ] }, { @@ -475,7 +529,66 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Noise',\n", + " figsize=(4,3.5))\n", + "\n", + "fobs_cents = data[0]['fobs_cents']\n", + "dur = 1.0/fobs_cents[0]\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "xx = fobs_cents*YR\n", + "for ii, dat in enumerate(data):\n", + " hc_bg = dat['hc_bg']\n", + " hc_ss = dat['hc_ss']\n", + "\n", + " # get sigma for the 0th realization\n", + " psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], dat['fobs_cents'], NPSRS, ret_sig=True,\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA,\n", + " debug=False)\n", + " if psrs is not None:\n", + " sigmas = np.ones(NPSRS)*sigma\n", + "\n", + " rr=0\n", + " y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents,\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA)[0,:,:,0]\n", + " y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", + " # y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + " # y4 = detstats._red_noise(RED_AMP, RED_GAMMA, fobs_cents) # (F,)\n", + " print(f\"{y1.shape=}, {y2.shape=}\")\n", + " label1 = 'total noise'\n", + " label2 = 'hc-rest noise'\n", + " # label3 = 'white noise'\n", + " # label4 = 'red noise'\n", + " h1 = plot.draw_med_conf_color(ax, xx, y1, color=colors[ii])\n", + " h2 = ax.plot(xx, y2, color=colors[ii], linestyle='--')\n", + " # h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", + " # h4, = ax.plot(xx, y4, color='tab:red', linestyle='--')\n", + "\n", + "\n", + " # ax.legend(handles=[h1, h2, h3, h4], \n", + " # labels=[label1, label2, label3, label4])\n", + "ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + " transform=ax.transAxes)\n", + " \n", + "handles = [mpl.lines.Line2D([0], [0], label='total noise', linestyle='-'), mpl.lines.Line2D([0], [0], label='hc_rest noise', linestyle='--')]\n", + "leg1 = ax.legend(handles=handles, loc='lower left', )\n", + "\n", + "handles=[]\n", + "for ii, dat in enumerate(data):\n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "leg2 = ax.legend(handles=handles, bbox_to_anchor=(0,.15), title=TITLE, loc='lower left')\n", + "ax.add_artist(leg1)\n", + "if SAVEFIG: \n", + " figname = figloc+f'/noise_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED_AMP is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_ra{RED_AMP:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] }, { "cell_type": "code", From f76637459d8a6f9ad5f171c2030ed9cc0fb58b9a Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 19:12:00 -0700 Subject: [PATCH 208/291] Allow color setting option for draw_ss_bg. --- holodeck/plot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/holodeck/plot.py b/holodeck/plot.py index 6b62ee27..00fbed47 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -499,7 +499,8 @@ def draw_ss_and_gwb(ax, xx, hc_ss, gwb, nsamp=10, if(ii==0): label=bglabel else: label=None - ax.plot(xx, gwb[:, ii], color=colors[ci], alpha=0.25, lw=1.0, ls='-') + cc = colors[ci] if color is None else color + ax.plot(xx, gwb[:, ii], color=cc, alpha=0.25, lw=1.0, ls='-') for ll in range(len(hc_ss[0,0])): if(ll==0): edgecolor='k' @@ -508,7 +509,7 @@ def draw_ss_and_gwb(ax, xx, hc_ss, gwb, nsamp=10, else: edgecolor=None label=None - ax.scatter(xx, hc_ss[:, ii, ll], color=colors[ci], alpha=0.25, + ax.scatter(xx, hc_ss[:, ii, ll], color=cc, alpha=0.25, edgecolor=edgecolor, label=label) ci+=1 From bdcf27120f7c58f3c49fb6864301b09e9da1d9d3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 19:12:22 -0700 Subject: [PATCH 209/291] Red noise corrections.' --- .../ds10_dpvsfreq_troubleshooting.ipynb | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb index a7dcc1ab..a9cd50b5 100644 --- a/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb +++ b/ecg-notebooks/detstats_functions/ds10_dpvsfreq_troubleshooting.ipynb @@ -75,8 +75,8 @@ "source": [ "NSKIES = 25\n", "NPSRS = 10\n", - "RED_AMP = 1.4e-14\n", - "RED_GAMMA = -6" + "RED_AMP = 2e-13\n", + "RED_GAMMA = -1.5" ] }, { @@ -87,7 +87,7 @@ "source": [ "# for the 0th realization\n", "psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA,\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA,\n", " debug=True)\n", "print(f\"{sigmin=}, {sigmax=}, {sigma=}\")" ] @@ -174,7 +174,7 @@ " rr=0\n", "\n", " y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA)[0,:,:,0]\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA)[0,:,:,0]\n", " y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", " y3 = detstats._white_noise(cad, sigmas) # (P,)\n", " y4 = detstats._red_noise(RED_AMP, RED_GAMMA, fobs_cents) # (F,)\n", @@ -246,9 +246,9 @@ "source": [ "dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", " nskies=NSKIES, ret_snr=True,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA)\n", "dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA)\n", "\n", "print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")" ] @@ -326,21 +326,21 @@ "source": [ "NSKIES = 25\n", "NPSRS = 10\n", - "RED_AMP = 1.4e-14\n", - "RED_GAMMA = -6\n", + "RED_AMP = 4e-15\n", + "RED_GAMMA = -3\n", "\n", "for RED_GAMMA in [-3, -4, -5, -6, -7, -8]:\n", " # for the 0th realization\n", " psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], fobs_cents, NPSRS, ret_sig=True,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA,\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA,\n", " debug=True)\n", " print(f\"{sigmin=}, {sigmax=}, {sigma=}\")\n", "\n", " dp_ss, snr_ss, gamma_ssi = detstats.detect_ss_pta(psrs, fobs_cents, hc_ss, hc_bg, \n", " nskies=NSKIES, ret_snr=True,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA)\n", " dp_bg, snr_bg = detstats.detect_bg_pta(psrs, fobs_cents, hc_bg, ret_snr=True,\n", - " red_amp=RED_AMP, red_gama=RED_GAMMA)\n", + " red_amp=RED_AMP, red_gamma=RED_GAMMA)\n", "\n", " print(f\"{dp_ss.shape=}, {snr_ss.shape=}, {dp_bg.shape=}, {snr_bg.shape=}\")\n", "\n", From 6b87ece55b6d7526a859f3bda586cdbfda759dc6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 28 Jun 2023 19:41:39 -0700 Subject: [PATCH 210/291] Add functions to calibrate pta by red noise amplitude. --- holodeck/detstats.py | 171 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index ff988a7e..6543d7f5 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2288,6 +2288,89 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, return _dsdat +def detect_pspace_model_clbrt_ramp(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigma, + rampstart=1e-16, rampmin=1e-20, rampmax=1e-13, tol=0.01, maxbads=5, + thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, + red_amp=None, red_gamma=None): + """ Detect pspace model using individual red noise amplitude calibration for each realization + + """ + dur = 1.0/fobs_cents[0] + cad = 1.0/(2*fobs_cents[-1]) + + nfreqs, nreals, nloudest = [*hc_ss.shape] + + # form arrays for individual realization detstats + # set all to nan, only to be replaced if successful pta is found + dp_ss = np.ones((nreals, nskies)) * np.nan + dp_bg = np.ones(nreals) * np.nan + snr_ss = np.ones((nfreqs, nreals, nskies, nloudest)) * np.nan + snr_bg = np.ones((nreals)) * np.nan + gamma_ssi = np.ones((nfreqs, nreals, nskies, nloudest)) * np.nan + + # get psrs + phis = np.random.uniform(0, 2*np.pi, size = npsrs) + thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, + phi=phis, theta=thetas) + + # for each realization, + # use sigmin and sigmax from previous realization, + # unless it's the first realization of the sample + _rampstart, _rampmin, _rampmax = rampstart, rampmin, rampmax + if debug: + mod_start = datetime.now() + real_dur = datetime.now() + failed_psrs=0 + for rr in range(nreals): + if debug: + now = datetime.now() + if (rr%10==0): + print(f"{rr=}, {now-real_dur} s per realization, {_rampmin=:.2e}, {_rampmax=:.2e}, {_rampstart=:.2e}") + real_dur = now + + # get calibrated psrs + ramp, _ramp_min, _rampmax = calibrate_one_ramp(hc_bg[:,rr], fobs_cents, npsrs, sigma, + tol=tol, maxbads=maxbads, + rampstart=_rampstart, rampmin=_rampmin, rampmax=_rampmax, debug=debug, + red_gamma=red_gamma,) + _rampstart = ramp + _rampmin /= 2 + _rampmax *= 2 + 2e-50 # >1e-20 to make sure it doesnt immediately fail the 0 check + + if ramp is None: + failed_psrs += 1 + continue # leave values as nan, if no successful PTA was found + # print(f"before calculation: {utils.stats(psrs[0].toaerrs)=}, \n{utils.stats(hc_bg[rr])=},\ + # {utils.stats(fobs_cents)=}") + # use those psrs to calculate realization detstats + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, red_amp=ramp, red_gamma=red_gamma) + # print(f"{utils.stats(psrs[0].toaerrs)=}, {utils.stats(hc_bg[rr])=},\ + # {_dp_bg=},") + # _dp_bg, = detect_bg_pta(psrs, fobs_cents, hc_bg=hc_bg[:,rr:rr+1], red_amp=red_amp, red_gamma=red_gamma) #, ret_snr=True) + # print(f"test2: {_dp_bg=}") + dp_bg[rr], snr_bg[rr] = _dp_bg.squeeze(), _snr_bg.squeeze() + _dp_ss, _snr_ss, _gamma_ssi = detect_ss_pta( + psrs, fobs_cents, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], nskies=nskies, ret_snr=True, red_amp=ramp, red_gamma=red_gamma) + # if debug: print(f"{_dp_ss.shape=}, {_snr_ss.shape=}, {_gamma_ssi.shape=}") + dp_ss[rr], snr_ss[:,rr], gamma_ssi[:,rr] = _dp_ss.squeeze(), _snr_ss.squeeze(), _gamma_ssi.squeeze() + + ev_ss = expval_of_ss(gamma_ssi) + df_ss, df_bg = detfrac_of_reals(dp_ss, dp_bg) + _dsdat = { + 'dp_ss':dp_ss, 'snr_ss':snr_ss, 'gamma_ssi':gamma_ssi, + 'dp_bg':dp_bg, 'snr_bg':snr_bg, + 'df_ss':df_ss, 'df_bg':df_bg, 'ev_ss':ev_ss, + } + if save_gamma_ssi: + _dsdat.update(gamma_ssi=gamma_ssi) + if save_snr_ss: + _dsdat.update(snr_ss=snr_ss) + print(f"Model took {datetime.now() - mod_start} s, {failed_psrs}/{nreals} realizations failed.") + return _dsdat + + + def detect_pspace_model_clbrt_sigma(fobs_cents, hc_ss, hc_bg, npsrs, nskies, maxtrials=1): """ Detect pspace model using individual PTA calibration for each realization @@ -2513,3 +2596,91 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, return psrs, sigma, sigmin, sigmax return psrs +def calibrate_one_ramp(hc_bg, fobs, psrs, + rampstart=1e-6, rampmin=1e-9, rampmax=1e-4, debug=False, maxbads=20, tol=0.03, + phis=None, thetas=None, rgam=-1.5): + """ Calibrate the red noise amplitude, for a given realization, and return that PTA + + Parameters + ---------- + hc_bg : (F,) 1Darray + The background characteristic strain for one realization. + fobs : (F,) 1Darray + Observed GW frequencies. + psrs : hasasia.sim.pta object + PTA w/ fixed white noise + sigma : scalar + White noise sigma + + Returns + ------- + redamp : float + final redamp, returned only if ret_ramp = True + redampmin : float + minimum of the final sigma range used, returned only if ret_sig=True + redampmax : float, returned only if ret_sig=True + maximum of the final sigma range used + + TODO: Check if sigma_max hits 0, then return something that essentially says to throw out this model + """ + + # get duration and cadence from fobs + dur = 1.0/fobs[0] + cad = 1.0/(2.0*fobs[-1]) + + # randomize pulsar positions + ramp = rampstart + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=rgam, red_gamma=ramp)[0] + + nclose=0 # number of attempts close to 0.5, could be stuck close + nfar=0 # number of attempts far from 0.5, could be stuck far + + # calibrate sigma + while np.abs(dp_bg-0.50)>tol: + ramp = np.mean([rampmin, rampmax]) # a weighted average would be better + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=ramp, red_gamma=rgam)[0] + + # if debug: print(f"{dp_bg=}") + if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): + nfar +=1 + + # check if we need to expand the range + if (nfar>5*maxbads # if we've had many bad guesses + or (rampmin/rampmax > 0.99 # or our range is small and we are far from the goal + and (dp_bg<0.4 or dp_bg>0.6))): + + # then we must expand the range + if debug: print(f"STUCK! {nfar=}, {dp_bg=}, {rampmin=:e}, {rampmax=:e}") + if dp_bg < 0.5-tol: # stuck way too low, allow much lower sigmin to raise DP + rampmin = rampmin/3 + if dp_bg > 0.5+tol: # stuck way too high, allow much higher sigmax to lower DP + rampmax = rampmax*3 + + # reset count for far guesses + nfar = 0 + + # check how we should narrow our range + if dp_bg<0.5-tol: # dp too low, lower sigma + rampmax = ramp + elif dp_bg>0.5+tol: # dp too high, raise sigma + rampmin = ramp + else: + nclose += 1 # check how many attempts between 0.49 and 0.51 fail + + # check if we are stuck near the goal value with a bad range + if nclose>maxbads: # if many fail, we're stuck; expand sampling range + if debug: print(f"{nclose=}, {dp_bg=}, {rampmin=:e}, {rampmax=:e}") + rampmin = rampmin/3 + rampmax = rampmax*3 + nclose=0 + + # check if goal DP is just impossible + if rampmax<1e-50: + ramp=None + if debug: print(f"FAILED! DP_BG=0.5 impossible with sigma={np.mean(psrs[0].toaerrs)}, {rgam=}") + break + # print(f"test1: {dp_bg=}") + # print(f"test1: {sigma=}") + # print(f"in calibration: {utils.stats(psrs[0].toaerrs)=}, \n{utils.stats(hc_bg)=},\ + # {utils.stats(fobs)=}, {dp_bg=}") + return ramp, rampmin, rampmax \ No newline at end of file From a5221600d3c9547ce3c2d018c5336366da07db52 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 29 Jun 2023 00:13:59 -0700 Subject: [PATCH 211/291] Plot variations of calibration with red noise amplitude. --- .../detect_model_clbrt_ramp.py | 222 ++++++ .../incl_red_noise.ipynb | 23 +- .../incl_red_noise_rampcalibration.ipynb | 634 ++++++++++++++++++ 3 files changed, 872 insertions(+), 7 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py new file mode 100644 index 00000000..a8f7fd98 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py @@ -0,0 +1,222 @@ +import numpy as np +import holodeck as holo +import argparse +from holodeck import detstats +from datetime import datetime + +# sample +DEF_SHAPE = None +DEF_NLOUDEST = 10 +DEF_NREALS = 100 +DEF_NFREQS = 40 +DEF_NVARS = 21 + +# pta calibration +DEF_NSKIES = 100 +DEF_NPSRS = 40 +DEF_SIGMA = 1e-9 +DEF_RED_GAMMA = -3.0 + +DEF_TOL = 0.01 +DEF_MAXBADS = 5 +GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' + +# settings to vary +DEF_CONSTRUCT = False +DEF_DETSTATS = False + + +def _setup_argparse(): + parser = argparse.ArgumentParser() + parser.add_argument('target', action='store', type=str, + help="target parameter to vary") + # parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + # help="gamma-rho interpolation grid path") + + # sample models setup + parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, + help='number of frequency bins') + parser.add_argument('-r', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, + help='number of strain realizations') + parser.add_argument('-l', '--nloudest', action='store', dest='nloudest', type=int, default=DEF_NLOUDEST, + help='number of loudest single sources') + parser.add_argument('-v', '--nvars', action='store', dest='nvars', type=int, default=DEF_NVARS, + help='number of variations on target param') + parser.add_argument('--shape', action='store', dest='shape', type=int, default=DEF_SHAPE, + help='sam shape') + # parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, + # help='pta duration in yrs') + + + + # pta setup + parser.add_argument('-p', '--npsrs', action='store', dest='npsrs', type=int, default=DEF_NPSRS, + help='number of pulsars in pta') + parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, + help='number of ss sky realizations') + parser.add_argument('--sigma', action='store', dest='sigma', type=float, default=DEF_SIGMA, + help='White noise sigma') + parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=float, default=DEF_RED_GAMMA, + help='Red noise gamma') + + # pta calibration settings + parser.add_argument('--rampstart', action='store', dest='rampstart', type=float, default=1e-7, + help='starting ramp if for realization calibration') + parser.add_argument('--rampmin', action='store', dest='rampmin', type=float, default=1e-18, + help='ramp minimum for calibration') + parser.add_argument('--rampmax', action='store', dest='rampmax', type=float, default=1e-13, + help='ramp maximum for calibration') + parser.add_argument('--thresh', action='store', dest='thresh', type=float, default=0.5, + help='threshold for detection fractions') + parser.add_argument('-t', '--tol', action='store', dest='tol', type=float, default=DEF_TOL, + help='tolerance for BG DP calibration') + parser.add_argument('-b', '--maxbads', action='store', dest='maxbads', type=int, default=DEF_MAXBADS, + help='number of bad ramps to try before expanding the search range') + + # general settings + parser.add_argument('--construct', action='store_true', default=DEF_CONSTRUCT, + help='construct data and detstats for each varying param') + parser.add_argument('--detstats', action='store_true', default=DEF_DETSTATS, + help='construct detstats, using saved data') + parser.add_argument('--debug', action='store_true', default=False, + help='print steps along the way') + + # rarely need changing + parser.add_argument('--snr_cython', action='store_true', default=True, + help='Use cython for ss snr calculations') + parser.add_argument('--save_ssi', action='store_true', default=True, + help="Save 'gamma_ssi', the detprob of each single source.") + parser.add_argument('--clbrt', action='store_true', default=True, + help="Whether or not to calibrate the PTA for individual realizations.") + parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + help="gamma-rho interpolation grid path") + parser.add_argument('--anatomy_path', action='store', dest ='anatomy_path', type=str, default=ANATOMY_PATH, + help="path to load and save anatomy files") + parser.add_argument('--load_file', action='store', dest ='load_file', type=str, default=None, + help="file to load sample data and params, excluding .npz suffice") + parser.add_argument('--save_file', action='store', dest ='save_file', type=str, default=None, + help="file to save sample data, excluding .npz suffix") + + args = parser.parse_args() + return args + + +# # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this +# pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None) + +def vary_parameter( + target_param, # the name of the parameter, has to exist in `param_names` + params_list, # the values we'll check + nreals, nfreqs, nloudest, + pspace, + pars=None, save_dir=None, debug=True + ): + + # get the parameter names from this library-space + param_names = pspace.param_names + num_pars = len(pspace.param_names) + if debug: print(f"{num_pars=} :: {param_names=}") + + # choose each parameter to be half-way across the range provided by the library + if pars is None: + pars = 0.5 * np.ones(num_pars) + str_pars = str(pars).replace(" ", "_").replace("[", "").replace("]", "") + # Choose parameter to vary + param_idx = param_names.index(target_param) + + data = [] + params = [] + for ii, par in enumerate(params_list): + pars[param_idx] = par + if debug: print(f"{ii=}, {pars=}") + # _params = pspace.param_samples[0]*pars + _params = pspace.normalized_params(pars) + params.append(_params) + # construct `sam` and `hard` instances based on these parameters + sam, hard = pspace.model_for_params(_params, pspace.sam_shape) + if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM): + hard_name = 'Fixed Time' + elif isinstance(hard, holo.hardening.Hard_GW): + hard_name = 'GW Only' + # run this model, retrieving binary parameters and the GWB + _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=nloudest, + gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True) + data.append(_data) + if save_dir is not None: + str_shape = str(sam.shape).replace(", ", "_").replace("(", "").replace(")", "") + filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape) + np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param ) + if debug: print('saved to %s' % filename) + + return (data, params) + + + +def main(): + start_time = datetime.now() + print("-----------------------------------------") + print(f"starting at {start_time}") + print("-----------------------------------------") + + args = _setup_argparse() + print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" + % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) + + if args.load_file is None: + load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + else: + load_data_from_file = args.load_file + + if args.save_file is None: + save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + else: + save_data_to_file = args.save_file + save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' + save_dets_to_file = save_dets_to_file+f'_sig{args.sigma:.1e}_rg{args.red_gamma:.1f}' + + print(f"{load_data_from_file=}.npz") + print(f"{save_data_to_file=}.npz") + print(f"{save_dets_to_file=}.npz") + + if args.construct or args.detstats: + if args.construct: + params_list = np.linspace(0,1,args.nvars) + data, params, = vary_parameter( + target_param=args.target, params_list=params_list, + nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, + pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=args.shape, seed=None),) + np.savez(save_data_to_file+'.npz', data=data, params=params) # save before calculating detstats, in case of crash + else: + file = np.load(load_data_from_file+'.npz', allow_pickle=True) + print('loaded files:', file.files) + data = file['data'] + params = file['params'] + file.close() + + fobs_cents = data[0]['fobs_cents'] + + # get dsdat for each data/param + dsdat = [] + for ii, _data in enumerate(data): + if args.debug: print(f"on var {ii=} out of {args.nvars}") + hc_bg = _data['hc_bg'] + hc_ss = _data['hc_ss'] + _dsdat = detstats.detect_pspace_model_clbrt_ramp( + fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, args.sigma, + rampstart=args.rampstart, rampmin=args.rampmin, rampmax=args.rampmax, tol=args.tol, maxbads=args.maxbads, + thresh=args.thresh, debug=args.debug, red_gamma=args.red_gamma) + dsdat.append(_dsdat) + np.savez(save_dets_to_file+'.npz', dsdat=dsdat, sigma=args.sigma, red_gamma=args.red_gamma, npsrs=args.npsrs) # overwrite + else: + print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") + + end_time = datetime.now() + print("-----------------------------------------") + print(f"ending at {end_time}") + print(f"total time: {end_time - start_time}") + print("-----------------------------------------") + +if __name__ == "__main__": + main() + diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb index 3d908b96..811debc0 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb @@ -48,20 +48,26 @@ "\n", "NPSRS = 40\n", "NSKIES = 15\n", - "RED_AMP = 5e-15\n", - "RED_GAMMA = -1.5\n", - "\n", - "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", - "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "RED_AMP = None\n", + "RED_GAMMA = None\n", "\n", "# TARGET = 'hard_time' # EDIT AS NEEDED\n", "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", "\n", + "# TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: $\\psi_0$ ' # EDIT AS NEEDED\n", + "\n", "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", - "TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" + "TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" ] }, { @@ -83,6 +89,9 @@ " err = 'load data file does not exist, you need to construct it.'\n", " raise Exception(err)\n", "\n", + "if os.path.exists(load_dets_from_file) is False:\n", + " err = 'load detstats file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", "# print(save_data_to_file)" ] }, diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb new file mode 100644 index 00000000..98440f80 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb @@ -0,0 +1,634 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "# CONSTRUCT = False\n", + "# JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "SET_YLIM = SAVEFIG\n", + "# TOL=0.01\n", + "# MAXBADS=5\n", + "\n", + "NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 15\n", + "SIGMA = 1e-8\n", + "RED_GAMMA = -3.0\n", + "\n", + "# TARGET = 'hard_time' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: $\\psi_0$ ' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "load_dets_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + "load_dets_from_file = load_dets_from_file+f'_sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + "load_dets_from_file = load_dets_from_file+'.npz'\n", + "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", + "print(load_data_from_file)\n", + "print(load_dets_from_file)\n", + "if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "if os.path.exists(load_dets_from_file) is False:\n", + " err = 'load detstats file does not exist.'\n", + " raise Exception(err)\n", + "\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get Param Names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "file.close()\n", + "\n", + "file = np.load(load_dets_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "dsdat = file['dsdat']\n", + "\n", + "file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dat in dsdat:\n", + " print(holo.utils.stats(dat['dp_bg']))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Normalize with individual gamma ssi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cc = np.zeros((NVARS, NREALS, NSKIES))\n", + "for ii, dat in enumerate(data):\n", + " for rr in range(NREALS):\n", + " for ss in range(NSKIES):\n", + " argmax = np.argmax(dsdat[ii]['gamma_ssi'][:,rr,ss,:])\n", + " fidx, lidx = np.unravel_index(argmax, shape=(NFREQS, NLOUDEST))\n", + " cc[ii,rr,ss] = np.log10(dat['sspar'][0,fidx,rr,lidx]/MSOL)\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(cc), vmax=np.max(cc))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot ratio vs freq" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "\n", + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "clabel = '$\\log M / [\\mathrm{M}_\\odot] $)'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear', figsize=(4,3.5))\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "ax.set_xlim(params[0][TARGET]-0.2, params[NVARS-1][TARGET]+0.05)\n", + "if SET_YLIM: ax.set_ylim(10**-3, 10**1)\n", + "if SIGMA is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$\\sigma_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (SIGMA, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = np.repeat(dsdat[ii]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[ii]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + " # for rr in range(len(yy[0])):\n", + "\n", + "x1= np.array(xx)\n", + "yy = np.array(yy)\n", + "\n", + "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", + "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", + "# sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.2,)\n", + "# cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "\n", + "\n", + "print(f\"{xx.shape=}, {yy.shape=}\")\n", + "\n", + "col = 'tab:blue'\n", + "for pp in [50, 95]:\n", + " med, *conf = np.percentile(yy, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(x1, med, alpha=0.5, color=col)\n", + " ax.fill_between(x1, *conf, color=col, alpha=0.25)\n", + "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "# fig.tight_layout()\n", + "fig.tight_layout()\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", + "if SAVEFIG: \n", + " figname = figloc+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if SIGMA is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Individual detprobs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability',\n", + " figsize=(4,3.5))\n", + "if SIGMA is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$\\sigma_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (SIGMA, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "ax.set_ylim(1e-6, 2e0)\n", + "xx = data[0]['fobs_cents']*YR\n", + "label1 = 'BG DP'\n", + "label2 = '1st Loudest DP, for each sky+strain realization'\n", + "label3 = 'Total SS DP, for each sky realization'\n", + "\n", + "handles = []\n", + "for ii, dsd in enumerate(dsdat):\n", + " y1 = dsd['dp_bg'][0] # 1\n", + " y2 = dsd['gamma_ssi'][:,:,:,0].reshape(NFREQS, NREALS*NSKIES) # F, S\n", + " y3 = dsd['dp_ss']\n", + " y3 = np.repeat(y3, NFREQS).reshape(NREALS*NSKIES, NFREQS)\n", + " y3 = np.swapaxes(y3, 0, 1)\n", + "\n", + " h1 = ax.axhline(y1)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color=colors[ii])\n", + " # for ss in range(NSKIES*NREALS):\n", + " h3 = plot.draw_med_conf_color(ax, xx, y3, color=colors[ii])\n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "\n", + "leg1 = ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3], loc='upper right',\n", + " fontsize=7)\n", + "leg2 = ax.legend(handles=handles, title=TITLE, loc='lower right')\n", + "ax.add_artist(leg1, )\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", + "if SAVEFIG: \n", + " figname = figloc+f'/DP_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if SIGMA is not None and RED_GAMMA is not None:\n", + " figname = figname+f'sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + " print(figname)\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':10})\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR,\n", + " ylabel=plot.LABEL_CHARACTERISTIC_STRAIN,\n", + " figsize=(5,4))\n", + "\n", + "# if SIGMA is not None and RED_GAMMA is not None:\n", + "# ax.set_title(('$\\sigma_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + "# % (SIGMA, RED_GAMMA, TITLE)))\n", + "# else: \n", + "# ax.set_title(f\"White Noise Only, {TITLE}\")\n", + " \n", + "xx = dat['fobs_cents']*YR\n", + "handles=[]\n", + "for ii, dat in enumerate(data):\n", + " plot.draw_ss_and_gwb(ax, xx, dat['hc_ss'], dat['hc_bg'], color=colors[ii],\n", + " nsamp=2) \n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "ax.legend(handles=handles, loc='lower left', title=TITLE)\n", + "\n", + "if SAVEFIG: \n", + " figname = figloc+f'/hc_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if SIGMA is not None and RED_GAMMA is not None:\n", + " figname = figname+f'sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Noise" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Noise',\n", + " figsize=(4,3.5))\n", + "if SIGMA is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$\\sigma_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (SIGMA, RED_GAMMA, TITLE)))\n", + "fobs_cents = data[0]['fobs_cents']\n", + "dur = 1.0/fobs_cents[0]\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "psrs = detstats._build_pta(NPSRS, SIGMA, dur, cad)\n", + "\n", + "xx = fobs_cents*YR\n", + "for ii, dat in enumerate(data):\n", + " hc_bg = dat['hc_bg']\n", + " hc_ss = dat['hc_ss']\n", + "\n", + " # get sigma for the 0th realization\n", + " ramp, rampmin, rampmax, = detstats.calibrate_one_ramp(hc_bg[:,0], dat['fobs_cents'], psrs,\n", + " rgam=RED_GAMMA,\n", + " debug=False)\n", + " if psrs is not None:\n", + " sigmas = np.ones(NPSRS)*SIGMA\n", + "\n", + " rr=0\n", + " y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents,\n", + " red_amp=ramp, red_gamma=RED_GAMMA)[0,:,:,0]\n", + " y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", + " # y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + " # y4 = detstats._red_noise(RED_AMP, RED_GAMMA, fobs_cents) # (F,)\n", + " print(f\"{y1.shape=}, {y2.shape=}\")\n", + " label1 = 'total noise'\n", + " label2 = 'hc-rest noise'\n", + " # label3 = 'white noise'\n", + " # label4 = 'red noise'\n", + " h1 = plot.draw_med_conf_color(ax, xx, y1, color=colors[ii])\n", + " h2 = ax.plot(xx, y2, color=colors[ii], linestyle='--')\n", + " # h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", + " # h4, = ax.plot(xx, y4, color='tab:red', linestyle='--')\n", + "\n", + "\n", + " # ax.legend(handles=[h1, h2, h3, h4], \n", + " # labels=[label1, label2, label3, label4])\n", + "# ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + "# transform=ax.transAxes)\n", + " \n", + "handles = [mpl.lines.Line2D([0], [0], label='total noise', linestyle='-'), mpl.lines.Line2D([0], [0], label='hc_rest noise', linestyle='--')]\n", + "leg1 = ax.legend(handles=handles, loc='lower left', )\n", + "\n", + "handles=[]\n", + "for ii, dat in enumerate(data):\n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "leg2 = ax.legend(handles=handles, bbox_to_anchor=(0,.15), title=TITLE, loc='lower left')\n", + "ax.add_artist(leg1)\n", + "if SAVEFIG: \n", + " figname = figloc+f'/noise_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if SIGMA is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 4221d71cabba39ef23fd7e9fef562b0eea94df37 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 29 Jun 2023 00:38:33 -0700 Subject: [PATCH 212/291] Begin calibration using fixed ratio between red and white noise amplitudes. Needs conversion. --- .../detect_model_clbrt_pta.py | 14 +++++++-- .../incl_red_noise.ipynb | 10 +++--- .../incl_red_noise_rampcalibration.ipynb | 10 +++--- holodeck/detstats.py | 31 +++++++++++++------ 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 04ee0bc2..d015efea 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -16,6 +16,7 @@ DEF_NPSRS = 40 DEF_RED_AMP = None DEF_RED_GAMMA = None +DEF_RED2WHITE = None DEF_TOL = 0.01 DEF_MAXBADS = 5 @@ -59,6 +60,8 @@ def _setup_argparse(): help='Red noise amplitude') parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=float, default=DEF_RED_GAMMA, help='Red noise gamma') + parser.add_argument('--red2white', action='store', dest='red2white', type=float, default=DEF_RED2WHITE, + help='Red noise amplitude to white noise amplitude ratio.') # pta calibration settings parser.add_argument('--sigstart', action='store', dest='sigstart', type=float, default=1e-7, @@ -170,12 +173,17 @@ def main(): if args.save_file is None: save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' - save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' else: save_data_to_file = args.save_file - if args.red_amp is not None and args.red_gamma is not None: + save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' + if args.red2white is not None and args.red_gamma is not None: + save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1e}_rg{args.red_gamma:.1f}' + elif args.red_amp is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1f}' + if args.red2white is not None and args.red_amp is not None: + print(f"{args.red2white=} and {args.red_amp} both provided. red_amp will be overriden by red2white ratio.") + print(f"{load_data_from_file=}.npz") print(f"{save_data_to_file=}.npz") @@ -207,7 +215,7 @@ def main(): _dsdat = detstats.detect_pspace_model_clbrt_pta( fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, - thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma) + thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma, red2white=args.red2white) dsdat.append(_dsdat) np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs) # overwrite else: diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb index 811debc0..4cde3517 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb @@ -60,11 +60,11 @@ "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", - "TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "# TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", - "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", "\n", "# TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", "# TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" @@ -554,7 +554,7 @@ " hc_ss = dat['hc_ss']\n", "\n", " # get sigma for the 0th realization\n", - " psrs, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], dat['fobs_cents'], NPSRS, ret_sig=True,\n", + " psrs, ramp, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], dat['fobs_cents'], NPSRS, ret_sig=True,\n", " red_amp=RED_AMP, red_gamma=RED_GAMMA,\n", " debug=False)\n", " if psrs is not None:\n", diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb index 98440f80..3fc49033 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb @@ -48,7 +48,7 @@ "\n", "NPSRS = 40\n", "NSKIES = 15\n", - "SIGMA = 1e-8\n", + "SIGMA = 1e-10\n", "RED_GAMMA = -3.0\n", "\n", "# TARGET = 'hard_time' # EDIT AS NEEDED\n", @@ -60,11 +60,11 @@ "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", - "TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "# TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", - "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", "\n", "# TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", "# TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 6543d7f5..a3c282a6 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2216,9 +2216,16 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, - red_amp=None, red_gamma=None): + red_amp=None, red_gamma=None, red2white = None): """ Detect pspace model using individual sigma calibration for each realization + Parameters + ---------- + + red2white : scalar or None + Fixed ratio between red and white noise amplitude, if not None. + Otherwise, red noise stays fixed + """ dur = 1.0/fobs_cents[0] cad = 1.0/(2*fobs_cents[-1]) @@ -2250,9 +2257,9 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, real_dur = now # get calibrated psrs - psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, tol=tol, maxbads=maxbads, + psrs, red_amp, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, tol=tol, maxbads=maxbads, sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, - red_amp=red_amp, red_gamma=red_gamma,) + red_amp=red_amp, red_gamma=red_gamma, red2white=red2white) _sigmin /= 2 _sigmax *= 2 + 2e-20 # >1e-20 to make sure it doesnt immediately fail the 0 check @@ -2330,10 +2337,10 @@ def detect_pspace_model_clbrt_ramp(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigm real_dur = now # get calibrated psrs - ramp, _ramp_min, _rampmax = calibrate_one_ramp(hc_bg[:,rr], fobs_cents, npsrs, sigma, + ramp, _ramp_min, _rampmax = calibrate_one_ramp(hc_bg[:,rr], fobs_cents, psrs, tol=tol, maxbads=maxbads, rampstart=_rampstart, rampmin=_rampmin, rampmax=_rampmax, debug=debug, - red_gamma=red_gamma,) + rgam=red_gamma,) _rampstart = ramp _rampmin /= 2 _rampmax *= 2 + 2e-50 # >1e-20 to make sure it doesnt immediately fail the 0 check @@ -2501,7 +2508,7 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, def calibrate_one_pta(hc_bg, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None, ret_sig = False, red_amp=None, red_gamma=None): + phis=None, thetas=None, ret_sig = False, red_amp=None, red_gamma=None, red2white=None): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2524,7 +2531,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigma : float final sigma, returned only if ret_sig=True - TODO: Check if sigma_max hits 0, then return something that essentially says to throw out this model + TODO: Correct ratio from red2white, so that they use the same units/convention! """ # get duration and cadence from fobs @@ -2535,6 +2542,9 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, if phis is None: phis = np.random.uniform(0, 2*np.pi, size = npsrs) if thetas is None: thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) sigma = sigstart + if red2white is not None: + red_amp = sigma/red2white + psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=red_amp, red_gamma=red_gamma)[0] @@ -2545,6 +2555,8 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, # calibrate sigma while np.abs(dp_bg-0.50)>tol: sigma = np.mean([sigmin, sigmax]) # a weighted average would be better + if red2white is not None: + red_amp = sigma * red2white psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=red_amp, red_gamma=red_gamma)[0] @@ -2593,8 +2605,8 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, # print(f"in calibration: {utils.stats(psrs[0].toaerrs)=}, \n{utils.stats(hc_bg)=},\ # {utils.stats(fobs)=}, {dp_bg=}") if ret_sig: - return psrs, sigma, sigmin, sigmax - return psrs + return psrs, red_amp, sigma, sigmin, sigmax + return psrs, red_amp def calibrate_one_ramp(hc_bg, fobs, psrs, rampstart=1e-6, rampmin=1e-9, rampmax=1e-4, debug=False, maxbads=20, tol=0.03, @@ -2621,7 +2633,6 @@ def calibrate_one_ramp(hc_bg, fobs, psrs, redampmax : float, returned only if ret_sig=True maximum of the final sigma range used - TODO: Check if sigma_max hits 0, then return something that essentially says to throw out this model """ # get duration and cadence from fobs From a702e6b9ea415b8b8a3ebfb9b7054d771a9a15e4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 30 Jun 2023 10:32:31 -0700 Subject: [PATCH 213/291] Scale white noise from sigma and cad by red2white to get rednoise in calibrate_one_pta when red2white is not None. --- holodeck/detstats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index a3c282a6..eba82903 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2543,7 +2543,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, if thetas is None: thetas = np.random.uniform(np.pi/2, np.pi/2, size = npsrs) sigma = sigstart if red2white is not None: - red_amp = sigma/red2white + red_amp = _white_noise(cad, sigma) * red2white psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) From 96b44af5151f9126438e2d3ec26b05728ab9c4c5 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 1 Jul 2023 10:42:01 -0700 Subject: [PATCH 214/291] Plot every calibration model. --- .../detect_model_clbrt_pta.py | 4 +- ..._time.ipynb => fullsize_white_noise.ipynb} | 35 +- .../incl_red_noise.ipynb | 31 +- .../incl_red_noise_rampcalibration.ipynb | 12 +- .../incl_red_noise_red2white.ipynb | 637 ++++++++++++++++++ 5 files changed, 690 insertions(+), 29 deletions(-) rename ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/{fullsize_hard_time.ipynb => fullsize_white_noise.ipynb} (91%) create mode 100644 ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_red2white.ipynb diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index d015efea..d344561e 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -178,7 +178,7 @@ def main(): save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' if args.red2white is not None and args.red_gamma is not None: - save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1e}_rg{args.red_gamma:.1f}' + save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' elif args.red_amp is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1f}' if args.red2white is not None and args.red_amp is not None: @@ -217,7 +217,7 @@ def main(): sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma, red2white=args.red2white) dsdat.append(_dsdat) - np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs) # overwrite + np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs, red2white=args.red2white) # overwrite else: print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_white_noise.ipynb similarity index 91% rename from ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb rename to ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_white_noise.ipynb index 54fe4edc..022888a7 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_hard_time.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/fullsize_white_noise.ipynb @@ -47,14 +47,23 @@ "NPSRS = 40\n", "NSKIES = 100\n", "\n", - "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", - "TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", - "\n", "# TARGET = 'hard_time' # EDIT AS NEEDED\n", "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", "\n", + "# TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: $\\psi_0$ ' # EDIT AS NEEDED\n", + "\n", "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", - "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED" + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "\n", + "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" ] }, { @@ -401,8 +410,11 @@ "\n", "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", - "sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", - "cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "\n", + "NODOTS=True\n", + "if NODOTS is False:\n", + " sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.5,)\n", + " cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", "\n", "\n", "print(f\"{xx.shape=}, {yy.shape=}\")\n", @@ -415,8 +427,15 @@ "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", "# fig.tight_layout()\n", "\n", - "# figloc = '/Users/emigardiner/GWs/holodeck/output/figures/params'\n", - "# if SAVEFIG: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))" + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/anatomy_09B'\n", + "# if SAVEFIG and NODOTS: fig.savefig(figloc+'/dpratio_vs_%s_w_mass_%dvars_clbrtd.png' % (TARGET, NVARS))\n", + "# figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", + "if SAVEFIG and NODOTS: \n", + " figname = figloc+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " fig.savefig(figname+'.png' , bbox_inches='tight')\n", + "elif SAVEFIG:\n", + " figname = figloc+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_with_mass.png' \n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" ] }, { diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb index 4cde3517..0d6925e6 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise.ipynb @@ -48,8 +48,8 @@ "\n", "NPSRS = 40\n", "NSKIES = 15\n", - "RED_AMP = None\n", - "RED_GAMMA = None\n", + "RED_AMP = 1e-14\n", + "RED_GAMMA = -1.5\n", "\n", "# TARGET = 'hard_time' # EDIT AS NEEDED\n", "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", @@ -60,11 +60,11 @@ "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "# TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", - "# TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", - "TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", "\n", "# TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", "# TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" @@ -502,11 +502,11 @@ " ylabel=plot.LABEL_CHARACTERISTIC_STRAIN,\n", " figsize=(5,4))\n", "\n", - "if RED_AMP is not None and RED_GAMMA is not None:\n", - " ax.set_title(('$A_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", - " % (RED_AMP, RED_GAMMA, TITLE)))\n", - "else: \n", - " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "# if RED_AMP is not None and RED_GAMMA is not None:\n", + "# ax.set_title(('$A_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + "# % (RED_AMP, RED_GAMMA, TITLE)))\n", + "# else: \n", + "# ax.set_title(f\"White Noise Only, {TITLE}\")\n", " \n", "xx = dat['fobs_cents']*YR\n", "handles=[]\n", @@ -544,7 +544,12 @@ "\n", "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Noise',\n", " figsize=(4,3.5))\n", - "\n", + "if RED_AMP is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$A_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED_AMP, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + " \n", "fobs_cents = data[0]['fobs_cents']\n", "dur = 1.0/fobs_cents[0]\n", "cad = 1.0/(2*fobs_cents[-1])\n", @@ -554,7 +559,7 @@ " hc_ss = dat['hc_ss']\n", "\n", " # get sigma for the 0th realization\n", - " psrs, ramp, sigmin, sigmax, sigma = detstats.calibrate_one_pta(hc_bg[:,0], dat['fobs_cents'], NPSRS, ret_sig=True,\n", + " psrs, ramp, sigma, sigmin, sigmax = detstats.calibrate_one_pta(hc_bg[:,0], dat['fobs_cents'], NPSRS, ret_sig=True,\n", " red_amp=RED_AMP, red_gamma=RED_GAMMA,\n", " debug=False)\n", " if psrs is not None:\n", diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb index 3fc49033..5d85f212 100644 --- a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_rampcalibration.ipynb @@ -63,11 +63,11 @@ "# TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", "# TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", "\n", - "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", - "TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", "\n", - "# TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", - "# TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" + "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" ] }, { @@ -485,7 +485,7 @@ "if SAVEFIG: \n", " figname = figloc+f'/DP_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", " if SIGMA is not None and RED_GAMMA is not None:\n", - " figname = figname+f'sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + " figname = figname+f'_sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", " print(figname)\n", " fig.savefig(figname+'.png' , bbox_inches='tight')" ] @@ -520,7 +520,7 @@ "if SAVEFIG: \n", " figname = figloc+f'/hc_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", " if SIGMA is not None and RED_GAMMA is not None:\n", - " figname = figname+f'sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", + " figname = figname+f'_sig{SIGMA:.1e}_rg{RED_GAMMA:.1f}'\n", " fig.savefig(figname+'.png' , bbox_inches='tight')" ] }, diff --git a/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_red2white.ipynb b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_red2white.ipynb new file mode 100644 index 00000000..ded53708 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk10D_isolate_parameters_detstats/incl_red_noise_red2white.ipynb @@ -0,0 +1,637 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "# CONSTRUCT = False\n", + "# JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "SET_YLIM = SAVEFIG\n", + "# TOL=0.01\n", + "# MAXBADS=5\n", + "\n", + "NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 15\n", + "RED2WHITE = 1.0\n", + "RED_GAMMA = -3\n", + "\n", + "# TARGET = 'hard_time' # EDIT AS NEEDED\n", + "# TITLE = '$\\\\tau_\\mathrm{hard}$ (Gyr)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: $\\psi_0$ ' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'gsmf_mchar0_log10' # EDIT AS NEEDED\n", + "# TITLE = 'GSMF: log($M_\\mathrm{char,0} / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'mmb_mamp_log10' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: log($\\mu / \\mathrm{M}_\\odot$)' # EDIT AS NEEDED\n", + "\n", + "# TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "# TITLE = 'MMB: $\\epsilon_\\mu$ (dex)' # EDIT AS NEEDED\n", + "\n", + "TARGET = 'hard_gamma_inner' # EDIT AS NEEDED\n", + "TITLE = '$\\\\nu_\\mathrm{inner}$ ' # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", + "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "load_dets_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + "load_dets_from_file = load_dets_from_file+f'_r2w{RED2WHITE:.1f}_rg{RED_GAMMA:.1f}'\n", + "load_dets_from_file = load_dets_from_file+'.npz'\n", + "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", + "print(load_data_from_file)\n", + "print(load_dets_from_file)\n", + "if os.path.exists(load_data_from_file) is False:\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "if os.path.exists(load_dets_from_file) is False:\n", + " err = 'load detstats file does not exist.'\n", + " raise Exception(err)\n", + "\n", + "# print(save_data_to_file)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Get Param Names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load(load_data_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "data = file['data']\n", + "params = file['params']\n", + "file.close()\n", + "\n", + "file = np.load(load_dets_from_file, allow_pickle=True)\n", + "print(file.files)\n", + "dsdat = file['dsdat']\n", + "\n", + "file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dat in dsdat:\n", + " print(holo.utils.stats(dat['dp_bg']))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "def draw_skies_vs_bg(ax, skies_ss, dp_bg, label=None,\n", + " color='k', mean=True):\n", + " xx = dp_bg # shape (R,)\n", + " if mean:\n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " else: \n", + " yy = np.mean(skies_ss, axis=-1) # shape (R,)\n", + " yerr = np.std(skies_ss, axis=-1) # shape (R,)\n", + "\n", + " hh = ax.errorbar(xx, yy, yerr, color=color, label=label,\n", + " linestyle='', capsize=3, marker='o', alpha=0.5)\n", + " return hh\n", + "\n", + "def plot_dpss_vs_dpbg(dsdat, params, target_param=TARGET, use_ev=True, title=TITLE):\n", + " colors = cm.rainbow_r(np.linspace(0, 1, len(dsdat)))\n", + " sslabel = 'Expected Number' if use_ev else 'Detection Probability'\n", + " fig, ax = plot.figax(xlabel='Background Detection Probability', \n", + " ylabel='$\\langle$ Single Source %s} $\\\\rangle_\\mathrm{skies}$' % sslabel,\n", + " ) #xscale='linear', yscale='linear')\n", + " handles = []\n", + " for ii, ds in enumerate(dsdat):\n", + " label = '%.2f' % params[ii][target_param]\n", + " detss = ds['ev_ss'] if use_ev else ds['dp_ss']\n", + " hh = draw_skies_vs_bg(ax, detss, ds['dp_bg'], color=colors[ii], label=label)\n", + " handles.append(hh)\n", + " ax.legend(handles=handles, loc = 'lower left', title=title,\n", + " ncols=4, title_fontsize=12)\n", + "\n", + " fig.tight_layout()\n", + " return fig\n", + "\n", + "text = 'GSMF: $\\psi_0=%.2f, m_{\\phi,0}=%.2f$' % ((params[0]['gsmf_phi0']), (params[0]['gsmf_mchar0_log10']))\n", + "text = text+'\\nMMB: $\\mu = %.2f, \\epsilon_\\mu=%2f$ dex' % (params[0]['mmb_mamp_log10'], params[0]['mmb_scatter_dex'])\n", + "text = text+'\\n$da/dt: \\gamma_\\mathrm{inner}=%.2f, \\\\tau_\\mathrm{hard}=%.2f$' % (params[0]['hard_time'], 2.5)\n", + "print(text)\n", + "\n", + "\n", + "\n", + "\n", + "fig1 = plot_dpss_vs_dpbg(dsdat, params, use_ev=True)\n", + "fig1.axes[0].text(0.99,0.01, text, transform=fig1.axes[0].transAxes, verticalalignment='bottom', horizontalalignment='right')\n", + "fig1.tight_layout()\n", + "\n", + "\n", + "\n", + "fig2 = plot_dpss_vs_dpbg(dsdat, params, use_ev=False)\n", + "fig2.axes[0].text(0.99,0.99, text, transform=fig1.axes[0].transAxes, verticalalignment='top', horizontalalignment='right')\n", + "fig2.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "# colors = cm.rainbow_r(np.linspace(0, 1, len(params)))\n", + "\n", + "\n", + "# fig, ax = plot.figax(xscale='linear',)\n", + "# ax.set_ylabel(ylabel, fontsize=14)\n", + "# ax.set_xlabel(xlabel, fontsize=14)\n", + "\n", + "# target=TARGET\n", + "# xx = []\n", + "# yy = []\n", + "# for ii, par in enumerate(params):\n", + "# xx.append(params[ii][target])\n", + "# dp_bg = dsdat[ii]['dp_bg']\n", + "# dp_ss = np.mean(dsdat[ii]['dp_ss'], axis=-1)\n", + "# yy.append(dp_ss/dp_bg)\n", + "# for rr in range(len(yy[0])):\n", + "# ax.scatter(xx[ii], yy[ii][rr], color=colors[ii], alpha=0.5)\n", + "# xx = np.array(xx)\n", + "# yy = np.array(yy)\n", + "# print(yy.shape)\n", + "# # for rr, yi in enumerate(yy):\n", + "# # ax.scatter(xx,yy[:,rr])\n", + "# plot.draw_med_conf(ax, xx, yy)\n", + "# # for rr in range(len(yy[0])):\n", + "# # ax.scatter(xx,yy[:,rr], alpha=0.5, color=colors[])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Could do the same, but vary another model parameter for color, or show some other parameter" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Mass Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # Get SS mass normalization\n", + "# use_snr=False\n", + "# # ssmtot = []\n", + "# # ss_dp = []\n", + "# if use_snr:\n", + "# mt_hisnr= np.zeros((NVARS, NREALS))\n", + "# for ii,dat in enumerate(data):\n", + "# # ssmtot.append(dat['sspar'][0])\n", + "# snr_ss = dsdat[ii]['snr_ss'] # (F,R,S,L)\n", + "# # print(snr_ss.shape)\n", + "# ssmtot = dat['sspar'][0]\n", + "# # print(ssmtot.shape)\n", + "# # for each realization, find the frequency with the loudest single source\n", + "# for rr in range(len(snr_ss[0])):\n", + "# argmax = np.argmax(snr_ss[:,rr,:,:])\n", + "# fidx, sidx, lidx = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + "# # print(f\"{fidx=}, {rr=}, {sidx=}, {lidx=}\")\n", + "# mt_hisnr[ii,rr] = ssmtot[fidx, rr, lidx]\n", + "\n", + "# mt_hisnr = np.log10(mt_hisnr/MSOL)\n", + "# vmin = np.min(mt_hisnr)\n", + "# vmax = np.max(mt_hisnr)\n", + "# norm = mpl.colors.Normalize(vmin=vmin, vmax=vmax)\n", + "\n", + "# # print(f\"{vmin=}, {vmax=}\")\n", + "# # print(mt_hisnr.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Any Normalization" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "#### use mass of max-DP single source for each realization\n", + "norm_by_maxDPmass = True\n", + "if norm_by_maxDPmass:\n", + " normcol = np.zeros((NVARS, NREALS))\n", + " for ii, dat in enumerate(data):\n", + " gamma_ssi = dsdat[ii]['gamma_ssi'] # (F,R,S,L)\n", + " ssmtot = dat['sspar'][0] # (F,R,L)\n", + " # for each realization, find the frequency, sky, and loudest with the loudest single source\n", + " for rr in range(NREALS):\n", + " argmax = np.argmax(gamma_ssi[:,rr,:,:])\n", + " ff, ss, ll = np.unravel_index(argmax, (NFREQS, NSKIES, NLOUDEST))\n", + " normcol[ii,rr] = ssmtot[ff,rr,ll]\n", + " normcol = np.log10(normcol/MSOL)\n", + "\n", + "#### could include other colorbar options here, to set normcol values\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(normcol), vmax=np.max(normcol))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Normalize with individual gamma ssi" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "cc = np.zeros((NVARS, NREALS, NSKIES))\n", + "for ii, dat in enumerate(data):\n", + " for rr in range(NREALS):\n", + " for ss in range(NSKIES):\n", + " argmax = np.argmax(dsdat[ii]['gamma_ssi'][:,rr,ss,:])\n", + " fidx, lidx = np.unravel_index(argmax, shape=(NFREQS, NLOUDEST))\n", + " cc[ii,rr,ss] = np.log10(dat['sspar'][0,fidx,rr,lidx]/MSOL)\n", + "\n", + "norm = mpl.colors.Normalize(vmin=np.min(cc), vmax=np.max(cc))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plot ratio vs freq" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "\n", + "xlabel=TITLE\n", + "# ylabel='$\\gamma_\\mathrm{SS}/\\gamma_\\mathrm{BG}$'\n", + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "clabel = '$\\log M / [\\mathrm{M}_\\odot] $)'\n", + "cmap = cm.rainbow\n", + "\n", + "fig, ax = plot.figax(xscale='linear', figsize=(4,3.5))\n", + "ax.set_ylabel(ylabel, fontsize=14)\n", + "ax.set_xlabel(xlabel, fontsize=14)\n", + "ax.set_xlim(params[0][TARGET]-0.2, params[NVARS-1][TARGET]+0.05)\n", + "if SET_YLIM: ax.set_ylim(10**-3, 10**1)\n", + "if RED2WHITE is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$S_\\mathrm{red}/S_\\mathrm{white}=%.2f$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED2WHITE, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "\n", + "target=TARGET\n", + "xx = []\n", + "yy = []\n", + "for ii, par in enumerate(params):\n", + " xx.append(params[ii][target])\n", + " dp_bg = np.repeat(dsdat[ii]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[ii]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + " # for rr in range(len(yy[0])):\n", + "\n", + "x1= np.array(xx)\n", + "yy = np.array(yy)\n", + "\n", + "xx = np.repeat(x1, NREALS*NSKIES).reshape(NVARS, NREALS, NSKIES)\n", + "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", + "# sax = ax.scatter(xx, yy, c=cc, cmap=cmap, norm=norm, alpha=0.2,)\n", + "# cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", + "\n", + "\n", + "print(f\"{xx.shape=}, {yy.shape=}\")\n", + "\n", + "col = 'tab:blue'\n", + "for pp in [50, 95]:\n", + " med, *conf = np.percentile(yy, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(x1, med, alpha=0.5, color=col)\n", + " ax.fill_between(x1, *conf, color=col, alpha=0.25)\n", + "# cbar = fig.colorbar(mpl.cm.ScalarMappable(norm=norm, cmap=cmap), label='log ($M(\\mathrm{max\\ EV_\\mathrm{SS}}) / [\\mathrm{M}_\\odot]$)',)\n", + "# fig.tight_layout()\n", + "fig.tight_layout()\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", + "if SAVEFIG: \n", + " figname = figloc+f'/ratio_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED2WHITE is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_r2w{RED2WHITE:.1f}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Individual detprobs" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability',\n", + " figsize=(4,3.5))\n", + "if RED2WHITE is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$S_\\mathrm{red}/S_\\mathrm{white}=%.2f$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED2WHITE, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "ax.set_ylim(1e-6, 2e0)\n", + "xx = data[0]['fobs_cents']*YR\n", + "label1 = 'BG DP'\n", + "label2 = '1st Loudest DP, for each sky+strain realization'\n", + "label3 = 'Total SS DP, for each sky realization'\n", + "\n", + "handles = []\n", + "for ii, dsd in enumerate(dsdat):\n", + " y1 = dsd['dp_bg'][0] # 1\n", + " y2 = dsd['gamma_ssi'][:,:,:,0].reshape(NFREQS, NREALS*NSKIES) # F, S\n", + " y3 = dsd['dp_ss']\n", + " y3 = np.repeat(y3, NFREQS).reshape(NREALS*NSKIES, NFREQS)\n", + " y3 = np.swapaxes(y3, 0, 1)\n", + "\n", + " h1 = ax.axhline(y1)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color=colors[ii])\n", + " # for ss in range(NSKIES*NREALS):\n", + " h3 = plot.draw_med_conf_color(ax, xx, y3, color=colors[ii])\n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "\n", + "leg1 = ax.legend(handles=[h1,h2,h3], labels=[label1, label2, label3], loc='upper right',\n", + " fontsize=7)\n", + "leg2 = ax.legend(handles=handles, title=TITLE, loc='lower right')\n", + "ax.add_artist(leg1, )\n", + "fig.tight_layout()\n", + "\n", + "figloc = '/Users/emigardiner/GWs/holodeck/output/figures/red_noise'\n", + "if SAVEFIG: \n", + " figname = figloc+f'/DP_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED2WHITE is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_r2w{RED2WHITE:.1f}_rg{RED_GAMMA:.1f}'\n", + " print(figname)\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':10})\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR,\n", + " ylabel=plot.LABEL_CHARACTERISTIC_STRAIN,\n", + " figsize=(5,4))\n", + "\n", + "# if SIGMA is not None and RED_GAMMA is not None:\n", + "# ax.set_title(('$\\sigma_\\mathrm{red}+%.2e$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + "# % (SIGMA, RED_GAMMA, TITLE)))\n", + "# else: \n", + "# ax.set_title(f\"White Noise Only, {TITLE}\")\n", + " \n", + "xx = dat['fobs_cents']*YR\n", + "handles=[]\n", + "for ii, dat in enumerate(data):\n", + " plot.draw_ss_and_gwb(ax, xx, dat['hc_ss'], dat['hc_bg'], color=colors[ii],\n", + " nsamp=2) \n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "ax.legend(handles=handles, loc='lower left', title=TITLE)\n", + "\n", + "if SAVEFIG: \n", + " figname = figloc+f'/hc_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED2WHITE is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_r2w{RED2WHITE:.1e}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Noise" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "mpl.rcParams.update({'font.size':8})\n", + "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Noise',\n", + " figsize=(4,3.5))\n", + "if RED2WHITE is not None and RED_GAMMA is not None:\n", + " ax.set_title(('$S_\\mathrm{red}/S_\\mathrm{white}=%.2f$, $\\gamma_\\mathrm{red}=%.2f$, %s'\n", + " % (RED2WHITE, RED_GAMMA, TITLE)))\n", + "else: \n", + " ax.set_title(f\"White Noise Only, {TITLE}\")\n", + "\n", + "fobs_cents = data[0]['fobs_cents']\n", + "dur = 1.0/fobs_cents[0]\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "# psrs = detstats._build_pta(NPSRS, SIGMA, dur, cad)\n", + "\n", + "xx = fobs_cents*YR\n", + "for ii, dat in enumerate(data):\n", + " hc_bg = dat['hc_bg']\n", + " hc_ss = dat['hc_ss']\n", + "\n", + " # get sigma for the 0th realization\n", + " psrs, ramp, sigma, sigmin, sigmax, = detstats.calibrate_one_pta(hc_bg[:,0], dat['fobs_cents'], NPSRS, ret_sig=True,\n", + " red_gamma=RED_GAMMA, red2white=RED2WHITE,\n", + " debug=False)\n", + " if psrs is not None:\n", + " sigmas = np.ones(NPSRS)*sigma\n", + "\n", + " rr=0\n", + " y1 = detstats._total_noise(cad, sigmas, hc_ss[:,rr:rr+1], hc_bg[:,rr:rr+1], fobs_cents,\n", + " red_amp=ramp, red_gamma=RED_GAMMA)[0,:,:,0]\n", + " y2 = detstats._power_spectral_density(hc_ss[:,rr:rr+1,0], fobs_cents)\n", + " # y3 = detstats._white_noise(cad, sigmas) # (P,)\n", + " # y4 = detstats._red_noise(RED_AMP, RED_GAMMA, fobs_cents) # (F,)\n", + " print(f\"{y1.shape=}, {y2.shape=}\")\n", + " label1 = 'total noise'\n", + " label2 = 'hc-rest noise'\n", + " # label3 = 'white noise'\n", + " # label4 = 'red noise'\n", + " h1 = plot.draw_med_conf_color(ax, xx, y1, color=colors[ii])\n", + " h2 = ax.plot(xx, y2, color=colors[ii], linestyle='--')\n", + " # h3 = ax.axhline(y3[0], linestyle='--', color='k', alpha=0.5)\n", + " # h4, = ax.plot(xx, y4, color='tab:red', linestyle='--')\n", + "\n", + "\n", + " # ax.legend(handles=[h1, h2, h3, h4], \n", + " # labels=[label1, label2, label3, label4])\n", + "# ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + "# transform=ax.transAxes)\n", + " \n", + "handles = [mpl.lines.Line2D([0], [0], label='total noise', linestyle='-'), mpl.lines.Line2D([0], [0], label='hc_rest noise', linestyle='--')]\n", + "leg1 = ax.legend(handles=handles, loc='lower left', )\n", + "\n", + "handles=[]\n", + "for ii, dat in enumerate(data):\n", + " handles.append(\n", + " mpl.lines.Line2D([0], [0], label=f\"{params[ii][TARGET]:.2f}\", color=colors[ii])\n", + " )\n", + "leg2 = ax.legend(handles=handles, bbox_to_anchor=(0,.15), title=TITLE, loc='lower left')\n", + "ax.add_artist(leg1)\n", + "if SAVEFIG: \n", + " figname = figloc+f'/noise_vs_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ds' \n", + " if RED2WHITE is not None and RED_GAMMA is not None:\n", + " figname = figname+f'_r2w{RED2WHITE:.1f}_rg{RED_GAMMA:.1f}'\n", + " fig.savefig(figname+'.png' , bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 1710331817e40d70bf54d5fd352645efe0c1d2d9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 1 Jul 2023 12:32:58 -0700 Subject: [PATCH 215/291] Plot white noise and r2w calibration models for 6 params on one figure, using v6 for now. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 480 ++++++++++++++++++ 1 file changed, 480 insertions(+) create mode 100644 ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb new file mode 100644 index 00000000..89b9db79 --- /dev/null +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -0,0 +1,480 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Set up" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "# NREALS = 500\n", + "NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "# NVARS = 21\n", + "NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "# NSKIES = 100\n", + "NSKIES = 15" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get param names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get data and dets file functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + "):\n", + "\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat\n", + "\n", + "def get_ratio_arrays(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " ):\n", + " filename = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ratio_arrays.npz'\n", + " file = np.load(filename)\n", + " xx = file['xx_params']\n", + " y0p0 = file['yy_ratio']\n", + " y1p5 = file['y1p5_ratio']\n", + " y3p0 = file['y3p0_ratio']\n", + " return xx, y0p0, y1p5, y3p0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "BUILD_ARRAYS=True\n", + "if BUILD_ARRAYS:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " for target in targets:\n", + " print(target)\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target)\n", + " xx=[]\n", + " yy=[]\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -1.5\n", + " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " y1p5=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y1p5.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -3.0\n", + " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + " y3p0=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y3p0.append(dp_ss/dp_bg)\n", + "\n", + " \n", + " np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", + " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if BUILD_ARRAYS:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex']#, 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " for target in targets:\n", + " print(target)\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target,)\n", + " xx=[]\n", + " yy=[]\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -1.5\n", + " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " y1p5=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y1p5.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -3.0\n", + " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + " y3p0=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y3p0.append(dp_ss/dp_bg)\n", + "\n", + " \n", + " np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", + " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#e67739', '#35b6e0',\n", + " '#4da169', '#e67739', '#35b6e0',\n", + "]\n", + "col3p0 = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " col=col0p0[ii]\n", + " # for pp in [50, 95]:\n", + " for pp in [68]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "\n", + "fig.tight_layout()\n", + "\n", + "SAVEFIG=True\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#e67739', '#35b6e0',\n", + " '#4da169', '#e67739', '#35b6e0',\n", + "]\n", + "col3p0 = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "\n", + "fig.tight_layout()\n", + "\n", + "SAVEFIG=True\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# FUll Size" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# NSKIES = 15" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "BUILD_ARRAYS=True\n", + "if BUILD_ARRAYS:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex'] #, 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " for target in targets:\n", + " print(target)\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target)\n", + " xx=[]\n", + " yy=[]\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -1.5\n", + " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " y1p5=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y1p5.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -3.0\n", + " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + " y3p0=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y3p0.append(dp_ss/dp_bg)\n", + "\n", + " \n", + " np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", + " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel1 = plot.LABEL_CHARACTERISTIC_STRAIN\n", + "ylabel2 = plot.LABEL_CHARACTERISTIC_STRAIN\n", + "xlabel1 = plot.LABEL_GW_FREQUENCY_YR\n", + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", + " 'hard_time', 'hard_gamma_inner']\n", + "\n", + "fig, axs = plot.figax_double(ncols=6, nrows=2, height=5)\n", + "\n", + "# for ii, target in enumerate(targets): # first row\n", + "# data, params, dets = get_data(target)\n", + "\n", + "# axs[0,ii].set_xlabel(xlabel1)\n", + "# axs[1,ii].set_xlabel(plot.PARAM_KEYS[target])\n", + "# if ii == 0:\n", + "# axs[0,ii].set_ylabel(ylabel1)\n", + "# axs[1,ii].set_ylabel(ylabel2)\n", + "# else:\n", + "# axs[0,ii].sharey(axs[0,0])\n", + "# axs[1,ii].sharey(axs[1,0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 2221af4eda04c51bbd3a1d157c2a9da238ea0f54 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 1 Jul 2023 12:36:44 -0700 Subject: [PATCH 216/291] Correct typo in _rampmin. --- holodeck/detstats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index eba82903..3a5b60bf 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2337,7 +2337,7 @@ def detect_pspace_model_clbrt_ramp(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigm real_dur = now # get calibrated psrs - ramp, _ramp_min, _rampmax = calibrate_one_ramp(hc_bg[:,rr], fobs_cents, psrs, + ramp, _rampmin, _rampmax = calibrate_one_ramp(hc_bg[:,rr], fobs_cents, psrs, tol=tol, maxbads=maxbads, rampstart=_rampstart, rampmin=_rampmin, rampmax=_rampmax, debug=debug, rgam=red_gamma,) From de3cef87f06cfbbb256df70cf7d851ac050963d7 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 1 Jul 2023 15:04:26 -0700 Subject: [PATCH 217/291] Plot parameters for the midvar data. Find nan for all bg distances and separations. --- ecg-notebooks/paper_plots/charstrain.ipynb | 319 +++++++++++++++++++++ 1 file changed, 319 insertions(+) create mode 100644 ecg-notebooks/paper_plots/charstrain.ipynb diff --git a/ecg-notebooks/paper_plots/charstrain.ipynb b/ecg-notebooks/paper_plots/charstrain.ipynb new file mode 100644 index 00000000..28f68524 --- /dev/null +++ b/ecg-notebooks/paper_plots/charstrain.ipynb @@ -0,0 +1,319 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# NSKIES = 15" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + "):\n", + "\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " # if red_gamma is not None and red2white is not None:\n", + " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " # load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " # if os.path.exists(load_dets_from_file) is False:\n", + " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " # raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data'][int(NVARS/2)]\n", + " params = file['params'][int(NVARS/2)]\n", + " file.close()\n", + "\n", + " # file = np.load(load_dets_from_file, allow_pickle=True)\n", + " # dsdat = file['dsdat']\n", + " # file.close()\n", + "\n", + " return data, params" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data, params = get_data('hard_time')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ss = data['hc_ss']\n", + "hc_bg = data['hc_bg']\n", + "sspar = data['sspar']\n", + "bgpar = data['bgpar']\n", + "fobs_cents = data['fobs_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "edgecolors = np.repeat(None, NLOUDEST)\n", + "edgecolors[0] = 'k'\n", + "print(edgecolors)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(colors.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax_single(\n", + " xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "\n", + "\n", + "nsamp = 5 # number of sample GWB spectra to plot\n", + "\n", + "xx = fobs_cents * YR\n", + "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", + "\n", + "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", + "\n", + "# Plot the median GWB spectrum\n", + "ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", + "\n", + "\n", + "\n", + "# Plot `nsamp` random spectra \n", + "seed = 67233 # more spread out\n", + "# seed = 98068 # includes random super high\n", + "# seed = np.random.randint(99999) # get a random number\n", + "print(seed) # print it out so we can reuse it if desired\n", + "np.random.seed(seed) # set the random seed\n", + "\n", + "nsamp = np.min([nsamp, NREALS])\n", + "\n", + "colors = [\n", + " '#6a3d9a', # purple\n", + " '#ff7f0f', # orange\n", + " '#15becf', # teal\n", + " '#f0027f', # pink\n", + " '#a6d853', # green\n", + "]\n", + "\n", + "# select random realizations to plot\n", + "idx = np.random.choice(NREALS, nsamp, replace=False)\n", + "for aa, ii in enumerate(idx):\n", + "\n", + " # edgecolors = np.repeat(colors[aa], NLOUDEST).reshape(4, NLOUDEST) # idk why this isnt working\n", + " # edgecolors = np.swapaxes(edgecolors, 0,1)\n", + " # edgecolors[0,:] = np.array([1, 1, 1, 1])\n", + "\n", + " for ll in range(5):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor)\n", + "\n", + "for aa, ii in enumerate(idx):\n", + " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[aa]) \n", + "\n", + "fig.tight_layout()\n", + "# fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_midvars_{seed}.png', dpi=100)\n", + "\n", + "# plot contours at 50% and 98% confidence intervals\n", + "for pp in [50, 98]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", + " \n", + "# plt.show()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# all parameters" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sings.par_labels)\n", + "\n", + "bgpar = data['bgpar']\n", + "sspar = data['sspar']\n", + "sspar = sings.all_sspars(fobs_cents, sspar)\n", + "\n", + "bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + "sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharex=True)\n", + "\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "# Plot `nsamp` random spectra \n", + "seed = 67233 # more spread out\n", + "# seed = np.random.randint(99999) # get a random number\n", + "print(seed) # print it out so we can reuse it if desired\n", + "np.random.seed(seed) # set the random seed\n", + "\n", + "# select random realizations to plot\n", + "idx = np.random.choice(NREALS, nsamp, replace=False)\n", + "\n", + "# parameters to plot\n", + "yy_ss = [hc_ss, sspar[0], sspar[1], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4], sspar[5], sspar[6]] # final comoving distance, final separation, final angular separation\n", + "yy_bg = [hc_bg, bgpar[0], bgpar[1], # strain, mass, mass ratio, initial redshift\n", + " bgpar[4], bgpar[5], bgpar[6]]\n", + "ylabels = np.append([plot.LABEL_CHARACTERISTIC_STRAIN,], sings.par_labels)\n", + "ylabels = ['Characteristic Strain, $h_c$', 'Total Mass, $M_\\mathrm{tot}$ [M$_\\odot$]', 'Mass Ratio, $q$', \n", + " 'Comoving Distance, $d_\\mathrm{com}$ [Mpc]', 'Separation [pc]', 'Separation [rad]']\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " ax.plot(xx, np.median(yy_bg[ii], axis=-1), 'k-')\n", + "\n", + " # Plot the confidence intervals\n", + " for pp in [50, 95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[ii], percs, axis=-1), alpha=0.25, color='k')\n", + "\n", + " # label axes\n", + " if ii>=3:\n", + " ax.set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " ax.set_ylabel(ylabels[ii])\n", + " \n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(holo.utils.stats(sspar[3]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx = np.linspace(0,20,100)\n", + "xx[5] = np.nan\n", + "\n", + "print(np.sum(xx))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From d082b4d8ad0d73438b94d42749185b476aad2e63 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 1 Jul 2023 15:58:46 -0700 Subject: [PATCH 218/291] Troubleshooting nan pars and negative redz. --- ecg-notebooks/paper_plots/charstrain.ipynb | 9 -- .../parameter_investigation/neg_redz2.ipynb | 87 +++++++++++++++++++ .../negative_redz.ipynb | 49 ++++------- 3 files changed, 105 insertions(+), 40 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/neg_redz2.ipynb diff --git a/ecg-notebooks/paper_plots/charstrain.ipynb b/ecg-notebooks/paper_plots/charstrain.ipynb index 28f68524..181bd5e5 100644 --- a/ecg-notebooks/paper_plots/charstrain.ipynb +++ b/ecg-notebooks/paper_plots/charstrain.ipynb @@ -119,15 +119,6 @@ "print(edgecolors)" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(colors.shape)" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb new file mode 100644 index 00000000..d7cbe9a6 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb @@ -0,0 +1,87 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "\n", + "import h5py\n", + "\n", + "\n", + "from holodeck import plot, detstats, utils\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents, fobs_edges = utils.pta_freqs()\n", + "sam = holo.sams.Semi_Analytic_Model(shape=30)\n", + "hard = holo.hardening.Fixed_Time_2PL_SAM(sam=sam, time=3*GYR)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(fobs_edges, hard, realize=10, loudest=5, params=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, par in enumerate(bgpar):\n", + " print(f\"{sings.par_names[ii]}, {utils.stats(par)}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/negative_redz.ipynb b/ecg-notebooks/parameter_investigation/negative_redz.ipynb index 518bd6f4..063de952 100644 --- a/ecg-notebooks/parameter_investigation/negative_redz.ipynb +++ b/ecg-notebooks/parameter_investigation/negative_redz.ipynb @@ -13,10 +13,11 @@ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import matplotlib.cm as cm\n", + "\n", "import h5py\n", "\n", "\n", - "from holodeck import plot, detstats\n", + "from holodeck import plot, detstats, utils\n", "import holodeck.single_sources as sings\n", "from holodeck.constants import YR, MSOL, MPC, GYR\n", "import holodeck as holo\n", @@ -96,9 +97,9 @@ "metadata": {}, "outputs": [], "source": [ - "\n", + "sam = holo.sams.Semi_Analytic_Model(shape=30)\n", "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", - " fobs_gw_edges=data['fobs_edges'], hard=holo.hardening.Fixed_Time_2PL_SAM(sam,3*GYR),\n", + " fobs_gw_edges=utils.pta_freqs()[1], hard=holo.hardening.Fixed_Time_2PL_SAM(sam,3*GYR),\n", " params=True, loudest=NLOUDEST, realize=NREALS, )\n", "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n" @@ -112,7 +113,7 @@ "source": [ "\n", "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", - " fobs_gw_edges=data['fobs_edges'], hard=holo.hardening.Fixed_Time_2PL_SAM(sam,5.5*GYR),\n", + " fobs_gw_edges=utils.pta_freqs()[1], hard=holo.hardening.Fixed_Time_2PL_SAM(sam,5.5*GYR),\n", " params=True, loudest=NLOUDEST, realize=NREALS, )\n", "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n" @@ -133,6 +134,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -170,13 +172,7 @@ "metadata": {}, "outputs": [], "source": [ - "sam = holo.sams.Semi_Analytic_Model(shape=15)\n", - "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", - " fobs_gw_edges=fobs_gw_edges, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR),\n", - " params=True)\n", - "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", - "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n", - "print(np.where(np.logical_and(sspar[3]<0, sspar[3] != -1)))" + "print(holo.utils.stats(bgpar[-1]))" ] }, { @@ -185,10 +181,13 @@ "metadata": {}, "outputs": [], "source": [ - "arr = np.random.uniform(-5, 5, 3*4).reshape(3,4)\n", - "arr[0,0]=-1\n", - "arr[2,2]=-1\n", - "print(arr)" + "sam = holo.sams.Semi_Analytic_Model(shape=15)\n", + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(\n", + " fobs_gw_edges=fobs_gw_edges, hard=holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR),\n", + " params=True)\n", + "print('%d out of %d' % (np.sum(sspar[2]<0), sspar[3].size))\n", + "print('%d out of %d' % (np.sum(bgpar[2]<0), bgpar[3].size))\n", + "print(np.where(np.logical_and(sspar[3]<0, sspar[3] != -1)))" ] }, { @@ -197,12 +196,8 @@ "metadata": {}, "outputs": [], "source": [ - "t1 = arr>0\n", - "t2 = arr==-1\n", - "print(t1,'\\n', t2)\n", - "either = np.logical_or(t1, t2)\n", - "print(either)\n", - "\n" + "for ii, par in enumerate(bgpar):\n", + " print(f\"{sings.par_names[ii]}, {utils.stats(par)}\")" ] }, { @@ -211,18 +206,10 @@ "metadata": {}, "outputs": [], "source": [ - "either = np.logical_or(arr>0, arr==-1)\n", - "neither = np.logical_not(either)\n", - "print(either)\n", - "if np.any(neither):\n", - " print(np.sum(neither))" + "xx = np.array([0,5,np.nan,10])\n", + "print(np.any(np.isnan(xx)))" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [] - }, { "cell_type": "code", "execution_count": null, From 39c2b129ac4280065f69b1eabe99067de913f047 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 2 Jul 2023 00:54:47 -0700 Subject: [PATCH 219/291] Plot ratio vs varpars for 21 vars, 500 reals. --- ecg-notebooks/paper_plots/charstrain.ipynb | 9 + .../paper_plots/ratio_and_hc_varpar.ipynb | 216 +++++------------- 2 files changed, 63 insertions(+), 162 deletions(-) diff --git a/ecg-notebooks/paper_plots/charstrain.ipynb b/ecg-notebooks/paper_plots/charstrain.ipynb index 181bd5e5..68f4b134 100644 --- a/ecg-notebooks/paper_plots/charstrain.ipynb +++ b/ecg-notebooks/paper_plots/charstrain.ipynb @@ -278,6 +278,15 @@ "print(np.sum(xx))" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.linspace(0,1,2))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 89b9db79..4dd89db1 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -41,22 +41,22 @@ "outputs": [], "source": [ "SHAPE = None\n", - "# NREALS = 500\n", - "NREALS = 20\n", + "NREALS = 500\n", + "# NREALS = 20\n", "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "BUILD_ARRAYS = False\n", + "BUILD_ARRAYS = True\n", "SAVEFIG = False\n", "TOL=0.01\n", "MAXBADS=5\n", "\n", - "# NVARS = 21\n", - "NVARS = 6\n", + "NVARS = 21\n", + "# NVARS = 6\n", "\n", "NPSRS = 40\n", - "# NSKIES = 100\n", - "NSKIES = 15" + "NSKIES = 100\n", + "# NSKIES = 15" ] }, { @@ -138,7 +138,6 @@ "metadata": {}, "outputs": [], "source": [ - "BUILD_ARRAYS=True\n", "if BUILD_ARRAYS:\n", " targets = [\n", " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", @@ -184,43 +183,43 @@ "metadata": {}, "outputs": [], "source": [ - "if BUILD_ARRAYS:\n", - " targets = [\n", - " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", - " 'gsmf_mchar0_log10', 'mmb_scatter_dex']#, 'hard_gamma_inner']\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", - " for target in targets:\n", - " print(target)\n", - "\n", - " # white noise only\n", - " data, params, dsdat = get_data(target,)\n", - " xx=[]\n", - " yy=[]\n", - " for pp, par in enumerate(params):\n", - " xx.append(params[pp][target])\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " yy.append(dp_ss/dp_bg)\n", - "\n", - " # red_gamma = -1.5\n", - " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", - " y1p5=[]\n", - " for pp, par in enumerate(params):\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " y1p5.append(dp_ss/dp_bg)\n", - "\n", - " # red_gamma = -3.0\n", - " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", - " y3p0=[]\n", - " for pp, par in enumerate(params):\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " y3p0.append(dp_ss/dp_bg)\n", + "# if BUILD_ARRAYS:\n", + "# targets = [\n", + "# 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + "# 'gsmf_mchar0_log10', 'mmb_scatter_dex']#, 'hard_gamma_inner']\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + "# for target in targets:\n", + "# print(target)\n", + "\n", + "# # white noise only\n", + "# data, params, dsdat = get_data(target,)\n", + "# xx=[]\n", + "# yy=[]\n", + "# for pp, par in enumerate(params):\n", + "# xx.append(params[pp][target])\n", + "# dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + "# dp_ss = dsdat[pp]['ev_ss']\n", + "# yy.append(dp_ss/dp_bg)\n", + "\n", + "# # red_gamma = -1.5\n", + "# data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + "# y1p5=[]\n", + "# for pp, par in enumerate(params):\n", + "# dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + "# dp_ss = dsdat[pp]['ev_ss']\n", + "# y1p5.append(dp_ss/dp_bg)\n", + "\n", + "# # red_gamma = -3.0\n", + "# data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + "# y3p0=[]\n", + "# for pp, par in enumerate(params):\n", + "# dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + "# dp_ss = dsdat[pp]['ev_ss']\n", + "# y3p0.append(dp_ss/dp_bg)\n", "\n", " \n", - " np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", - " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + "# np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", + "# xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" ] }, { @@ -234,16 +233,16 @@ " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", "col0p0 = [\n", - " '#8fcf91', '#fda363', '#38cbff',\n", - " '#8fcf91', '#fda363', '#38cbff',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", "]\n", "col1p5 = [\n", " '#4da169', '#e67739', '#35b6e0',\n", " '#4da169', '#e67739', '#35b6e0',\n", "]\n", "col3p0 = [\n", - " '#336948', '#9e5c41', '#2d839f',\n", - " '#336948', '#9e5c41', '#2d839f',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", "]\n", "\n", "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", @@ -274,10 +273,10 @@ "\n", "fig.tight_layout()\n", "\n", - "SAVEFIG=True\n", + "SAVEFIG=False\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50.png'\n", " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] @@ -293,16 +292,16 @@ " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", "col0p0 = [\n", - " '#8fcf91', '#fda363', '#38cbff',\n", - " '#8fcf91', '#fda363', '#38cbff',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", "]\n", "col1p5 = [\n", " '#4da169', '#e67739', '#35b6e0',\n", " '#4da169', '#e67739', '#35b6e0',\n", "]\n", "col3p0 = [\n", - " '#336948', '#9e5c41', '#2d839f',\n", - " '#336948', '#9e5c41', '#2d839f',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", "]\n", "\n", "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", @@ -333,121 +332,14 @@ "\n", "fig.tight_layout()\n", "\n", - "SAVEFIG=True\n", + "SAVEFIG=False\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", - " savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# FUll Size" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "SHAPE = None\n", - "NREALS = 500\n", - "# NREALS = 20\n", - "NFREQS = 40\n", - "NLOUDEST = 10\n", - "\n", - "BUILD_ARRAYS = False\n", - "SAVEFIG = False\n", - "TOL=0.01\n", - "MAXBADS=5\n", - "\n", - "NVARS = 21\n", - "# NVARS = 6\n", - "\n", - "NPSRS = 40\n", - "NSKIES = 100\n", - "# NSKIES = 15" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "BUILD_ARRAYS=True\n", - "if BUILD_ARRAYS:\n", - " targets = [\n", - " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", - " 'gsmf_mchar0_log10', 'mmb_scatter_dex'] #, 'hard_gamma_inner']\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", - " for target in targets:\n", - " print(target)\n", - "\n", - " # white noise only\n", - " data, params, dsdat = get_data(target)\n", - " xx=[]\n", - " yy=[]\n", - " for pp, par in enumerate(params):\n", - " xx.append(params[pp][target])\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " yy.append(dp_ss/dp_bg)\n", - "\n", - " # red_gamma = -1.5\n", - " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", - " y1p5=[]\n", - " for pp, par in enumerate(params):\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " y1p5.append(dp_ss/dp_bg)\n", - "\n", - " # red_gamma = -3.0\n", - " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", - " y3p0=[]\n", - " for pp, par in enumerate(params):\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " y3p0.append(dp_ss/dp_bg)\n", - "\n", - " \n", - " np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", - " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ylabel1 = plot.LABEL_CHARACTERISTIC_STRAIN\n", - "ylabel2 = plot.LABEL_CHARACTERISTIC_STRAIN\n", - "xlabel1 = plot.LABEL_GW_FREQUENCY_YR\n", - "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', \n", - " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", - " 'hard_time', 'hard_gamma_inner']\n", - "\n", - "fig, axs = plot.figax_double(ncols=6, nrows=2, height=5)\n", - "\n", - "# for ii, target in enumerate(targets): # first row\n", - "# data, params, dets = get_data(target)\n", - "\n", - "# axs[0,ii].set_xlabel(xlabel1)\n", - "# axs[1,ii].set_xlabel(plot.PARAM_KEYS[target])\n", - "# if ii == 0:\n", - "# axs[0,ii].set_ylabel(ylabel1)\n", - "# axs[1,ii].set_ylabel(ylabel2)\n", - "# else:\n", - "# axs[0,ii].sharey(axs[0,0])\n", - "# axs[1,ii].sharey(axs[1,0])" - ] - }, { "cell_type": "code", "execution_count": null, From 48c0834ecf092a38c12dcbf3874902e1e8956b04 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 2 Jul 2023 00:55:11 -0700 Subject: [PATCH 220/291] Fix nan values, still working out negative values. --- .../parameter_investigation/neg_redz2.ipynb | 374 +++++++++++++++++- 1 file changed, 371 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb index d7cbe9a6..2cdfd30a 100644 --- a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb +++ b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb @@ -13,11 +13,13 @@ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import matplotlib.cm as cm\n", + "import kalepy as kale\n", "\n", "import h5py\n", "\n", "\n", - "from holodeck import plot, detstats, utils\n", + "from holodeck import plot, detstats, utils, cosmo\n", + "import holodeck.sams.cyutils as sam_cyutils\n", "import holodeck.single_sources as sings\n", "from holodeck.constants import YR, MSOL, MPC, GYR\n", "import holodeck as holo\n", @@ -32,7 +34,7 @@ "outputs": [], "source": [ "fobs_cents, fobs_edges = utils.pta_freqs()\n", - "sam = holo.sams.Semi_Analytic_Model(shape=30)\n", + "sam = holo.sams.Semi_Analytic_Model(shape=40)\n", "hard = holo.hardening.Fixed_Time_2PL_SAM(sam=sam, time=3*GYR)\n" ] }, @@ -42,7 +44,9 @@ "metadata": {}, "outputs": [], "source": [ - "hc_ss, hc_bg, sspar, bgpar = sam.gwb(fobs_edges, hard, realize=10, loudest=5, params=True)" + "nloudest = 5\n", + "nreals = 10\n", + "hc_ss, hc_bg, sspar, bgpar = sam.gwb(fobs_edges, hard, realize=nreals, loudest=nloudest, params=True)" ] }, { @@ -55,6 +59,370 @@ " print(f\"{sings.par_names[ii]}, {utils.stats(par)}\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii, par in enumerate(sspar):\n", + " print(f\"{sings.par_names[ii]}, {utils.stats(par)}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_orb_cents = fobs_cents/2\n", + "fobs_orb_edges = fobs_edges/2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "redz_final, diff_num = sam_cyutils.dynamic_binary_number_at_fobs(\n", + " fobs_orb_cents, sam, hard, holo.cosmo\n", + ")\n", + "\n", + "edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges]\n", + "number = sam_cyutils.integrate_differential_number_3dx1d(edges, diff_num)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(number.shape)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Internal to ss_gws_redz()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "redz=redz_final\n", + "\n", + "# All other bin midpoints\n", + "mt = kale.utils.midpoints(edges[0]) #: total mass\n", + "mr = kale.utils.midpoints(edges[1]) #: mass ratio\n", + "rz = kale.utils.midpoints(edges[2]) #: initial redshift\n", + "\n", + "\n", + "# hsfdf = hsamp^2 * f/df # this is same as hc^2\n", + "h2fdf = holo.gravwaves.char_strain_sq_from_bin_edges_redz(edges, redz)\n", + "\n", + "# indices of bins sorted by h2fdf\n", + "indices = np.argsort(-h2fdf[...,0].flatten()) # just sort for first frequency\n", + "unraveled = np.array(np.unravel_index(indices, (len(mt),len(mr),len(rz))))\n", + "msort = unraveled[0,:]\n", + "qsort = unraveled[1,:]\n", + "zsort = unraveled[2,:]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(utils.stats(redz))\n", + "if np.any(np.logical_and(redz<0, redz!=-1)):\n", + " err = np.sum(np.logical_and(redz<0, redz!=-1))\n", + " err = f\"{err} redz < 0 and !=-1 found in redz, in ss_gws_redz()\"\n", + " raise ValueError(err)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for dd in range(3):\n", + " redz = np.moveaxis(redz, dd, 0)\n", + " redz = kale.utils.midpoints(redz, axis=0)\n", + " redz = np.moveaxis(redz, 0, dd)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(utils.stats(redz))\n", + "if np.any(np.logical_and(redz<0, redz!=-1)):\n", + " err = np.sum(np.logical_and(redz<0, redz!=-1))\n", + " err = f\"{err} redz < 0 and !=-1 found in redz, in ss_gws_redz()\"\n", + " print(err)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(redz.size)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "dcom_final = +np.inf*np.ones_like(redz)\n", + "# print(holo.utils.stats(redz), \"before sel\")\n", + "sel = (redz > 0.0)\n", + "redz[~sel] = -1.0\n", + "# print(holo.utils.stats(redz), \"after sel\")\n", + "redz[redz<0] = -1.0\n", + "# print(holo.utils.stats(redz), \"after redz[redz<0]=-1\")\n", + "dcom_final[sel] = cosmo.comoving_distance(redz[sel]).cgs.value\n", + "if np.any(dcom_final<0): print('dcom_final<0 found')\n", + "if np.any(np.isnan(dcom_final)): print('nan dcom_final found')\n", + "# redz[redz<0] = -1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(utils.stats(redz))\n", + "print(utils.stats(dcom_final))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "fobs_orb_edges = edges[-1]\n", + "fobs_orb_cents = kale.utils.midpoints(fobs_orb_edges)\n", + "frst_orb_cents = utils.frst_from_fobs(fobs_orb_cents[np.newaxis,np.newaxis,np.newaxis,:], redz) # (M,Q,Z,F,), final\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "sepa = utils.kepler_sepa_from_freq(mt[:,np.newaxis,np.newaxis,np.newaxis], frst_orb_cents) # (M,Q,Z,F) in cm\n", + "angs = utils.angs_from_sepa(sepa, dcom_final, redz) # (M,Q,Z,F) use sepa and dcom in cm\n", + "\n", + "print(utils.stats(sepa))\n", + "print(utils.stats(angs))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "shape=number.shape\n", + "print(shape)\n", + "M, Q, Z, F = [*shape]\n", + "L = nloudest\n", + "R = nreals\n", + "\n", + "hc2ss = np.zeros_like(hc_ss)\n", + "hc2bg = np.zeros_like(hc_bg)\n", + "bgpar = np.zeros((7,F,R,))\n", + "sspar = np.zeros((4,F,R,L))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "thresh = 0.5 \n", + "for rr in range(R):\n", + " for ff in range(F):\n", + " ll = 0 # track which index in the loudest list you're currently storing\n", + " # start at 0 for the loudest of all.\n", + " # reset strain sums\n", + " sum_bg = 0 # sum of bg h2fdf, for parameter averaging and gwb\n", + " # reset parameter averaging sums\n", + " m_bg = 0\n", + " q_bg = 0\n", + " z_bg = 0\n", + " zfinal_bg = 0\n", + " dcom_bg = 0\n", + " sepa_bg = 0\n", + " angs_bg = 0\n", + " for bb in range(M*Q*Z): #iterate through bins, loudest to quietest\n", + " mm = msort[bb]\n", + " qq = qsort[bb]\n", + " zz = zsort[bb]\n", + " num = number[mm,qq,zz,ff]\n", + " num = np.random.poisson(num)\n", + " if(num < 1):\n", + " continue\n", + " cur = h2fdf[mm,qq,zz,ff] # h^2 * f/df of current bin\n", + " if (num<1):\n", + " continue # to next loudest bin\n", + " while (ll < L) and (num > 0):\n", + " # store ll loudest source strain\n", + " hc2ss[ff,rr,ll] = cur\n", + "\n", + " # store indices of ll loudest source\n", + " sspar[0,ff,rr,ll] = mt[mm]\n", + " sspar[1,ff,rr,ll] = mr[qq]\n", + " sspar[2,ff,rr,ll] = rz[zz]\n", + " sspar[3,ff,rr,ll] = redz_final[mm,qq,zz,ff]\n", + "\n", + " # check for negative redz_final\n", + " if redz_final[mm,qq,zz,ff]<0 and redz_final[mm,qq,zz,ff]!=-1:\n", + " # badz = badz+1\n", + " err = f\"redz_final[{mm},{qq},{zz},{ff}] = {redz_final[mm,qq,zz,ff]} < 0\"\n", + " print(\"ERROR IN CYUTILS:\", err)\n", + "\n", + " # update number and ll index\n", + " num -= 1\n", + " ll += 1\n", + " if cur > 0:\n", + " sum_bg += num * cur # tot bg h2fdf\n", + " # add to average parameters of background sources\n", + " m_bg += num * cur * mt[mm] # tot weight bg mass\n", + " q_bg += num * cur * mr[qq] # tot weighted bg ratio\n", + " z_bg += num * cur * rz[zz] # tot weighted bg redshift\n", + " zfinal_bg += num * cur * redz_final[mm,qq,zz,ff] # tot weighted bg redshift after hardening\n", + " dcom_bg += num * cur * dcom_final[mm,qq,zz,ff] # tot weighted bg com. dist. after hardening\n", + " sepa_bg += num * cur * sepa[mm,qq,zz,ff] # tot weighted bg separation after hardening\n", + " angs_bg += num * cur * angs[mm,qq,zz,ff] # tot weighted bg angular separation after hardening\n", + " if(mm==19 and qq==19 and zz==19 and ff==21):\n", + " print(\"here!\")\n", + " if np.any(sspar[3,ff,rr,:]<0):\n", + " print(f\"{ff=}, {rr=}, {mm=}, {qq=}, {zz=}, {sspar[3,ff,rr,:]=}, {num=}, {cur=}\")\n", + " if ll < nloudest-1: \n", + " print(f'not enough loudest at {ff=}, {rr=}, {ll=} ')\n", + " hc2bg[ff,rr] = sum_bg # background strain\n", + " # background average parameters\n", + " bgpar[0,ff,rr] = m_bg/sum_bg # bg avg mass\n", + " bgpar[1,ff,rr] = q_bg/sum_bg # bg avg ratio\n", + " bgpar[2,ff,rr] = z_bg/sum_bg # bg avg redshift\n", + " bgpar[3,ff,rr] = zfinal_bg/sum_bg # bg avg redshift after hardening\n", + " bgpar[4,ff,rr] = dcom_bg/sum_bg # bg avg comoving distance after hardening\n", + " bgpar[5,ff,rr] = sepa_bg/sum_bg # bg avg binary separation after hardening\n", + " bgpar[6,ff,rr] = angs_bg/sum_bg # bg avg binary angular separation after hardening\n", + " # print(f\"{ff=}, {rr=}, {dcom_bg=}, {sum_bg=}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(M*Q*Z)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(msort))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(redz_final[19, 19, 19, 21])\n", + "print(dcom_final[19, 19, 19, 21])\n", + "print(h2fdf[19,19,19,21])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(msort[-1]) # this is the quietest bin\n", + "print(qsort[-1])\n", + "print(zsort[-1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ff in range(F):\n", + " for rr in range(nreals):\n", + " for ll in range(nloudest):\n", + " if sspar[3,ff,rr,ll]<0:\n", + " print(f\"{ff=}, {rr=}, {ll=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sspar[3,:,:,:][sspar[3]<0])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(utils.stats(sspar[3]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.sum(sspar[3][sspar[3]<0]))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sspar[3])" + ] + }, { "cell_type": "code", "execution_count": null, From ea2020ce674a094f2ac94219a1f5bbccc8441ed2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 2 Jul 2023 01:23:49 -0700 Subject: [PATCH 221/291] Find bug in sorting by redz_final before interpolation. Implement simple patch to check that cur>0. A proper solution would be to sort after redz_final interpolation. --- .../parameter_investigation/neg_redz2.ipynb | 68 +++++++++++++++---- holodeck/cyutils.pyx | 5 +- holodeck/single_sources.py | 12 ++-- 3 files changed, 62 insertions(+), 23 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb index 2cdfd30a..94e97579 100644 --- a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb +++ b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb @@ -33,8 +33,10 @@ "metadata": {}, "outputs": [], "source": [ + "shape = 40\n", + "\n", "fobs_cents, fobs_edges = utils.pta_freqs()\n", - "sam = holo.sams.Semi_Analytic_Model(shape=40)\n", + "sam = holo.sams.Semi_Analytic_Model(shape=shape)\n", "hard = holo.hardening.Fixed_Time_2PL_SAM(sam=sam, time=3*GYR)\n" ] }, @@ -282,12 +284,12 @@ " zz = zsort[bb]\n", " num = number[mm,qq,zz,ff]\n", " num = np.random.poisson(num)\n", - " if(num < 1):\n", - " continue\n", + " # if(num < 1):\n", + " # continue\n", " cur = h2fdf[mm,qq,zz,ff] # h^2 * f/df of current bin\n", - " if (num<1):\n", - " continue # to next loudest bin\n", - " while (ll < L) and (num > 0):\n", + " # if (num<1):\n", + " # continue # to next loudest bin\n", + " while (ll < L) and (num > 0) and (cur>0):\n", " # store ll loudest source strain\n", " hc2ss[ff,rr,ll] = cur\n", "\n", @@ -306,7 +308,7 @@ " # update number and ll index\n", " num -= 1\n", " ll += 1\n", - " if cur > 0:\n", + " if cur > 0 and num > 0:\n", " sum_bg += num * cur # tot bg h2fdf\n", " # add to average parameters of background sources\n", " m_bg += num * cur * mt[mm] # tot weight bg mass\n", @@ -316,10 +318,9 @@ " dcom_bg += num * cur * dcom_final[mm,qq,zz,ff] # tot weighted bg com. dist. after hardening\n", " sepa_bg += num * cur * sepa[mm,qq,zz,ff] # tot weighted bg separation after hardening\n", " angs_bg += num * cur * angs[mm,qq,zz,ff] # tot weighted bg angular separation after hardening\n", - " if(mm==19 and qq==19 and zz==19 and ff==21):\n", - " print(\"here!\")\n", + "\n", " if np.any(sspar[3,ff,rr,:]<0):\n", - " print(f\"{ff=}, {rr=}, {mm=}, {qq=}, {zz=}, {sspar[3,ff,rr,:]=}, {num=}, {cur=}\")\n", + " print(f\"{ff=}, {rr=}, {sspar[3,ff,rr,:]=}\")\n", " if ll < nloudest-1: \n", " print(f'not enough loudest at {ff=}, {rr=}, {ll=} ')\n", " hc2bg[ff,rr] = sum_bg # background strain\n", @@ -334,6 +335,47 @@ " # print(f\"{ff=}, {rr=}, {dcom_bg=}, {sum_bg=}\")\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(hc2ss[27,0,:])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(redz_final[:,:,:,27])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for bb in range(M*Q*Z):\n", + " mm = msort[bb]\n", + " qq = qsort[bb]\n", + " zz = zsort[bb]\n", + " if mm==19 and qq==19 and zz==19:\n", + " print(f\"{bb=}, {mm}, {qq}, {zz}\") # this is the quietest bin!" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(h2fdf[19,19,19])" + ] + }, { "cell_type": "code", "execution_count": null, @@ -349,7 +391,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(len(msort))" + "print(M*Q*Z)" ] }, { @@ -358,9 +400,7 @@ "metadata": {}, "outputs": [], "source": [ - "print(redz_final[19, 19, 19, 21])\n", - "print(dcom_final[19, 19, 19, 21])\n", - "print(h2fdf[19,19,19,21])" + "print(len(msort))" ] }, { diff --git a/holodeck/cyutils.pyx b/holodeck/cyutils.pyx index f76ec0e2..87d785ce 100644 --- a/holodeck/cyutils.pyx +++ b/holodeck/cyutils.pyx @@ -1742,10 +1742,9 @@ cdef void _loudest_hc_and_par_from_sorted_redz(long[:] shape, double[:,:,:,:] h2 num = random_normal(rng, num, std) else: # Poisson sample num = random_poisson(rng, num) - if(num < 1): - continue cur = h2fdf[mm,qq,zz,ff] # h^2 * f/df of current bin - if (num<1): + + if (num < 1) or (cur == 0): continue # to next loudest bin while (ll < L) and (num > 0): # store ll loudest source strain diff --git a/holodeck/single_sources.py b/holodeck/single_sources.py index 052d4117..e13505db 100644 --- a/holodeck/single_sources.py +++ b/holodeck/single_sources.py @@ -130,7 +130,7 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): # print(holo.utils.stats(redz), "after redz[redz<0]=-1") dcom_final[sel] = cosmo.comoving_distance(redz[sel]).cgs.value if np.any(dcom_final<0): print('dcom_final<0 found') - + if np.any(np.isnan(dcom_final)): print('nan dcom_final found') # redz[redz<0] = -1 fobs_orb_edges = edges[-1] @@ -169,11 +169,11 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): raise ValueError(err) # check for negatives - if np.any(sspar[3]<0): - sumfalse = np.sum(sspar[3]<0) - err = f"check 2: {sumfalse} out of {sspar[3].size} redz_final are negative in sings.ss_gws_redz()" - # print(np.where(neither==True)) - print(err) + # if np.any(sspar[3]<0): + sumfalse = np.sum(sspar[3]<0) + err = f"check 2: {sumfalse} out of {sspar[3].size} redz_final are negative in sings.ss_gws_redz()" + # print(np.where(neither==True)) + print(err) # raise ValueError(err) # return From bf50652de583c1cd6c51115b042d5a1aafb99331 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 2 Jul 2023 10:59:17 -0700 Subject: [PATCH 222/291] Update varpar save location to anatomy_redz, for fixed positive redshift data. --- ecg-notebooks/paper_plots/charstrain.ipynb | 39 ++++++++++++++----- .../detect_model_clbrt_pta.py | 2 +- .../detect_model_clbrt_ramp.py | 2 +- .../parameter_investigation/neg_redz2.ipynb | 2 +- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ecg-notebooks/paper_plots/charstrain.ipynb b/ecg-notebooks/paper_plots/charstrain.ipynb index 68f4b134..ceedb15d 100644 --- a/ecg-notebooks/paper_plots/charstrain.ipynb +++ b/ecg-notebooks/paper_plots/charstrain.ipynb @@ -43,11 +43,11 @@ "TOL=0.01\n", "MAXBADS=5\n", "\n", - "NVARS = 21\n", + "NVARS = 3\n", "# NVARS = 6\n", "\n", "NPSRS = 40\n", - "NSKIES = 100\n", + "NSKIES = 25\n", "# NSKIES = 15" ] }, @@ -153,11 +153,11 @@ "nsamp = np.min([nsamp, NREALS])\n", "\n", "colors = [\n", - " '#6a3d9a', # purple\n", " '#ff7f0f', # orange\n", - " '#15becf', # teal\n", + " '#6a3d9a', # purple\n", " '#f0027f', # pink\n", " '#a6d853', # green\n", + " '#15becf', # teal\n", "]\n", "\n", "# select random realizations to plot\n", @@ -170,7 +170,8 @@ "\n", " for ll in range(5):\n", " edgecolor = 'k' if ll==0 else None\n", - " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor)\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", "\n", "for aa, ii in enumerate(idx):\n", " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[aa]) \n", @@ -217,7 +218,7 @@ "metadata": {}, "outputs": [], "source": [ - "fig, axs = plot.figax_double(nrows=2, ncols=3, sharex=True)\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharex=True, height=5)\n", "\n", "xx = fobs_cents*YR\n", "nsamp = 5\n", @@ -237,11 +238,20 @@ "yy_bg = [hc_bg, bgpar[0], bgpar[1], # strain, mass, mass ratio, initial redshift\n", " bgpar[4], bgpar[5], bgpar[6]]\n", "ylabels = np.append([plot.LABEL_CHARACTERISTIC_STRAIN,], sings.par_labels)\n", - "ylabels = ['Characteristic Strain, $h_c$', 'Total Mass, $M_\\mathrm{tot}$ [M$_\\odot$]', 'Mass Ratio, $q$', \n", - " 'Comoving Distance, $d_\\mathrm{com}$ [Mpc]', 'Separation [pc]', 'Separation [rad]']\n", + "ylabels = ['Characteristic Strain', 'Total Mass [M$_\\odot$]', 'Mass Ratio, $q$', \n", + " 'Com. Distance [Mpc]', 'Separation [pc]', 'Separation [rad]']\n", "for ii, ax in enumerate(axs.flatten()):\n", " # Plot the median \n", " ax.plot(xx, np.median(yy_bg[ii], axis=-1), 'k-')\n", + " for aa, nn in enumerate(idx):\n", + " ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + "\n", + " for aa, nn in enumerate(idx):\n", + " for ll in range(3):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[ii][:,nn,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", "\n", " # Plot the confidence intervals\n", " for pp in [50, 95]:\n", @@ -254,7 +264,18 @@ " ax.set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", " ax.set_ylabel(ylabels[ii])\n", " \n", - "fig.tight_layout()" + "fig.tight_layout()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " +f'/params_midvars_{seed}.png')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.sum(sspar[3][sspar[3]<0]))" ] }, { diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index d344561e..6b1060d8 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -21,7 +21,7 @@ DEF_TOL = 0.01 DEF_MAXBADS = 5 GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system -ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' # settings to vary DEF_CONSTRUCT = False diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py index a8f7fd98..897bb446 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py @@ -20,7 +20,7 @@ DEF_TOL = 0.01 DEF_MAXBADS = 5 GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system -ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' # settings to vary DEF_CONSTRUCT = False diff --git a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb index 94e97579..b1bf19f8 100644 --- a/ecg-notebooks/parameter_investigation/neg_redz2.ipynb +++ b/ecg-notebooks/parameter_investigation/neg_redz2.ipynb @@ -33,7 +33,7 @@ "metadata": {}, "outputs": [], "source": [ - "shape = 40\n", + "shape = None\n", "\n", "fobs_cents, fobs_edges = utils.pta_freqs()\n", "sam = holo.sams.Semi_Analytic_Model(shape=shape)\n", From 13f90db20228ca83796044e4f5c60b698aa9601b Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 2 Jul 2023 23:19:34 -0700 Subject: [PATCH 223/291] Plot 2dhistograms of snr vs mass of single sources for varying parameters. --- .../paper_plots/snr_vs_mass_hist.ipynb | 1160 +++++++++++++++++ 1 file changed, 1160 insertions(+) create mode 100644 ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb diff --git a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb new file mode 100644 index 00000000..28b454b4 --- /dev/null +++ b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb @@ -0,0 +1,1160 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "import tqdm\n", + "import os\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "CALC = False" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "cmap_base = 'magma_r'\n", + "magma_r = truncate_colormap(cmap_base, 0, 0.85)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 3\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "# NSKIES = 15\n", + "RED_GAMMA = None\n", + "RED2WHITE = None\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_var_data(\n", + " target, var=int(NVARS/2), nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + "\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data'][var]\n", + " params = file['params'][var]\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " dsdat = file['dsdat'][var]\n", + " file.close()\n", + "\n", + " return data, params, dsdat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data, params, dsdat = get_var_data('gsmf_phi0', var=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(dsdat['gamma_ssi'].shape)\n", + "print(data['sspar'].shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ssmtt = data['sspar'][0]/MSOL\n", + "ssmtt = np.repeat(ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "ssmtt = np.swapaxes(ssmtt, -2, -1)\n", + "\n", + "dpssi = dsdat['gamma_ssi']" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get edges" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot/MSOL\n", + "# ff_edges = data['fobs_edges']*YR\n", + "\n", + "dpmin = np.min(dpssi)\n", + "dpmax = np.max(dpssi)\n", + "print(dpmin, dpmax)\n", + "dp_edges = np.geomspace(2.5e-6,1.0, NBINS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hist, mme, ffe = np.histogram2d(\n", + " dpssi.flatten(), ssmtt.flatten(), bins=(dp_edges, mt_edges))\n", + "mtgrid, dpgrid, = np.meshgrid(mt_edges, dp_edges)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "snssi = dsdat['snr_ss']\n", + "snmin = np.min(snssi)\n", + "snmax = np.max(snssi)\n", + "print(snmin, snmax)\n", + "sn_edges = np.geomspace(2.e-6,25, NBINS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "NSKIES = 25\n", + "\n", + "# get edges\n", + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[15:-10]/MSOL\n", + "sn_edges = np.geomspace(2.e-6,25, NBINS)\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "fig, axs = plot.figax_single(\n", + " ncols=3, sharex=True, sharey=True, height=3.5)\n", + "\n", + "\n", + "for ii in [0,1,2]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES)\n", + " ssmtt = data['sspar'][0]/MSOL\n", + " ssmtt = np.repeat(ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " ssmtt = np.swapaxes(ssmtt, -2, -1)\n", + "\n", + " snssi = dsdat['snr_ss']\n", + "\n", + " # get histogram\n", + " hist, mte, sne = np.histogram2d(\n", + " snssi.flatten(), ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "\n", + " im = axs[ii].pcolormesh(mtgrid, sngrid, np.log10(hist), cmap=cm.BuPu)\n", + " title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[ii].text(0, 1, title, horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[ii].transAxes, color='white')\n", + "\n", + "# fig.colorbar(im, cax=axs[-1], label='$\\log N$', orientation='vertical')\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[1].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.4, \n", + " orientation='horizontal', pad=0.22, label='$\\log N$', )\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "NSKIES = 25\n", + "\n", + "# get edges\n", + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[25:-12]/MSOL\n", + "sn_edges = np.geomspace(2.e-6,25, NBINS)\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "fig, axs = plot.figax_single(\n", + " nrows=3, sharex=True, sharey=True, height=11)\n", + "\n", + "for ii in [0,1,2]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES)\n", + " ssmtt = data['sspar'][0]/MSOL\n", + " ssmtt = np.repeat(ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " ssmtt = np.swapaxes(ssmtt, -2, -1)\n", + "\n", + " snssi = dsdat['snr_ss']\n", + "\n", + " # get histogram\n", + " hist, mte, sne = np.histogram2d(\n", + " snssi.flatten(), ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "\n", + " im = axs[ii].pcolormesh(mtgrid, sngrid, np.log10(hist))\n", + " title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[ii].text(0, 1, title, horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[ii].transAxes, color='white', fontsize=18)\n", + " axs[ii].set_facecolor('k')\n", + "\n", + "axs[1].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='horizontal', pad=0.08, label='$\\log N$', )\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "\n", + "# get edges\n", + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[25:-15]/MSOL\n", + "sn_edges = np.geomspace(2.e-6,25, NBINS)\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# titles\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# colormaps\n", + "# cmaps = [cm.Greens, cm.Blues, cm.Purples]\n", + "cmaps = [cm.Oranges, cm.Greys, cm.Blues]\n", + "\n", + "\n", + "fig, ax = plot.figax_single()\n", + "\n", + "for ii in [0,1,2]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii)\n", + " ssmtt = data['sspar'][0]/MSOL\n", + " ssmtt = np.repeat(ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " ssmtt = np.swapaxes(ssmtt, -2, -1)\n", + "\n", + " snssi = dsdat['snr_ss']\n", + "\n", + " # get histogram\n", + " hist, mte, sne = np.histogram2d(\n", + " snssi.flatten(), ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "\n", + " im = ax.pcolormesh(mtgrid, sngrid, np.log10(hist), cmap=cmaps[ii], alpha=0.5)\n", + " title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # axs[ii].text(0, 1, title, horizontalalignment='left', verticalalignment='top', \n", + " # transform=axs[ii].transAxes, color='white')\n", + "\n", + "ax.set_ylabel(ylabel)\n", + "ax.set_xlabel(xlabel)\n", + "\n", + "fig.tight_layout()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NSKIES = 50\n", + "\n", + "\n", + "# get edges\n", + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[20:-12]/MSOL\n", + "sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "fig, axs = plot.figax_single(\n", + " nrows=3, sharex=True, sharey=True, height=11)\n", + "\n", + "for ii in [0,1,2]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES)\n", + " ssmtt = data['sspar'][0]/MSOL\n", + " ssmtt = np.repeat(ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " ssmtt = np.swapaxes(ssmtt, -2, -1)\n", + "\n", + " snssi = dsdat['snr_ss']\n", + "\n", + " # get histogram\n", + " hist, mte, sne = np.histogram2d(\n", + " snssi.flatten(), ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "\n", + " im = axs[ii].pcolormesh(mtgrid, sngrid, np.log10(hist), cmap=cm.magma)\n", + " title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[ii].text(0, 1, title, horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[ii].transAxes, color='white', fontsize=18)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "axs[1].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='horizontal', pad=0.08, label='$\\log N$', )\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NSKIES = 50\n", + "\n", + "# get edges\n", + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[25:-15]/MSOL\n", + "sn_edges = np.geomspace(2.e-6,25, NBINS)\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# titles\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# colormaps\n", + "# cmaps = [cm.Greens, cm.Blues, cm.Purples]\n", + "cmaps = [cm.Oranges, cm.Greys, cm.Blues]\n", + "\n", + "\n", + "fig, ax = plot.figax_single()\n", + "\n", + "for ii in [0,1,2]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES)\n", + " ssmtt = data['sspar'][0]/MSOL\n", + " ssmtt = np.repeat(ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " ssmtt = np.swapaxes(ssmtt, -2, -1)\n", + "\n", + " snssi = dsdat['snr_ss']\n", + "\n", + " # get histogram\n", + " hist, mte, sne = np.histogram2d(\n", + " snssi.flatten(), ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "\n", + " im = ax.pcolormesh(mtgrid, sngrid, np.log10(hist), cmap=cmaps[ii], alpha=0.5)\n", + " title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # axs[ii].text(0, 1, title, horizontalalignment='left', verticalalignment='top', \n", + " # transform=axs[ii].transAxes, color='white')\n", + "\n", + "ax.set_ylabel(ylabel)\n", + "ax.set_xlabel(xlabel)\n", + "\n", + "fig.tight_layout()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Hard_time 5ax" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NSKIES = 100\n", + "NVARS = 21\n", + "\n", + "if CALC:\n", + " # get edges\n", + " NBINS = 40\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[20:-12]/MSOL\n", + " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + " # get histograms\n", + " ssmtt = []\n", + " snssi = []\n", + " hist = []\n", + " text = []\n", + " for ii in [0,5,10,15,20]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + " _ssmtt = data['sspar'][0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + " ssmtt.append(_ssmtt)\n", + "\n", + " _snssi = dsdat['snr_ss']\n", + " snssi.append(_snssi)\n", + " # get histogram\n", + " _hist, mte, sne = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist.append(_hist)\n", + "\n", + " _text = '%.2f' % (params[TARGET])\n", + " text.append(_text)\n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges,\n", + " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "else:\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " mt_edges = file['mt_edges']\n", + " sn_edges = file['sn_edges']\n", + " ssmtt = file['ssmtt']\n", + " snssi = file['snssi']\n", + " hist = file['hist']\n", + " text = file['text']\n", + " file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_single(\n", + " nrows=5, sharex=True, sharey=True, height=16)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=cm.magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0, 1, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], \n", + " horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=18)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[2].set_ylabel(ylabel)\n", + "axs[-1].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='horizontal', pad=0.08, label='$\\log N$', )\n", + "\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Hard_gamma_inner 5ax" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner'\n", + "NSKIES = 100\n", + "NVARS = 21\n", + "\n", + "if CALC:\n", + " # get edges\n", + " NBINS = 40\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[20:-12]/MSOL\n", + " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + " # get histograms\n", + " ssmtt = []\n", + " snssi = []\n", + " hist = []\n", + " text = []\n", + " for ii in [0,5,10,15,20]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + " _ssmtt = data['sspar'][0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + " ssmtt.append(_ssmtt)\n", + "\n", + " _snssi = dsdat['snr_ss']\n", + " snssi.append(_snssi)\n", + " # get histogram\n", + " _hist, mte, sne = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist.append(_hist)\n", + "\n", + " _text = '%.2f' % (params[TARGET])\n", + " text.append(_text)\n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges,\n", + " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "else:\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " mt_edges = file['mt_edges']\n", + " sn_edges = file['sn_edges']\n", + " ssmtt = file['ssmtt']\n", + " snssi = file['snssi']\n", + " hist = file['hist']\n", + " text = file['text']\n", + " file.close()\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0.01, 0.99, '$\\\\nu_\\mathrm{inner}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "SNR or DP vs. Frequency" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# GSMF_phi0 5ax" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "NSKIES = 100\n", + "NVARS = 21\n", + "\n", + "if CALC:\n", + " # get edges\n", + " NBINS = 40\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[20:-10]/MSOL\n", + " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + " # get histograms\n", + " ssmtt = []\n", + " snssi = []\n", + " hist = []\n", + " text = []\n", + " for ii in [0,5,10,15,20]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + " _ssmtt = data['sspar'][0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + " ssmtt.append(_ssmtt)\n", + "\n", + " _snssi = dsdat['snr_ss']\n", + " snssi.append(_snssi)\n", + " # get histogram\n", + " _hist, mte, sne = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist.append(_hist)\n", + "\n", + " _text = '%.2f' % (params[TARGET])\n", + " text.append(_text)\n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges,\n", + " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "else:\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " mt_edges = file['mt_edges']\n", + " sn_edges = file['sn_edges']\n", + " ssmtt = file['ssmtt']\n", + " snssi = file['snssi']\n", + " hist = file['hist']\n", + " text = file['text']\n", + " file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0.01, 0.99, '$\\psi_0$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Gsmf_mchar0_log10 5ax" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NSKIES = 100\n", + "NVARS = 21\n", + "\n", + "if CALC:\n", + " # get edges\n", + " NBINS = 40\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[20:-6]/MSOL\n", + " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + " # get histograms\n", + " ssmtt = []\n", + " snssi = []\n", + " hist = []\n", + " text = []\n", + " for ii in [0,5,10,15,20]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + " _ssmtt = data['sspar'][0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + " ssmtt.append(_ssmtt)\n", + "\n", + " _snssi = dsdat['snr_ss']\n", + " snssi.append(_snssi)\n", + " # get histogram\n", + " _hist, mte, sne = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist.append(_hist)\n", + "\n", + " _text = '%.2f' % (params[TARGET])\n", + " text.append(_text)\n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges,\n", + " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "else:\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " mt_edges = file['mt_edges']\n", + " sn_edges = file['sn_edges']\n", + " ssmtt = file['ssmtt']\n", + " snssi = file['snssi']\n", + " hist = file['hist']\n", + " text = file['text']\n", + " file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0.01, 0.99, '$M_\\mathrm{char,0}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_mamp_log10 5ax" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_mamp_log10'\n", + "NSKIES = 100\n", + "NVARS = 21\n", + "\n", + "if CALC:\n", + " # get edges\n", + " NBINS = 40\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[20:-8]/MSOL\n", + " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + " # get histograms\n", + " ssmtt = []\n", + " snssi = []\n", + " hist = []\n", + " text = []\n", + " for ii in [0,5,10,15,20]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + " _ssmtt = data['sspar'][0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + " ssmtt.append(_ssmtt)\n", + "\n", + " _snssi = dsdat['snr_ss']\n", + " snssi.append(_snssi)\n", + " # get histogram\n", + " _hist, mte, sne = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist.append(_hist)\n", + "\n", + " _text = '%.2f' % (params[TARGET])\n", + " text.append(_text)\n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges,\n", + " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "else:\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " mt_edges = file['mt_edges']\n", + " sn_edges = file['sn_edges']\n", + " ssmtt = file['ssmtt']\n", + " snssi = file['snssi']\n", + " hist = file['hist']\n", + " text = file['text']\n", + " file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0.01, 0.99, '$\\mu$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_scatter_dex" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_scatter_dex'\n", + "NSKIES = 100\n", + "NVARS = 21\n", + "\n", + "if CALC:\n", + " # get edges\n", + " NBINS = 40\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[20:-8]/MSOL\n", + " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + " # get histograms\n", + " ssmtt = []\n", + " snssi = []\n", + " hist = []\n", + " text = []\n", + " for ii in [0,5,10,15,20]: # vars to use\n", + " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + " _ssmtt = data['sspar'][0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + " ssmtt.append(_ssmtt)\n", + "\n", + " _snssi = dsdat['snr_ss']\n", + " snssi.append(_snssi)\n", + " # get histogram\n", + " _hist, mte, sne = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist.append(_hist)\n", + "\n", + " _text = '%.2f' % (params[TARGET])\n", + " text.append(_text)\n", + " \n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges,\n", + " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "else:\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " mt_edges = file['mt_edges']\n", + " sn_edges = file['sn_edges']\n", + " ssmtt = file['ssmtt']\n", + " snssi = file['snssi']\n", + " hist = file['hist']\n", + " text = file['text']\n", + " file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Mass [M$_\\odot$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " axs[aa].text(0.01, 0.99, '$\\epsilon_\\mu$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b72d659b5a376d57667bf72f55a792b867a9f971 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 00:14:36 -0700 Subject: [PATCH 224/291] Plot ratio vs hard_time for just 50 skies. 100skies looks better. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 4dd89db1..97471309 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -340,6 +340,130 @@ " fig.savefig(savename, dpi=100)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Using 50 skies" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = True\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 50\n", + "# NSKIES = 15" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if True:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + " for target in ['hard_time']:\n", + " print(target)\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target, path=path, nskies=50,)\n", + " xx=[]\n", + " yy=[]\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + "\n", + " # # red_gamma = -1.5\n", + " # data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " # y1p5=[]\n", + " # for pp, par in enumerate(params):\n", + " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " # dp_ss = dsdat[pp]['ev_ss']\n", + " # y1p5.append(dp_ss/dp_bg)\n", + "\n", + " # # red_gamma = -3.0\n", + " # data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + " # y3p0=[]\n", + " # for pp, par in enumerate(params):\n", + " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " # dp_ss = dsdat[pp]['ev_ss']\n", + " # y3p0.append(dp_ss/dp_bg)\n", + "\n", + " \n", + " # np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", + " # xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xx_hardtime = xx\n", + "yy_hardtime = yy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " if ii != 2:\n", + " continue\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " # xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy_hardtime, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx_hardtime, *conf, color=col0p0[ii], alpha=0.25)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/hard_time_21vars_clbrt_pta.npz',\n", + " allow_pickle=True)\n", + "print(file.files)\n", + "print(len(file['data']))\n", + "hc_bg = file['data'][0]['hc_bg']\n", + "print(hc_bg.shape)" + ] + }, { "cell_type": "code", "execution_count": null, From ce66ef3f707a7c5547157fe6401b2fbd2f777576 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 01:29:51 -0700 Subject: [PATCH 225/291] Remove nskies from filename of data files, leave in dets file names. --- .../parameter_investigation/detect_model_clbrt_pta.py | 4 ++-- .../parameter_investigation/detect_model_clbrt_ramp.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 6b1060d8..7d19408d 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -167,12 +167,12 @@ def main(): % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) if args.load_file is None: - load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' else: load_data_from_file = args.load_file if args.save_file is None: - save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' else: save_data_to_file = args.save_file diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py index 897bb446..06a2763b 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py @@ -164,12 +164,12 @@ def main(): % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) if args.load_file is None: - load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' else: load_data_from_file = args.load_file if args.save_file is None: - save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}' + save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' else: save_data_to_file = args.save_file save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' From cda9db3fbc93ad15f3a339cf0da7f258437a59d9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 01:33:29 -0700 Subject: [PATCH 226/291] Plot other strain and properties for varying pars. --- ecg-notebooks/paper_plots/charstrain.ipynb | 340 --------- .../paper_plots/charstrain_and_props.ipynb | 648 ++++++++++++++++++ .../paper_plots/ratio_and_hc_varpar.ipynb | 10 +- 3 files changed, 654 insertions(+), 344 deletions(-) delete mode 100644 ecg-notebooks/paper_plots/charstrain.ipynb create mode 100644 ecg-notebooks/paper_plots/charstrain_and_props.ipynb diff --git a/ecg-notebooks/paper_plots/charstrain.ipynb b/ecg-notebooks/paper_plots/charstrain.ipynb deleted file mode 100644 index ceedb15d..00000000 --- a/ecg-notebooks/paper_plots/charstrain.ipynb +++ /dev/null @@ -1,340 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%reload_ext autoreload\n", - "%autoreload 2\n", - "from importlib import reload\n", - "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import matplotlib.cm as cm\n", - "import h5py\n", - "import matplotlib as mpl\n", - "\n", - "\n", - "from holodeck import plot, detstats\n", - "import holodeck.single_sources as sings\n", - "from holodeck.constants import YR, MSOL, MPC\n", - "import holodeck as holo\n", - "\n", - "import hasasia.sim as hsim\n", - "import os\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "SHAPE = None\n", - "NREALS = 500\n", - "# NREALS = 20\n", - "NFREQS = 40\n", - "NLOUDEST = 10\n", - "\n", - "BUILD_ARRAYS = False\n", - "SAVEFIG = False\n", - "TOL=0.01\n", - "MAXBADS=5\n", - "\n", - "NVARS = 3\n", - "# NVARS = 6\n", - "\n", - "NPSRS = 40\n", - "NSKIES = 25\n", - "# NSKIES = 15" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def get_data(\n", - " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", - "):\n", - "\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", - " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", - " # if red_gamma is not None and red2white is not None:\n", - " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", - " # load_dets_from_file = load_dets_from_file+'.npz'\n", - "\n", - " if os.path.exists(load_data_from_file) is False:\n", - " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", - " raise Exception(err)\n", - " # if os.path.exists(load_dets_from_file) is False:\n", - " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", - " # raise Exception(err)\n", - " file = np.load(load_data_from_file, allow_pickle=True)\n", - " data = file['data'][int(NVARS/2)]\n", - " params = file['params'][int(NVARS/2)]\n", - " file.close()\n", - "\n", - " # file = np.load(load_dets_from_file, allow_pickle=True)\n", - " # dsdat = file['dsdat']\n", - " # file.close()\n", - "\n", - " return data, params" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "data, params = get_data('hard_time')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "hc_ss = data['hc_ss']\n", - "hc_bg = data['hc_bg']\n", - "sspar = data['sspar']\n", - "bgpar = data['bgpar']\n", - "fobs_cents = data['fobs_cents']" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "edgecolors = np.repeat(None, NLOUDEST)\n", - "edgecolors[0] = 'k'\n", - "print(edgecolors)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, ax = plot.figax_single(\n", - " xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN)\n", - "\n", - "\n", - "nsamp = 5 # number of sample GWB spectra to plot\n", - "\n", - "xx = fobs_cents * YR\n", - "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", - "\n", - "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", - "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", - "ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", - "\n", - "# Plot the median GWB spectrum\n", - "ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", - "\n", - "\n", - "\n", - "# Plot `nsamp` random spectra \n", - "seed = 67233 # more spread out\n", - "# seed = 98068 # includes random super high\n", - "# seed = np.random.randint(99999) # get a random number\n", - "print(seed) # print it out so we can reuse it if desired\n", - "np.random.seed(seed) # set the random seed\n", - "\n", - "nsamp = np.min([nsamp, NREALS])\n", - "\n", - "colors = [\n", - " '#ff7f0f', # orange\n", - " '#6a3d9a', # purple\n", - " '#f0027f', # pink\n", - " '#a6d853', # green\n", - " '#15becf', # teal\n", - "]\n", - "\n", - "# select random realizations to plot\n", - "idx = np.random.choice(NREALS, nsamp, replace=False)\n", - "for aa, ii in enumerate(idx):\n", - "\n", - " # edgecolors = np.repeat(colors[aa], NLOUDEST).reshape(4, NLOUDEST) # idk why this isnt working\n", - " # edgecolors = np.swapaxes(edgecolors, 0,1)\n", - " # edgecolors[0,:] = np.array([1, 1, 1, 1])\n", - "\n", - " for ll in range(5):\n", - " edgecolor = 'k' if ll==0 else None\n", - " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor,\n", - " s=20)\n", - "\n", - "for aa, ii in enumerate(idx):\n", - " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[aa]) \n", - "\n", - "fig.tight_layout()\n", - "# fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_midvars_{seed}.png', dpi=100)\n", - "\n", - "# plot contours at 50% and 98% confidence intervals\n", - "for pp in [50, 98]:\n", - " percs = pp / 2\n", - " percs = [50 - percs, 50 + percs]\n", - " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", - " \n", - "# plt.show()" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# all parameters" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(sings.par_labels)\n", - "\n", - "bgpar = data['bgpar']\n", - "sspar = data['sspar']\n", - "sspar = sings.all_sspars(fobs_cents, sspar)\n", - "\n", - "bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", - "sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, axs = plot.figax_double(nrows=2, ncols=3, sharex=True, height=5)\n", - "\n", - "xx = fobs_cents*YR\n", - "nsamp = 5\n", - "\n", - "# Plot `nsamp` random spectra \n", - "seed = 67233 # more spread out\n", - "# seed = np.random.randint(99999) # get a random number\n", - "print(seed) # print it out so we can reuse it if desired\n", - "np.random.seed(seed) # set the random seed\n", - "\n", - "# select random realizations to plot\n", - "idx = np.random.choice(NREALS, nsamp, replace=False)\n", - "\n", - "# parameters to plot\n", - "yy_ss = [hc_ss, sspar[0], sspar[1], # sspar[2,], # strain, mass, mass ratio,\n", - " sspar[4], sspar[5], sspar[6]] # final comoving distance, final separation, final angular separation\n", - "yy_bg = [hc_bg, bgpar[0], bgpar[1], # strain, mass, mass ratio, initial redshift\n", - " bgpar[4], bgpar[5], bgpar[6]]\n", - "ylabels = np.append([plot.LABEL_CHARACTERISTIC_STRAIN,], sings.par_labels)\n", - "ylabels = ['Characteristic Strain', 'Total Mass [M$_\\odot$]', 'Mass Ratio, $q$', \n", - " 'Com. Distance [Mpc]', 'Separation [pc]', 'Separation [rad]']\n", - "for ii, ax in enumerate(axs.flatten()):\n", - " # Plot the median \n", - " ax.plot(xx, np.median(yy_bg[ii], axis=-1), 'k-')\n", - " for aa, nn in enumerate(idx):\n", - " ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", - "\n", - " for aa, nn in enumerate(idx):\n", - " for ll in range(3):\n", - " edgecolor = 'k' if ll==0 else None\n", - " ax.scatter(xx, yy_ss[ii][:,nn,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor,\n", - " s=20)\n", - "\n", - "\n", - " # Plot the confidence intervals\n", - " for pp in [50, 95]:\n", - " percs = pp / 2\n", - " percs = [50 - percs, 50 + percs]\n", - " ax.fill_between(xx, *np.percentile(yy_bg[ii], percs, axis=-1), alpha=0.25, color='k')\n", - "\n", - " # label axes\n", - " if ii>=3:\n", - " ax.set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", - " ax.set_ylabel(ylabels[ii])\n", - " \n", - "fig.tight_layout()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " +f'/params_midvars_{seed}.png')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.sum(sspar[3][sspar[3]<0]))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# print(holo.utils.stats(sspar[3]))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "xx = np.linspace(0,20,100)\n", - "xx[5] = np.nan\n", - "\n", - "print(np.sum(xx))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "print(np.linspace(0,1,2))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "holo310", - "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.10" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb new file mode 100644 index 00000000..eb9adf57 --- /dev/null +++ b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb @@ -0,0 +1,648 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 3\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "# NSKIES = 15" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + "):\n", + "\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " # if red_gamma is not None and red2white is not None:\n", + " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " # load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " # if os.path.exists(load_dets_from_file) is False:\n", + " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " # raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data'][int(NVARS/2)]\n", + " params = file['params'][int(NVARS/2)]\n", + " file.close()\n", + "\n", + " # file = np.load(load_dets_from_file, allow_pickle=True)\n", + " # dsdat = file['dsdat']\n", + " # file.close()\n", + "\n", + " return data, params" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data, params = get_data('hard_time')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hc_ss = data['hc_ss']\n", + "hc_bg = data['hc_bg']\n", + "sspar = data['sspar']\n", + "bgpar = data['bgpar']\n", + "fobs_cents = data['fobs_cents']" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "edgecolors = np.repeat(None, NLOUDEST)\n", + "edgecolors[0] = 'k'\n", + "print(edgecolors)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax_single(\n", + " xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel=plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "\n", + "\n", + "nsamp = 5 # number of sample GWB spectra to plot\n", + "\n", + "xx = fobs_cents * YR\n", + "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", + "\n", + "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", + "\n", + "# Plot the median GWB spectrum\n", + "ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", + "\n", + "\n", + "\n", + "# Plot `nsamp` random spectra \n", + "seed = 67233 # more spread out\n", + "# seed = 98068 # includes random super high\n", + "# seed = np.random.randint(99999) # get a random number\n", + "print(seed) # print it out so we can reuse it if desired\n", + "np.random.seed(seed) # set the random seed\n", + "\n", + "nsamp = np.min([nsamp, NREALS])\n", + "\n", + "colors = [\n", + " '#ff7f0f', # orange\n", + " '#6a3d9a', # purple\n", + " '#f0027f', # pink\n", + " '#a6d853', # green\n", + " '#15becf', # teal\n", + "]\n", + "\n", + "# select random realizations to plot\n", + "idx = np.random.choice(NREALS, nsamp, replace=False)\n", + "for aa, ii in enumerate(idx):\n", + "\n", + " # edgecolors = np.repeat(colors[aa], NLOUDEST).reshape(4, NLOUDEST) # idk why this isnt working\n", + " # edgecolors = np.swapaxes(edgecolors, 0,1)\n", + " # edgecolors[0,:] = np.array([1, 1, 1, 1])\n", + "\n", + " for ll in range(5):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", + "for aa, ii in enumerate(idx):\n", + " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[aa]) \n", + "\n", + "fig.tight_layout()\n", + "# fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_midvars_{seed}.png', dpi=100)\n", + "\n", + "# plot contours at 50% and 98% confidence intervals\n", + "for pp in [50, 98]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", + " \n", + "# plt.show()" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# all parameters" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sings.par_labels)\n", + "\n", + "bgpar = data['bgpar']\n", + "sspar = data['sspar']\n", + "sspar = sings.all_sspars(fobs_cents, sspar)\n", + "\n", + "bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + "sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharex=True, height=5)\n", + "\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "# Plot `nsamp` random spectra \n", + "seed = 67233 # more spread out\n", + "# seed = np.random.randint(99999) # get a random number\n", + "print(seed) # print it out so we can reuse it if desired\n", + "np.random.seed(seed) # set the random seed\n", + "\n", + "# select random realizations to plot\n", + "idx = np.random.choice(NREALS, nsamp, replace=False)\n", + "\n", + "# parameters to plot\n", + "yy_ss = [hc_ss, sspar[0], sspar[1], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4], sspar[5], sspar[6]] # final comoving distance, final separation, final angular separation\n", + "yy_bg = [hc_bg, bgpar[0], bgpar[1], # strain, mass, mass ratio, initial redshift\n", + " bgpar[4], bgpar[5], bgpar[6]]\n", + "ylabels = np.append([plot.LABEL_CHARACTERISTIC_STRAIN,], sings.par_labels)\n", + "ylabels = ['Characteristic Strain', 'Total Mass [M$_\\odot$]', 'Mass Ratio, $q$', \n", + " 'Com. Distance [Mpc]', 'Separation [pc]', 'Separation [rad]']\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " ax.plot(xx, np.median(yy_bg[ii], axis=-1), 'k-')\n", + " for aa, nn in enumerate(idx):\n", + " ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + "\n", + " for aa, nn in enumerate(idx):\n", + " for ll in range(3):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, yy_ss[ii][:,nn,ll], color=colors[aa], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", + "\n", + " # Plot the confidence intervals\n", + " for pp in [50, 95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[ii], percs, axis=-1), alpha=0.25, color='k')\n", + "\n", + " # label axes\n", + " if ii>=3:\n", + " ax.set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " ax.set_ylabel(ylabels[ii])\n", + " \n", + "fig.tight_layout()\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "# +f'/params_midvars_{seed}.png')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vary Parameter\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### truncate colormaps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + "):\n", + "\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " # if red_gamma is not None and red2white is not None:\n", + " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " # load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " # if os.path.exists(load_dets_from_file) is False:\n", + " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " # raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " # file = np.load(load_dets_from_file, allow_pickle=True)\n", + " # dsdat = file['dsdat']\n", + " # file.close()\n", + "\n", + " return data, params" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Hard Time, 3vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NVARS = 21\n", + "NSKIES = 50\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nskies=NSKIES, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the confidence intervals\n", + " for pp in [95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3)\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " # for vv, var in enumerate(parvars):\n", + " # # for aa, nn in enumerate(idx):\n", + " # # for ll in range(3):\n", + " # # edgecolor = 'k' if ll==0 else None\n", + " # ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# GSMF_Phi0, 3vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "NVARS = 21\n", + "NSKIES = 25\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nskies=NSKIES, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the confidence intervals\n", + " for pp in [95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 97471309..02f3cd67 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -46,7 +46,7 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "BUILD_ARRAYS = True\n", + "BUILD_ARRAYS = False\n", "SAVEFIG = False\n", "TOL=0.01\n", "MAXBADS=5\n", @@ -271,7 +271,9 @@ " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", "axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", "\n", - "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", + "# fig.tight_layout()\n", "\n", "SAVEFIG=False\n", "if SAVEFIG:\n", @@ -329,8 +331,8 @@ "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", - "\n", - "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", + "# fig.tight_layout()\n", "\n", "SAVEFIG=False\n", "if SAVEFIG:\n", From 43fad6adacec551332a0699dce930b9da5c870bf Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 01:40:57 -0700 Subject: [PATCH 227/291] Clean up vary_parameter function. --- .../parameter_investigation/detect_model_clbrt_pta.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 7d19408d..93d7cf97 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -113,7 +113,7 @@ def vary_parameter( params_list, # the values we'll check nreals, nfreqs, nloudest, pspace, - pars=None, save_dir=None, debug=True + pars=None, debug=True ): # get the parameter names from this library-space @@ -138,19 +138,10 @@ def vary_parameter( params.append(_params) # construct `sam` and `hard` instances based on these parameters sam, hard = pspace.model_for_params(_params, pspace.sam_shape) - if isinstance(hard, holo.hardening.Fixed_Time_2PL_SAM): - hard_name = 'Fixed Time' - elif isinstance(hard, holo.hardening.Hard_GW): - hard_name = 'GW Only' # run this model, retrieving binary parameters and the GWB _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=nloudest, gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True) data.append(_data) - if save_dir is not None: - str_shape = str(sam.shape).replace(", ", "_").replace("(", "").replace(")", "") - filename = save_dir+'/%s_p%s_s%s.npz' % (target_param, str_pars, str_shape) - np.savez(filename, data=data, params=params, hard_name=hard_name, shape=sam.shape, target_param=target_param ) - if debug: print('saved to %s' % filename) return (data, params) From 5e1ffaa3b935defc0fa25c82e021cfd8a84fdcc6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 01:42:03 -0700 Subject: [PATCH 228/291] Plot hc, mass, and distance for varying hard_time and gsmf_phi0. --- .../paper_plots/charstrain_and_props.ipynb | 85 ++++++++++++++++--- 1 file changed, 74 insertions(+), 11 deletions(-) diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb index eb9adf57..af83e5be 100644 --- a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb +++ b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb @@ -59,10 +59,12 @@ "source": [ "def get_data(\n", " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " path = '/Users/e migardiner/GWs/holodeck/output/anatomy_09B' \n", "):\n", - "\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " if path == '/Users/e migardiner/GWs/holodeck/output/anatomy_09':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " else:\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}.npz' \n", " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", " # if red_gamma is not None and red2white is not None:\n", " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", @@ -316,10 +318,10 @@ "source": [ "def get_data(\n", " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", "\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}.npz' \n", " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", " # if red_gamma is not None and red2white is not None:\n", " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", @@ -525,15 +527,15 @@ "outputs": [], "source": [ "TARGET = 'gsmf_phi0'\n", - "NVARS = 21\n", - "NSKIES = 25\n", + "NVARS = 3\n", "NREALS = 500\n", "\n", - "parvars = [0,5,10,15,20]\n", + "parvars = [0,1,2]\n", "yy_ss = []\n", "yy_bg = []\n", - "data, params = get_data(TARGET, nvars=NVARS, nskies=NSKIES, nreals=NREALS,\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", "for vv, var in enumerate(parvars):\n", " hc_ss = data[var]['hc_ss']\n", " hc_bg = data[var]['hc_bg']\n", @@ -569,7 +571,7 @@ "xx = fobs_cents*YR\n", "nsamp = 5\n", "\n", - "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", "\n", "for ii, ax in enumerate(axs.flatten()):\n", " # Plot the median \n", @@ -613,7 +615,68 @@ "for vv, var in enumerate(parvars):\n", " labels.append(f\"{params[var][TARGET]:.2f}\")\n", "\n", - "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3)\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " # for vv, var in enumerate(parvars):\n", + " # # for aa, nn in enumerate(idx):\n", + " # # for ll in range(3):\n", + " # # edgecolor = 'k' if ll==0 else None\n", + " # ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" ] }, { From 210279875ce0ad25b3cfbc9d86b46bdda1e80608 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 09:59:30 -0700 Subject: [PATCH 229/291] Add scatter points. --- .../paper_plots/charstrain_and_props.ipynb | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb index af83e5be..b8c1e8a2 100644 --- a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb +++ b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb @@ -679,6 +679,60 @@ "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3)\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " xx_ss = np.repeat(xx, NREALS).reshape(NFREQS,NREALS)\n", + " ax.scatter(xx_ss, yy_ss[vv][ii], marker='o', color=colors[vv], alpha=0.1, s=5)\n", + "\n", + "\n", + " # for vv, var in enumerate(parvars):\n", + " # # Plot the loudest single sources confidence intervals\n", + " # for pp in [95,]:\n", + " # percs = pp / 2\n", + " # percs = [50 - percs, 50 + percs]\n", + " # ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" + ] + }, { "cell_type": "code", "execution_count": null, From f68d49f82d7cc9cc1b79fc10405f887d07144ad8 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 10:31:26 -0700 Subject: [PATCH 230/291] Update save paths. --- .../detect_model_clbrt_pta.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 93d7cf97..690bb882 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -3,6 +3,7 @@ import argparse from holodeck import detstats from datetime import datetime +import os # sample DEF_SHAPE = None @@ -157,21 +158,29 @@ def main(): print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) + output_path = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' + # check if output folder already exists, if not, make it. + if os.path.exists(output_path) is False: + os.makedirs(output_path) + if args.load_file is None: - load_data_from_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' + load_data_from_file = output_path+'/data_params' else: load_data_from_file = args.load_file if args.save_file is None: - save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' + save_data_to_file = output_path+'/data_params' else: save_data_to_file = args.save_file - save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' + save_dets_to_file = output_path+f'/detstats_s{args.nskies}' if args.red2white is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' elif args.red_amp is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1f}' + else: + save_dets_to_file = save_dets_to_file+f'_white' + if args.red2white is not None and args.red_amp is not None: print(f"{args.red2white=} and {args.red_amp} both provided. red_amp will be overriden by red2white ratio.") From c94bb8a5473b13925aa43fcc85763f5fed5074dd Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 11:33:05 -0700 Subject: [PATCH 231/291] Add dcom and frequencies to varpar histograms --- .../paper_plots/snr_vs_mass_hist.ipynb | 371 ++++++++++++++++-- 1 file changed, 343 insertions(+), 28 deletions(-) diff --git a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb index 28b454b4..b9016205 100644 --- a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb +++ b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "CALC = False" + "CALC = True" ] }, { @@ -101,10 +101,13 @@ " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", "\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", - " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " path = path + f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}' \n", + " load_data_from_file = path+f'/data_params.npz' \n", + " load_dets_from_file = path+f'/detstats_s{nskies}' \n", " if red_gamma is not None and red2white is not None:\n", " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", " load_dets_from_file = load_dets_from_file+'.npz'\n", "\n", " if os.path.exists(load_data_from_file) is False:\n", @@ -476,47 +479,79 @@ "NSKIES = 100\n", "NVARS = 21\n", "\n", - "if CALC:\n", + "if CALC: \n", " # get edges\n", " NBINS = 40\n", " sam = holo.sams.Semi_Analytic_Model()\n", " mt_edges = sam.mtot[20:-12]/MSOL\n", " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + " dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", + " ff_edges = None # assign in loops\n", "\n", " # get histograms\n", - " ssmtt = []\n", - " snssi = []\n", - " hist = []\n", + " # ssmtt = []\n", + " # ssdcm = []\n", + " # snssi = []\n", + " # ssfrq = []\n", + " hist_mt = []\n", + " hist_dc = []\n", + " hist_ff = []\n", " text = []\n", " for ii in [0,5,10,15,20]: # vars to use\n", " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - " _ssmtt = data['sspar'][0]/MSOL\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " ff_edges = data['fobs_edges']*YR\n", + "\n", + " _ssmtt = sspar[0]/MSOL\n", " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " ssmtt.append(_ssmtt)\n", + " # ssmtt.append(_ssmtt)\n", + "\n", + " _ssdcm = sspar[4]/MPC\n", + " _ssdcm = np.repeat(_ssdcm, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssdcm = np.swapaxes(_ssdcm, -2, -1)\n", + " # ssdcm.append(_ssdcm)\n", + "\n", + " _ssfrq = data['fobs_cents']*YR\n", + " _ssfrq = np.repeat(_ssfrq, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " # ssfrq.append(_ssfrq)\n", "\n", " _snssi = dsdat['snr_ss']\n", - " snssi.append(_snssi)\n", - " # get histogram\n", - " _hist, mte, sne = np.histogram2d(\n", + " # snssi.append(_snssi)\n", + "\n", + " # get histograms\n", + " _hist_mt, sne, mte, = np.histogram2d(\n", " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - " hist.append(_hist)\n", + " hist_mt.append(_hist_mt)\n", + "\n", + " _hist_dc, sne, dce, = np.histogram2d(\n", + " _snssi.flatten(), _ssdcm.flatten(), bins=(sn_edges, dc_edges))\n", + " hist_dc.append(_hist_dc)\n", + "\n", + " _hist_ff, sne, fqe, = np.histogram2d(\n", + " _snssi.flatten(), _ssfrq.flatten(), bins=(sn_edges, ff_edges))\n", + " hist_ff.append(_hist_ff)\n", "\n", " _text = '%.2f' % (params[TARGET])\n", " text.append(_text)\n", - " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - " mt_edges=mt_edges, sn_edges=sn_edges,\n", - " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + " mt_edges=mt_edges, sn_edges=sn_edges, dc_edges=dc_edges,\n", + " # ssmtt=ssmtt, ssdcm=ssdcm, snssi=snssi, \n", + " hist_mt=hist_mt, hist_dc=hist_dc, hist_ff=hist_ff, text=text)\n", "else:\n", - " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", " mt_edges = file['mt_edges']\n", " sn_edges = file['sn_edges']\n", - " ssmtt = file['ssmtt']\n", - " snssi = file['snssi']\n", - " hist = file['hist']\n", + " dc_edges = file['dc_edges']\n", + " # ssmtt = file['ssmtt']\n", + " # ssdcm = file['ssdcm']\n", + " # snssi = file['snssi']\n", + " hist_mt = file['hist_mt']\n", + " hist_dc = file['hist_dc']\n", + " hist_ff = file['hist_ff']\n", " text = file['text']\n", " file.close()" ] @@ -540,9 +575,9 @@ "\n", "# plot histograms\n", "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " im = ax.pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", - " axs[aa].text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", " transform=axs[aa].transAxes, color='k', fontsize=12)\n", " # axs[ii].set_facecolor('k')\n", "\n", @@ -551,13 +586,293 @@ "axs[2].set_xlabel(xlabel)\n", "fig.tight_layout()\n", "\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", "# add colorbar\n", "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", - " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + " orientation='vertical', pad=0.01, label='$\\log N$', )\n", "\n", "# save\n", "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + " + f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Distance [Mpc]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "dcgrid, sngrid, = np.meshgrid(dc_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = ax.pcolormesh(dcgrid, sngrid, np.log10(hist_dc[aa]), cmap=cm.viridis_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.01, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_dcom_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel='Frequency [yr$^{-1}$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "ffgrid, sngrid, = np.meshgrid(ff_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, sharex=True, sharey=True, height=4)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs):\n", + " im = ax.pcolormesh(ffgrid, sngrid, np.log10(hist_ff[aa]), cmap=cm.cubehelix_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=12)\n", + " # axs[ii].set_facecolor('k')\n", + "\n", + "# set labels\n", + "axs[0].set_ylabel(ylabel)\n", + "axs[2].set_xlabel(xlabel)\n", + "fig.tight_layout()\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.01, label='$\\log N$', )\n", + "\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_dcom_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Combined" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel1='Mass [M$_\\odot$]'\n", + "xlabel2='Distance [Mpc]'\n", + "xlabel3='Frequency [yr$^{-1}$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid1, = np.meshgrid(mt_edges, sn_edges)\n", + "dcgrid, sngrid2, = np.meshgrid(dc_edges, sn_edges)\n", + "ffgrid, sngrid3 = np.meshgrid(ff_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, nrows=3, sharex=False, sharey=True, height=8)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs[0,:]):\n", + " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[aa]), cmap=magma_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "# # axs[ii].set_facecolor('k')\n", + "\n", + "# plot dcom histograms\n", + "for aa, ax in enumerate(axs[1,:]):\n", + " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[aa]), cmap=cm.viridis_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " # transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "# plot freq histograms\n", + "for aa, ax in enumerate(axs[2,:]):\n", + " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[aa]), cmap=cm.cubehelix_r)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.01, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='bottom', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "\n", + "\n", + "# set labels\n", + "axs[1,0].set_ylabel(ylabel)\n", + "axs[0,2].set_xlabel(xlabel1)\n", + "axs[1,2].set_xlabel(xlabel2)\n", + "axs[2,2].set_xlabel(xlabel3)\n", + "fig.tight_layout()\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "# add colorbar\n", + "for ii, im in enumerate([im1, im2, im3]):\n", + " plt.colorbar(im, ax=axs[ii,:].ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_props_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel1='Mass [M$_\\odot$]'\n", + "xlabel2='Distance [Mpc]'\n", + "xlabel3='Frequency [yr$^{-1}$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid1, = np.meshgrid(mt_edges, sn_edges)\n", + "dcgrid, sngrid2, = np.meshgrid(dc_edges, sn_edges)\n", + "ffgrid, sngrid3 = np.meshgrid(ff_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_double(\n", + " ncols=5, nrows=3, sharex=False, sharey=True, height=8)\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs[0,:]):\n", + " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[aa]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "# # axs[ii].set_facecolor('k')\n", + "\n", + "# plot dcom histograms\n", + "for aa, ax in enumerate(axs[1,:]):\n", + " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[aa]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", + " # transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "# plot freq histograms\n", + "for aa, ax in enumerate(axs[2,:]):\n", + " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[aa]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.01, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], horizontalalignment='left', verticalalignment='bottom', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "\n", + "\n", + "# set labels\n", + "axs[1,0].set_ylabel(ylabel)\n", + "axs[0,2].set_xlabel(xlabel1)\n", + "axs[1,2].set_xlabel(xlabel2)\n", + "axs[2,2].set_xlabel(xlabel3)\n", + "fig.tight_layout()\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "# add colorbar\n", + "# for ii, im in enumerate([im1, im2, im3]):\n", + "plt.colorbar(im2, ax=axs.ravel().tolist(), shrink=0.5, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_props_bluehist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel1='Mass [M$_\\odot$]'\n", + "xlabel2='Distance [Mpc]'\n", + "xlabel3='Frequency [yr$^{-1}$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid1, = np.meshgrid(mt_edges, sn_edges)\n", + "dcgrid, sngrid2, = np.meshgrid(dc_edges, sn_edges)\n", + "ffgrid, sngrid3 = np.meshgrid(ff_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_single(\n", + " ncols=3, nrows=3, sharex=False, sharey=True, height=8)\n", + "\n", + "cols = [0,2,4]\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs[0,:]):\n", + " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "# # axs[ii].set_facecolor('k')\n", + "\n", + "# plot dcom histograms\n", + "for aa, ax in enumerate(axs[1,:]):\n", + " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", + " # transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "# plot freq histograms\n", + "for aa, ax in enumerate(axs[2,:]):\n", + " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.01, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='bottom', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "\n", + "\n", + "# set labels\n", + "axs[1,0].set_ylabel(ylabel)\n", + "axs[0,1].set_xlabel(xlabel1)\n", + "axs[1,1].set_xlabel(xlabel2)\n", + "axs[2,1].set_xlabel(xlabel3)\n", + "fig.tight_layout()\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "# add colorbar\n", + "# for ii, im in enumerate([im1, im2, im3]):\n", + "plt.colorbar(im2, ax=axs.ravel().tolist(), shrink=0.5, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_props_bluehist_{TARGET}_v{NVARS}_3axs.png', dpi=100)" ] }, { @@ -709,7 +1024,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "SNR or DP vs. Frequency" + "SNR or DP vs. distance" ] }, { From 1d3763f5905023252c06f27290e1b28321925ae7 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 12:48:22 -0700 Subject: [PATCH 232/291] Plot hc 3x6. --- .../paper_plots/charstrain_and_props.ipynb | 451 +++++++++++++++++- 1 file changed, 439 insertions(+), 12 deletions(-) diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb index b8c1e8a2..ae50089f 100644 --- a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb +++ b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb @@ -57,14 +57,14 @@ "metadata": {}, "outputs": [], "source": [ - "def get_data(\n", + "def get_mid_data(\n", " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", - " path = '/Users/e migardiner/GWs/holodeck/output/anatomy_09B' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B', mid=True, \n", "):\n", - " if path == '/Users/e migardiner/GWs/holodeck/output/anatomy_09':\n", + " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_09B':\n", " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", " else:\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}.npz' \n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", " # if red_gamma is not None and red2white is not None:\n", " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", @@ -77,8 +77,12 @@ " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", " # raise Exception(err)\n", " file = np.load(load_data_from_file, allow_pickle=True)\n", - " data = file['data'][int(NVARS/2)]\n", - " params = file['params'][int(NVARS/2)]\n", + " if(mid):\n", + " data = file['data'][int(NVARS/2)]\n", + " params = file['params'][int(NVARS/2)]\n", + " else:\n", + " data = file['data']\n", + " params = file['params']\n", " file.close()\n", "\n", " # file = np.load(load_dets_from_file, allow_pickle=True)\n", @@ -94,7 +98,7 @@ "metadata": {}, "outputs": [], "source": [ - "data, params = get_data('hard_time')" + "data, params = get_mid_data('hard_time', nskies=25)" ] }, { @@ -321,11 +325,10 @@ " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", "\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}.npz' \n", - " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", - " # if red_gamma is not None and red2white is not None:\n", - " # load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", - " # load_dets_from_file = load_dets_from_file+'.npz'\n", + " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_09B':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " else:\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", "\n", " if os.path.exists(load_data_from_file) is False:\n", " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", @@ -512,6 +515,179 @@ "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Separate char strains" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,5,10,15,20]\n", + "hc_ss_all = []\n", + "hc_bg_all = []\n", + "text = []\n", + "\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(params[var][TARGET])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsamp = 5 # number of sample GWB spectra to plot\n", + "colors = [\n", + " '#ff7f0f', # orange\n", + " '#6a3d9a', # purple\n", + " '#f0027f', # pink\n", + " '#a6d853', # green\n", + " '#15becf', # teal\n", + "]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, sharex=True, sharey=True, height=8)\n", + "axs[1].set_ylabel(plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(hspace=0)\n", + "\n", + "# plot as a function of frequency /yr\n", + "xx = fobs_cents * YR\n", + "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", + "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "\n", + "\n", + "\n", + "\n", + "for aa, vv, in enumerate([0,2,4]):\n", + " ax = axs[aa]\n", + "\n", + " ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", + "\n", + " hc_ss = hc_ss_all[vv]\n", + " hc_bg = hc_bg_all[vv]\n", + " print(f\"{hc_ss.shape=}, {hc_bg.shape=}\")\n", + "\n", + " # Plot the median GWB spectrum\n", + " ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", + "\n", + " # Plot `nsamp` random spectra \n", + " seed = np.random.randint(99999) # get a random number\n", + " print(f\"{ii=}, {seed=}\") # print it out so we can reuse it if desired\n", + " np.random.seed(seed) # set the random seed\n", + "\n", + " nsamp = np.min([nsamp, NREALS])\n", + "\n", + " # select random realizations to plot\n", + " idx = np.random.choice(NREALS, nsamp, replace=False)\n", + " for cc, ii in enumerate(idx):\n", + "\n", + " for ll in range(5):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[cc], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", + " for cc, ii in enumerate(idx):\n", + " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[cc]) \n", + "\n", + " # plot contours at 50% and 98% confidence intervals\n", + " for pp in [50, 98]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", + " \n", + " label = \"$\\\\tau_\\mathrm{hard}$=%.2f\" % text[vv]\n", + " ax.text(0.01,0.01,label, transform=ax.transAxes, horizontalalignment='left', verticalalignment='bottom')\n", + " \n", + "# plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsamp = 5 # number of sample GWB spectra to plot\n", + "colors = [\n", + " '#ff7f0f', # orange\n", + " '#6a3d9a', # purple\n", + " '#f0027f', # pink\n", + " '#a6d853', # green\n", + " '#15becf', # teal\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(ncols=3, sharex=True, sharey=True, height=3)\n", + "axs[0].set_ylabel(plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "axs[1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", + "# plot as a function of frequency /yr\n", + "xx = fobs_cents * YR\n", + "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", + "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "\n", + "\n", + "\n", + "\n", + "for aa, vv, in enumerate([0,2,4]):\n", + " ax = axs[aa]\n", + "\n", + " ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", + "\n", + " hc_ss = hc_ss_all[vv]\n", + " hc_bg = hc_bg_all[vv]\n", + " print(f\"{hc_ss.shape=}, {hc_bg.shape=}\")\n", + "\n", + " # Plot the median GWB spectrum\n", + " ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", + "\n", + " # Plot `nsamp` random spectra \n", + " seed = np.random.randint(99999) # get a random number\n", + " print(f\"{ii=}, {seed=}\") # print it out so we can reuse it if desired\n", + " np.random.seed(seed) # set the random seed\n", + "\n", + " nsamp = np.min([nsamp, NREALS])\n", + "\n", + " # select random realizations to plot\n", + " idx = np.random.choice(NREALS, nsamp, replace=False)\n", + " for cc, ii in enumerate(idx):\n", + "\n", + " for ll in range(5):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[cc], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", + " for cc, ii in enumerate(idx):\n", + " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[cc]) \n", + "\n", + " # plot contours at 50% and 98% confidence intervals\n", + " for pp in [50, 98]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", + " \n", + " label = \"$\\\\tau_\\mathrm{hard}$=%.2f\" % text[vv]\n", + " ax.text(0.01,0.01,label, transform=ax.transAxes, horizontalalignment='left', verticalalignment='bottom')\n", + " \n", + "# plt.show()" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -733,6 +909,257 @@ "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# The charstrain plot to end all charstrain plots" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,1,2]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'gsmf_phi0'\n", + "data, params = get_data(TARGET, nvars=3, nreals=500, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\psi_0$=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_phi0 = hc_ss_all\n", + "hc_bg_phi0 = hc_bg_all\n", + "text_phi0 = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,1,2]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'gsmf_mchar0_log10'\n", + "data, params = get_data(TARGET, nvars=3, nreals=500, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"log($M_{\\psi,0}$/M$_\\odot$)=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_mchar0 = hc_ss_all\n", + "hc_bg_mchar0 = hc_bg_all\n", + "text_mchar0 = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'mmb_mamp_log10'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"log($\\mu$/M$_\\odot$)=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_mamp = hc_ss_all\n", + "hc_bg_mamp = hc_bg_all\n", + "text_mamp = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'mmb_scatter_dex'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\epsilon_\\mu$=%.2f dex\" % params[var][TARGET])\n", + "\n", + "hc_ss_scatter = hc_ss_all\n", + "hc_bg_scatter = hc_bg_all\n", + "text_scatter = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all = []\n", + "text = []\n", + "TARGET = 'hard_time'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\\\tau_\\mathrm{hard}=%.2f$\" % params[var][TARGET])\n", + "\n", + "hc_ss_hardtime = hc_ss_all\n", + "hc_bg_hardtime = hc_bg_all\n", + "text_hardtime = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'hard_gamma_inner'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\\\nu_\\mathrm{inner}$=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_gamma = hc_ss_all\n", + "hc_bg_gamma = hc_bg_all\n", + "text_gamma = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.shares_memory(hc_ss_hardtime, hc_ss_all))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsamp = 5 # number of sample GWB spectra to plot\n", + "colors = [\n", + " '#ff7f0f', # orange\n", + " '#6a3d9a', # purple\n", + " '#f0027f', # pink\n", + " '#a6d853', # green\n", + " '#15becf', # teal\n", + "]\n", + "\n", + "target_colors = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41',\n", + " '#2d839f', '#2d839f',\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(ncols=3, nrows = 6, sharex=True, sharey=True, height=14)\n", + "# axs[0].set_ylabel(plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "fig.text(0.04, 0.5, plot.LABEL_CHARACTERISTIC_STRAIN, ha='center', va='bottom', rotation='vertical')\n", + "axs[-1, 1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "\n", + "# plot as a function of frequency /yr\n", + "xx = fobs_cents * YR\n", + "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", + "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "\n", + "\n", + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex', 'hard_time', 'hard_gamma_inner']\n", + "hc_ss_targets = [hc_ss_phi0, hc_ss_mchar0, hc_ss_mamp, hc_ss_scatter, hc_ss_hardtime, hc_ss_gamma]\n", + "hc_bg_targets = [hc_bg_phi0, hc_bg_mchar0, hc_bg_mamp, hc_bg_scatter, hc_bg_hardtime, hc_bg_gamma]\n", + "text_targets = [text_phi0, text_mchar0, text_mamp, text_scatter, text_hardtime, text_gamma]\n", + "for rr, ax_row in enumerate(axs):\n", + " text = text_targets[rr]\n", + " hc_ss_all = hc_ss_targets[rr]\n", + " hc_bg_all = hc_bg_targets[rr]\n", + " for cc, ax in enumerate(ax_row):\n", + " \n", + " ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", + "\n", + " hc_ss = hc_ss_all[cc]\n", + " hc_bg = hc_bg_all[cc]\n", + "\n", + " # Plot the median GWB spectrum\n", + " ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", + "\n", + " # Plot `nsamp` random spectra \n", + " seed = np.random.randint(99999) # get a random number\n", + " print(f\"{ii=}, {seed=}\") # print it out so we can reuse it if desired\n", + " np.random.seed(seed) # set the random seed\n", + "\n", + " nsamp = np.min([nsamp, NREALS])\n", + "\n", + " # select random realizations to plot\n", + " idx = np.random.choice(NREALS, nsamp, replace=False)\n", + " for ci, ii in enumerate(idx):\n", + "\n", + " for ll in range(5):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[ci], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", + " for ci, ii in enumerate(idx):\n", + " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[ci]) \n", + "\n", + " # plot contours at 50% and 98% confidence intervals\n", + " for pp in [50, 98]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", + " ax.text(\n", + " 0.01,0.01, text[cc], transform=ax.transAxes, color=target_colors[rr],\n", + " horizontalalignment='left', verticalalignment='bottom')\n", + " \n", + " # plt.show()\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_3x6.png', dpi=300)" + ] + }, { "cell_type": "code", "execution_count": null, From 764e98d685cb77d62cda846c6a577f5c9e6f7901 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 15:52:24 -0700 Subject: [PATCH 233/291] Improve strain and property for varpar plots. --- .../paper_plots/charstrain_and_props.ipynb | 674 +++++++++++++++--- 1 file changed, 591 insertions(+), 83 deletions(-) diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb index ae50089f..94df96f4 100644 --- a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb +++ b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb @@ -26,6 +26,37 @@ "import os\n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### truncate colormaps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", + "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -271,8 +302,10 @@ " ax.set_ylabel(ylabels[ii])\n", " \n", "fig.tight_layout()\n", - "# fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - "# +f'/params_midvars_{seed}.png')" + "plt.subplots_adjust(hspace=0) \n", + "\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " +f'/params_midvars_{seed}.png')" ] }, { @@ -283,37 +316,6 @@ "# Vary Parameter\n" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### truncate colormaps" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", - " '''\n", - " https://stackoverflow.com/a/18926541\n", - " '''\n", - " if isinstance(cmap, str):\n", - " cmap = plt.get_cmap(cmap)\n", - " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", - " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", - " cmap(np.linspace(minval, maxval, n)))\n", - " return new_cmap\n", - "\n", - "\n", - "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", - "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", - "cmap_Greens = truncate_colormap('Greens', 0.4, 1)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -454,6 +456,14 @@ "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## fave hard_time" + ] + }, { "cell_type": "code", "execution_count": null, @@ -479,17 +489,6 @@ " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", " handles.append(hh)\n", "\n", - " # for vv, var in enumerate(parvars):\n", - " # # for aa, nn in enumerate(idx):\n", - " # # for ll in range(3):\n", - " # # edgecolor = 'k' if ll==0 else None\n", - " # ymed = np.median(yy_ss[vv][ii], axis=-1)\n", - " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", - " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", - " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", - " # capsize=3, marker=None)\n", - " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", - "\n", "\n", " for vv, var in enumerate(parvars):\n", " # Plot the loudest single sources confidence intervals\n", @@ -512,7 +511,9 @@ "for vv, var in enumerate(parvars):\n", " labels.append(f\"{params[var][TARGET]:.2f}\")\n", "\n", - "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')\n", + "# fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/charstrain_pars_vs_freq_var5_{TARGET}.png',\n", + " # dpi=300)" ] }, { @@ -693,7 +694,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# GSMF_Phi0, 3vars" + "# GSMF_Phi0, 5vars" ] }, { @@ -703,10 +704,10 @@ "outputs": [], "source": [ "TARGET = 'gsmf_phi0'\n", - "NVARS = 3\n", + "NVARS = 21\n", "NREALS = 500\n", "\n", - "parvars = [0,1,2]\n", + "parvars = [0,5,10,15,20]\n", "yy_ss = []\n", "yy_bg = []\n", "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", @@ -740,7 +741,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", " 'Distance [Mpc]',]\n", "\n", "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", @@ -748,34 +749,34 @@ "nsamp = 5\n", "\n", "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", "\n", "for ii, ax in enumerate(axs.flatten()):\n", " # Plot the median \n", " handles=[]\n", " for vv, var in enumerate(parvars): \n", - " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=2, linestyle='-')\n", " # for aa, nn in enumerate(idx):\n", " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", " handles.append(hh)\n", "\n", " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " for vv, var in enumerate(parvars):\n", " # for aa, nn in enumerate(idx):\n", " # for ll in range(3):\n", " # edgecolor = 'k' if ll==0 else None\n", " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", - " ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", - " ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", - " ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", - " capsize=3, marker=None)\n", - " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", - "\n", - "\n", - " for vv, var in enumerate(parvars):\n", - " # Plot the confidence intervals\n", - " for pp in [95]:\n", - " percs = pp / 2\n", - " percs = [50 - percs, 50 + percs]\n", - " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[var], alpha=0.8, s=20)\n", "\n", "\n", " # label axes\n", @@ -791,7 +792,9 @@ "for vv, var in enumerate(parvars):\n", " labels.append(f\"{params[var][TARGET]:.2f}\")\n", "\n", - "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_midpoints.png',\n", + " dpi=300)" ] }, { @@ -814,29 +817,30 @@ " # Plot the median \n", " handles=[]\n", " for vv, var in enumerate(parvars): \n", - " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3)\n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=2, linestyle='-')\n", " # for aa, nn in enumerate(idx):\n", " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", " handles.append(hh)\n", "\n", - " # for vv, var in enumerate(parvars):\n", - " # # for aa, nn in enumerate(idx):\n", - " # # for ll in range(3):\n", - " # # edgecolor = 'k' if ll==0 else None\n", - " # ymed = np.median(yy_ss[vv][ii], axis=-1)\n", - " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", - " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", - " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", - " # capsize=3, marker=None)\n", - " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", - "\n", - "\n", " for vv, var in enumerate(parvars):\n", " # Plot the loudest single sources confidence intervals\n", - " for pp in [95,]:\n", + " for pp in [68,]:\n", " percs = pp / 2\n", " percs = [50 - percs, 50 + percs]\n", - " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " ax.scatter(xx, ymax, marker='v', color=colors[var], alpha=0.8, s=20)\n", + "\n", + " ax.scatter(xx, ymin, marker='^', color=colors[var], alpha=0.8, s=20)\n", "\n", "\n", " # label axes\n", @@ -852,7 +856,198 @@ "for vv, var in enumerate(parvars):\n", " labels.append(f\"{params[var][TARGET]:.2f}\")\n", "\n", - "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}.png',\n", + " dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_95ci(xx, yy_ss, yy_bg, colors):\n", + " ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_95ci.png',\n", + " dpi=300)\n", + " return fig\n", + "fig = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_errbars(xx, yy_ss, yy_bg, colors):\n", + " ylabels = ['Char. Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the confidence intervals\n", + " for pp in [95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_errbars.png',\n", + " dpi=300)\n", + " return fig\n", + "fig = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_uplims(xx, yy_ss, yy_bg, colors):\n", + " ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " if ii == 2:\n", + " ax.errorbar(xx, ymin, yerr=(ymin-ymin, ymed-ymin), color=colors[var], alpha=0.5, \n", + " capsize=2, lolims=True, marker='o', markersize=3, linestyle='')\n", + " else:\n", + " ax.errorbar(xx, ymax, yerr=(ymax-ymed, ymax-ymax), color=colors[var], alpha=0.5, \n", + " capsize=2, uplims=True, marker='o', markersize=3, linestyle='')\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + " \n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_uplims_68ci.png',\n", + " dpi=300)\n", + " return fig\n", + "fig = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" ] }, { @@ -882,7 +1077,7 @@ "\n", " for vv, var in enumerate(parvars):\n", " xx_ss = np.repeat(xx, NREALS).reshape(NFREQS,NREALS)\n", - " ax.scatter(xx_ss, yy_ss[vv][ii], marker='o', color=colors[vv], alpha=0.1, s=5)\n", + " ax.scatter(xx_ss, yy_ss[vv][ii], marker='o', color=colors[var], alpha=0.1, s=5)\n", "\n", "\n", " # for vv, var in enumerate(parvars):\n", @@ -906,7 +1101,320 @@ "for vv, var in enumerate(parvars):\n", " labels.append(f\"{params[var][TARGET]:.2f}\")\n", "\n", - "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])" + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_scatter.png',\n", + " dpi=300)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plots From Functions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GSMF_phi0, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GSMF_mchar0_log10, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## mmb_mamp_log10, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_mamp_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_scatter_dex" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_scatter_dex'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))" ] }, { @@ -1157,7 +1665,7 @@ " horizontalalignment='left', verticalalignment='bottom')\n", " \n", " # plt.show()\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_3x6.png', dpi=300)" + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_3x6.png', dpi=300)" ] }, { From c6ab1a41d235b402a08e09bc9c137d4bb9ca73da Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 15:52:50 -0700 Subject: [PATCH 234/291] Edit plots. --- .../paper_plots/snr_vs_mass_hist.ipynb | 85 ++++++++++++++++++- 1 file changed, 83 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb index b9016205..34ec0118 100644 --- a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb +++ b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb @@ -496,24 +496,33 @@ " hist_mt = []\n", " hist_dc = []\n", " hist_ff = []\n", + " bghist_mt = []\n", + " bghist_dc = []\n", + " bghist_ff = []\n", " text = []\n", " for ii in [0,5,10,15,20]: # vars to use\n", " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " bgpar = data['bgpar']\n", " ff_edges = data['fobs_edges']*YR\n", "\n", + " # total mass\n", " _ssmtt = sspar[0]/MSOL\n", " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " # ssmtt.append(_ssmtt)\n", "\n", + " _bgmtt = bg\n", + "\n", + " # comoving distance\n", " _ssdcm = sspar[4]/MPC\n", " _ssdcm = np.repeat(_ssdcm, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", " _ssdcm = np.swapaxes(_ssdcm, -2, -1)\n", " # ssdcm.append(_ssdcm)\n", "\n", - " _ssfrq = data['fobs_cents']*YR\n", + " # frequencies\n", + " _bgfrq = data['fobs_cents']*YR\n", + " _bgfrq = np.repeat(_bgfrq, NREALS).reshape()\n", " _ssfrq = np.repeat(_ssfrq, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", " # ssfrq.append(_ssfrq)\n", "\n", @@ -875,6 +884,78 @@ " + f'/snr_vs_props_bluehist_{TARGET}_v{NVARS}_3axs.png', dpi=100)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Add background" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# PLOT\n", + "xlabel1='Mass [M$_\\odot$]'\n", + "xlabel2='Distance [Mpc]'\n", + "xlabel3='Frequency [yr$^{-1}$]'\n", + "ylabel='SNR'\n", + "\n", + "# build grid from edges\n", + "mtgrid, sngrid1, = np.meshgrid(mt_edges, sn_edges)\n", + "dcgrid, sngrid2, = np.meshgrid(dc_edges, sn_edges)\n", + "ffgrid, sngrid3 = np.meshgrid(ff_edges, sn_edges)\n", + "\n", + "# make figure\n", + "fig, axs = plot.figax_single(\n", + " ncols=3, nrows=3, sharex=False, sharey=True, height=8)\n", + "\n", + "cols = [0,2,4]\n", + "\n", + "# plot histograms\n", + "for aa, ax in enumerate(axs[0,:]):\n", + " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "# # axs[ii].set_facecolor('k')\n", + "\n", + "# plot dcom histograms\n", + "for aa, ax in enumerate(axs[1,:]):\n", + " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", + " # transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "# plot freq histograms\n", + "for aa, ax in enumerate(axs[2,:]):\n", + " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.01, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='bottom', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "\n", + "\n", + "# set labels\n", + "axs[1,0].set_ylabel(ylabel)\n", + "axs[0,1].set_xlabel(xlabel1)\n", + "axs[1,1].set_xlabel(xlabel2)\n", + "axs[2,1].set_xlabel(xlabel3)\n", + "fig.tight_layout()\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "# add colorbar\n", + "# for ii, im in enumerate([im1, im2, im3]):\n", + "plt.colorbar(im2, ax=axs.ravel().tolist(), shrink=0.5, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " + f'/snr_vs_props_bluehist_{TARGET}_v{NVARS}_3axs.png', dpi=100)" + ] + }, { "cell_type": "code", "execution_count": null, From 1cf0574efb02236ca4094f440dfef00c8fb3d79c Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 3 Jul 2023 17:03:51 -0700 Subject: [PATCH 235/291] Calculate background histograms. --- .../paper_plots/snr_vs_mass_hist.ipynb | 609 +++++++++++------- 1 file changed, 374 insertions(+), 235 deletions(-) diff --git a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb index 34ec0118..af08db67 100644 --- a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb +++ b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb @@ -59,7 +59,8 @@ " return new_cmap\n", "\n", "cmap_base = 'magma_r'\n", - "magma_r = truncate_colormap(cmap_base, 0, 0.85)" + "magma_r = truncate_colormap(cmap_base, 0, 0.85)\n", + "blacks = truncate_colormap('binary', 0.4, 1.0)" ] }, { @@ -96,8 +97,7 @@ "metadata": {}, "outputs": [], "source": [ - "def get_var_data(\n", - " target, var=int(NVARS/2), nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + "def get_var_data( target, var=int(NVARS/2), nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", "\n", @@ -478,8 +478,9 @@ "TARGET = 'hard_time'\n", "NSKIES = 100\n", "NVARS = 21\n", + "CALC=False\n", "\n", - "if CALC: \n", + "def calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES):\n", " # get edges\n", " NBINS = 40\n", " sam = holo.sams.Semi_Analytic_Model()\n", @@ -489,10 +490,6 @@ " ff_edges = None # assign in loops\n", "\n", " # get histograms\n", - " # ssmtt = []\n", - " # ssdcm = []\n", - " # snssi = []\n", - " # ssfrq = []\n", " hist_mt = []\n", " hist_dc = []\n", " hist_ff = []\n", @@ -512,43 +509,68 @@ " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", "\n", - " _bgmtt = bg\n", + " _bgmtt = bgpar[0]/MSOL # F,R\n", + " print(f\"{_bgmtt.shape=}\")\n", "\n", " # comoving distance\n", " _ssdcm = sspar[4]/MPC\n", " _ssdcm = np.repeat(_ssdcm, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", " _ssdcm = np.swapaxes(_ssdcm, -2, -1)\n", - " # ssdcm.append(_ssdcm)\n", + "\n", + " _bgdcm = bgpar[4]/MPC\n", "\n", " # frequencies\n", " _bgfrq = data['fobs_cents']*YR\n", - " _bgfrq = np.repeat(_bgfrq, NREALS).reshape()\n", - " _ssfrq = np.repeat(_ssfrq, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " # ssfrq.append(_ssfrq)\n", + " _bgfrq = np.repeat(_bgfrq, NREALS).reshape(NFREQS, NREALS)\n", + " _ssfrq = np.repeat(_bgfrq, NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", "\n", + " # snr\n", " _snssi = dsdat['snr_ss']\n", - " # snssi.append(_snssi)\n", + " _snrbg = dsdat['snr_bg']\n", + " _snrbg = np.repeat(_snrbg, NFREQS).reshape(NREALS, NFREQS)\n", + " _snrbg = np.swapaxes(_snrbg, 0, 1)\n", + " print(f\"{_snrbg.shape=}\")\n", "\n", - " # get histograms\n", + " # get total mass histograms\n", " _hist_mt, sne, mte, = np.histogram2d(\n", " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", " hist_mt.append(_hist_mt)\n", "\n", + " _bghist_mt, sne, mte, = np.histogram2d(\n", + " _snrbg.flatten(), _bgmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " bghist_mt.append(_bghist_mt)\n", + "\n", + " # get comoving distance histograms\n", " _hist_dc, sne, dce, = np.histogram2d(\n", " _snssi.flatten(), _ssdcm.flatten(), bins=(sn_edges, dc_edges))\n", " hist_dc.append(_hist_dc)\n", "\n", + " _bghist_dc, sne, dce = np.histogram2d(\n", + " _snrbg.flatten(), _bgdcm.flatten(), bins=(sn_edges, dc_edges))\n", + " bghist_dc.append(_bghist_dc)\n", + "\n", + " # get frequencie histograms\n", " _hist_ff, sne, fqe, = np.histogram2d(\n", " _snssi.flatten(), _ssfrq.flatten(), bins=(sn_edges, ff_edges))\n", " hist_ff.append(_hist_ff)\n", "\n", + " _bghist_ff, sne, fqe = np.histogram2d(\n", + " _snrbg.flatten(), _bgfrq.flatten(), bins=(sn_edges, ff_edges))\n", + " bghist_ff.append(_bghist_ff)\n", + " \n", + "\n", " _text = '%.2f' % (params[TARGET])\n", " text.append(_text)\n", " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz',\n", " mt_edges=mt_edges, sn_edges=sn_edges, dc_edges=dc_edges,\n", - " # ssmtt=ssmtt, ssdcm=ssdcm, snssi=snssi, \n", - " hist_mt=hist_mt, hist_dc=hist_dc, hist_ff=hist_ff, text=text)\n", + " hist_mt=hist_mt, hist_dc=hist_dc, hist_ff=hist_ff, text=text,\n", + " bghist_mt = bghist_mt, bghist_dc=bghist_dc, bghist_ff=bghist_ff,\n", + " )\n", + "\n", + "\n", + "if CALC: \n", + " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", "else:\n", " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", @@ -562,6 +584,9 @@ " hist_dc = file['hist_dc']\n", " hist_ff = file['hist_ff']\n", " text = file['text']\n", + " bghist_mt = file['bghist_mt']\n", + " bghist_dc = file['bghist_dc']\n", + " bghist_ff = file['bghist_ff']\n", " file.close()" ] }, @@ -918,6 +943,7 @@ "# plot histograms\n", "for aa, ax in enumerate(axs[0,:]):\n", " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " im0 = ax.pcolormesh(mtgrid, sngrid1, np.log10(bghist_mt[cols[aa]]), cmap=blacks, alpha=0.75)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", " transform=ax.transAxes, color='k', fontsize=12)\n", @@ -926,6 +952,7 @@ "# plot dcom histograms\n", "for aa, ax in enumerate(axs[1,:]):\n", " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " im0 = ax.pcolormesh(dcgrid, sngrid2, np.log10(bghist_dc[cols[aa]]), cmap=blacks, alpha=0.75)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", " # transform=ax.transAxes, color='k', fontsize=12)\n", @@ -933,6 +960,7 @@ "# plot freq histograms\n", "for aa, ax in enumerate(axs[2,:]):\n", " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", + " im0 = ax.pcolormesh(ffgrid, sngrid3, np.log10(bghist_ff[cols[aa]]), cmap=blacks, alpha=0.75)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " ax.text(0.01, 0.01, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='bottom', \n", " transform=ax.transAxes, color='k', fontsize=12)\n", @@ -962,39 +990,39 @@ "metadata": {}, "outputs": [], "source": [ - "# PLOT\n", - "xlabel='Mass [M$_\\odot$]'\n", - "ylabel='SNR'\n", - "\n", - "# build grid from edges\n", - "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", - "\n", - "# make figure\n", - "fig, axs = plot.figax_single(\n", - " nrows=5, sharex=True, sharey=True, height=16)\n", - "\n", - "# plot histograms\n", - "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=cm.magma_r)\n", - " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", - " axs[aa].text(0, 1, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], \n", - " horizontalalignment='left', verticalalignment='top', \n", - " transform=axs[aa].transAxes, color='k', fontsize=18)\n", - " # axs[ii].set_facecolor('k')\n", + "# # PLOT\n", + "# xlabel='Mass [M$_\\odot$]'\n", + "# ylabel='SNR'\n", + "\n", + "# # build grid from edges\n", + "# mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", + "\n", + "# # make figure\n", + "# fig, axs = plot.figax_single(\n", + "# nrows=5, sharex=True, sharey=True, height=16)\n", + "\n", + "# # plot histograms\n", + "# for aa, ax in enumerate(axs):\n", + "# im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=cm.magma_r)\n", + "# # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + "# axs[aa].text(0, 1, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], \n", + "# horizontalalignment='left', verticalalignment='top', \n", + "# transform=axs[aa].transAxes, color='k', fontsize=18)\n", + "# # axs[ii].set_facecolor('k')\n", "\n", - "# set labels\n", - "axs[2].set_ylabel(ylabel)\n", - "axs[-1].set_xlabel(xlabel)\n", - "fig.tight_layout()\n", + "# # set labels\n", + "# axs[2].set_ylabel(ylabel)\n", + "# axs[-1].set_xlabel(xlabel)\n", + "# fig.tight_layout()\n", "\n", - "# add colorbar\n", - "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", - " orientation='horizontal', pad=0.08, label='$\\log N$', )\n", + "# # add colorbar\n", + "# plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + "# orientation='horizontal', pad=0.08, label='$\\log N$', )\n", "\n", "\n", - "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + "# # save\n", + "# fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "# + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, { @@ -1014,50 +1042,71 @@ "TARGET = 'hard_gamma_inner'\n", "NSKIES = 100\n", "NVARS = 21\n", + "CALC=True\n", "\n", - "if CALC:\n", - " # get edges\n", - " NBINS = 40\n", - " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[20:-12]/MSOL\n", - " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - " # get histograms\n", - " ssmtt = []\n", - " snssi = []\n", - " hist = []\n", - " text = []\n", - " for ii in [0,5,10,15,20]: # vars to use\n", - " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - " _ssmtt = data['sspar'][0]/MSOL\n", - " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " ssmtt.append(_ssmtt)\n", - "\n", - " _snssi = dsdat['snr_ss']\n", - " snssi.append(_snssi)\n", - " # get histogram\n", - " _hist, mte, sne = np.histogram2d(\n", - " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - " hist.append(_hist)\n", - "\n", - " _text = '%.2f' % (params[TARGET])\n", - " text.append(_text)\n", - " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - " mt_edges=mt_edges, sn_edges=sn_edges,\n", - " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "if CALC: \n", + " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", "else:\n", - " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", " mt_edges = file['mt_edges']\n", " sn_edges = file['sn_edges']\n", - " ssmtt = file['ssmtt']\n", - " snssi = file['snssi']\n", - " hist = file['hist']\n", + " dc_edges = file['dc_edges']\n", + " # ssmtt = file['ssmtt']\n", + " # ssdcm = file['ssdcm']\n", + " # snssi = file['snssi']\n", + " hist_mt = file['hist_mt']\n", + " hist_dc = file['hist_dc']\n", + " hist_ff = file['hist_ff']\n", " text = file['text']\n", + " bghist_mt = file['bghist_mt']\n", + " bghist_dc = file['bghist_dc']\n", + " bghist_ff = file['bghist_ff']\n", " file.close()\n", + "\n", + "# if CALC:\n", + "# # get edges\n", + "# NBINS = 40\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[20:-12]/MSOL\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# # get histograms\n", + "# ssmtt = []\n", + "# snssi = []\n", + "# hist = []\n", + "# text = []\n", + "# for ii in [0,5,10,15,20]: # vars to use\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + "# _ssmtt = data['sspar'][0]/MSOL\n", + "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "# ssmtt.append(_ssmtt)\n", + "\n", + "# _snssi = dsdat['snr_ss']\n", + "# snssi.append(_snssi)\n", + "# # get histogram\n", + "# _hist, mte, sne = np.histogram2d(\n", + "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# hist.append(_hist)\n", + "\n", + "# _text = '%.2f' % (params[TARGET])\n", + "# text.append(_text)\n", + "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + "# mt_edges=mt_edges, sn_edges=sn_edges,\n", + "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "# else:\n", + "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + "# mt_edges = file['mt_edges']\n", + "# sn_edges = file['sn_edges']\n", + "# ssmtt = file['ssmtt']\n", + "# snssi = file['snssi']\n", + "# hist = file['hist']\n", + "# text = file['text']\n", + "# file.close()\n", " " ] }, @@ -1132,50 +1181,71 @@ "TARGET = 'gsmf_phi0'\n", "NSKIES = 100\n", "NVARS = 21\n", + "# CALC=True\n", "\n", - "if CALC:\n", - " # get edges\n", - " NBINS = 40\n", - " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[20:-10]/MSOL\n", - " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - " # get histograms\n", - " ssmtt = []\n", - " snssi = []\n", - " hist = []\n", - " text = []\n", - " for ii in [0,5,10,15,20]: # vars to use\n", - " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - " _ssmtt = data['sspar'][0]/MSOL\n", - " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " ssmtt.append(_ssmtt)\n", - "\n", - " _snssi = dsdat['snr_ss']\n", - " snssi.append(_snssi)\n", - " # get histogram\n", - " _hist, mte, sne = np.histogram2d(\n", - " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - " hist.append(_hist)\n", - "\n", - " _text = '%.2f' % (params[TARGET])\n", - " text.append(_text)\n", - " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - " mt_edges=mt_edges, sn_edges=sn_edges,\n", - " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "if CALC: \n", + " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", "else:\n", - " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", " mt_edges = file['mt_edges']\n", " sn_edges = file['sn_edges']\n", - " ssmtt = file['ssmtt']\n", - " snssi = file['snssi']\n", - " hist = file['hist']\n", + " dc_edges = file['dc_edges']\n", + " # ssmtt = file['ssmtt']\n", + " # ssdcm = file['ssdcm']\n", + " # snssi = file['snssi']\n", + " hist_mt = file['hist_mt']\n", + " hist_dc = file['hist_dc']\n", + " hist_ff = file['hist_ff']\n", " text = file['text']\n", - " file.close()" + " bghist_mt = file['bghist_mt']\n", + " bghist_dc = file['bghist_dc']\n", + " bghist_ff = file['bghist_ff']\n", + " file.close()\n", + " \n", + "# if CALC:\n", + "# # get edges\n", + "# NBINS = 40\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[20:-10]/MSOL\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# # get histograms\n", + "# ssmtt = []\n", + "# snssi = []\n", + "# hist = []\n", + "# text = []\n", + "# for ii in [0,5,10,15,20]: # vars to use\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + "# _ssmtt = data['sspar'][0]/MSOL\n", + "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "# ssmtt.append(_ssmtt)\n", + "\n", + "# _snssi = dsdat['snr_ss']\n", + "# snssi.append(_snssi)\n", + "# # get histogram\n", + "# _hist, mte, sne = np.histogram2d(\n", + "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# hist.append(_hist)\n", + "\n", + "# _text = '%.2f' % (params[TARGET])\n", + "# text.append(_text)\n", + "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + "# mt_edges=mt_edges, sn_edges=sn_edges,\n", + "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "# else:\n", + "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + "# mt_edges = file['mt_edges']\n", + "# sn_edges = file['sn_edges']\n", + "# ssmtt = file['ssmtt']\n", + "# snssi = file['snssi']\n", + "# hist = file['hist']\n", + "# text = file['text']\n", + "# file.close()" ] }, { @@ -1235,49 +1305,72 @@ "NSKIES = 100\n", "NVARS = 21\n", "\n", - "if CALC:\n", - " # get edges\n", - " NBINS = 40\n", - " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[20:-6]/MSOL\n", - " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - " # get histograms\n", - " ssmtt = []\n", - " snssi = []\n", - " hist = []\n", - " text = []\n", - " for ii in [0,5,10,15,20]: # vars to use\n", - " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - " _ssmtt = data['sspar'][0]/MSOL\n", - " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " ssmtt.append(_ssmtt)\n", "\n", - " _snssi = dsdat['snr_ss']\n", - " snssi.append(_snssi)\n", - " # get histogram\n", - " _hist, mte, sne = np.histogram2d(\n", - " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - " hist.append(_hist)\n", + "# CALC=True\n", "\n", - " _text = '%.2f' % (params[TARGET])\n", - " text.append(_text)\n", - " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - " mt_edges=mt_edges, sn_edges=sn_edges,\n", - " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "if CALC: \n", + " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", "else:\n", - " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", " mt_edges = file['mt_edges']\n", " sn_edges = file['sn_edges']\n", - " ssmtt = file['ssmtt']\n", - " snssi = file['snssi']\n", - " hist = file['hist']\n", + " dc_edges = file['dc_edges']\n", + " # ssmtt = file['ssmtt']\n", + " # ssdcm = file['ssdcm']\n", + " # snssi = file['snssi']\n", + " hist_mt = file['hist_mt']\n", + " hist_dc = file['hist_dc']\n", + " hist_ff = file['hist_ff']\n", " text = file['text']\n", - " file.close()" + " bghist_mt = file['bghist_mt']\n", + " bghist_dc = file['bghist_dc']\n", + " bghist_ff = file['bghist_ff']\n", + " file.close()\n", + " \n", + "# if CALC:\n", + "# # get edges\n", + "# NBINS = 40\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[20:-6]/MSOL\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# # get histograms\n", + "# ssmtt = []\n", + "# snssi = []\n", + "# hist = []\n", + "# text = []\n", + "# for ii in [0,5,10,15,20]: # vars to use\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + "# _ssmtt = data['sspar'][0]/MSOL\n", + "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "# ssmtt.append(_ssmtt)\n", + "\n", + "# _snssi = dsdat['snr_ss']\n", + "# snssi.append(_snssi)\n", + "# # get histogram\n", + "# _hist, mte, sne = np.histogram2d(\n", + "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# hist.append(_hist)\n", + "\n", + "# _text = '%.2f' % (params[TARGET])\n", + "# text.append(_text)\n", + "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + "# mt_edges=mt_edges, sn_edges=sn_edges,\n", + "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "# else:\n", + "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + "# mt_edges = file['mt_edges']\n", + "# sn_edges = file['sn_edges']\n", + "# ssmtt = file['ssmtt']\n", + "# snssi = file['snssi']\n", + "# hist = file['hist']\n", + "# text = file['text']\n", + "# file.close()" ] }, { @@ -1337,49 +1430,72 @@ "NSKIES = 100\n", "NVARS = 21\n", "\n", - "if CALC:\n", - " # get edges\n", - " NBINS = 40\n", - " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[20:-8]/MSOL\n", - " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", "\n", - " # get histograms\n", - " ssmtt = []\n", - " snssi = []\n", - " hist = []\n", - " text = []\n", - " for ii in [0,5,10,15,20]: # vars to use\n", - " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - " _ssmtt = data['sspar'][0]/MSOL\n", - " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " ssmtt.append(_ssmtt)\n", + "# CALC=True\n", "\n", - " _snssi = dsdat['snr_ss']\n", - " snssi.append(_snssi)\n", - " # get histogram\n", - " _hist, mte, sne = np.histogram2d(\n", - " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - " hist.append(_hist)\n", - "\n", - " _text = '%.2f' % (params[TARGET])\n", - " text.append(_text)\n", - " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - " mt_edges=mt_edges, sn_edges=sn_edges,\n", - " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "if CALC: \n", + " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", "else:\n", - " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", " mt_edges = file['mt_edges']\n", " sn_edges = file['sn_edges']\n", - " ssmtt = file['ssmtt']\n", - " snssi = file['snssi']\n", - " hist = file['hist']\n", + " dc_edges = file['dc_edges']\n", + " # ssmtt = file['ssmtt']\n", + " # ssdcm = file['ssdcm']\n", + " # snssi = file['snssi']\n", + " hist_mt = file['hist_mt']\n", + " hist_dc = file['hist_dc']\n", + " hist_ff = file['hist_ff']\n", " text = file['text']\n", - " file.close()" + " bghist_mt = file['bghist_mt']\n", + " bghist_dc = file['bghist_dc']\n", + " bghist_ff = file['bghist_ff']\n", + " file.close()\n", + " \n", + "# if CALC:\n", + "# # get edges\n", + "# NBINS = 40\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[20:-8]/MSOL\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# # get histograms\n", + "# ssmtt = []\n", + "# snssi = []\n", + "# hist = []\n", + "# text = []\n", + "# for ii in [0,5,10,15,20]: # vars to use\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + "# _ssmtt = data['sspar'][0]/MSOL\n", + "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "# ssmtt.append(_ssmtt)\n", + "\n", + "# _snssi = dsdat['snr_ss']\n", + "# snssi.append(_snssi)\n", + "# # get histogram\n", + "# _hist, mte, sne = np.histogram2d(\n", + "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# hist.append(_hist)\n", + "\n", + "# _text = '%.2f' % (params[TARGET])\n", + "# text.append(_text)\n", + "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + "# mt_edges=mt_edges, sn_edges=sn_edges,\n", + "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "# else:\n", + "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + "# mt_edges = file['mt_edges']\n", + "# sn_edges = file['sn_edges']\n", + "# ssmtt = file['ssmtt']\n", + "# snssi = file['snssi']\n", + "# hist = file['hist']\n", + "# text = file['text']\n", + "# file.close()" ] }, { @@ -1439,50 +1555,73 @@ "NSKIES = 100\n", "NVARS = 21\n", "\n", - "if CALC:\n", - " # get edges\n", - " NBINS = 40\n", - " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[20:-8]/MSOL\n", - " sn_edges = np.geomspace(2.e-6,515, NBINS)\n", "\n", - " # get histograms\n", - " ssmtt = []\n", - " snssi = []\n", - " hist = []\n", - " text = []\n", - " for ii in [0,5,10,15,20]: # vars to use\n", - " data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - " _ssmtt = data['sspar'][0]/MSOL\n", - " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - " ssmtt.append(_ssmtt)\n", - "\n", - " _snssi = dsdat['snr_ss']\n", - " snssi.append(_snssi)\n", - " # get histogram\n", - " _hist, mte, sne = np.histogram2d(\n", - " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - " hist.append(_hist)\n", + "# CALC=True\n", "\n", - " _text = '%.2f' % (params[TARGET])\n", - " text.append(_text)\n", - " \n", - " np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - " mt_edges=mt_edges, sn_edges=sn_edges,\n", - " ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "if CALC: \n", + " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", "else:\n", - " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - " +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + " file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " +f'/snr_hist_{TARGET}_v{NVARS}_5axs.npz')\n", " mt_edges = file['mt_edges']\n", " sn_edges = file['sn_edges']\n", - " ssmtt = file['ssmtt']\n", - " snssi = file['snssi']\n", - " hist = file['hist']\n", + " dc_edges = file['dc_edges']\n", + " # ssmtt = file['ssmtt']\n", + " # ssdcm = file['ssdcm']\n", + " # snssi = file['snssi']\n", + " hist_mt = file['hist_mt']\n", + " hist_dc = file['hist_dc']\n", + " hist_ff = file['hist_ff']\n", " text = file['text']\n", - " file.close()" + " bghist_mt = file['bghist_mt']\n", + " bghist_dc = file['bghist_dc']\n", + " bghist_ff = file['bghist_ff']\n", + " file.close()\n", + "\n", + "# if CALC:\n", + "# # get edges\n", + "# NBINS = 40\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[20:-8]/MSOL\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# # get histograms\n", + "# ssmtt = []\n", + "# snssi = []\n", + "# hist = []\n", + "# text = []\n", + "# for ii in [0,5,10,15,20]: # vars to use\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", + "# _ssmtt = data['sspar'][0]/MSOL\n", + "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "# ssmtt.append(_ssmtt)\n", + "\n", + "# _snssi = dsdat['snr_ss']\n", + "# snssi.append(_snssi)\n", + "# # get histogram\n", + "# _hist, mte, sne = np.histogram2d(\n", + "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# hist.append(_hist)\n", + "\n", + "# _text = '%.2f' % (params[TARGET])\n", + "# text.append(_text)\n", + " \n", + "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", + "# mt_edges=mt_edges, sn_edges=sn_edges,\n", + "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", + "# else:\n", + "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", + "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", + "# mt_edges = file['mt_edges']\n", + "# sn_edges = file['sn_edges']\n", + "# ssmtt = file['ssmtt']\n", + "# snssi = file['snssi']\n", + "# hist = file['hist']\n", + "# text = file['text']\n", + "# file.close()" ] }, { From 5e6626a60931f7d90fcc7b134be33400ba31bce1 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 4 Jul 2023 10:50:45 -0700 Subject: [PATCH 236/291] Update to use corrected redz. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 25 +- .../paper_plots/snr_vs_mass_hist.ipynb | 474 ++++++------------ 2 files changed, 165 insertions(+), 334 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 02f3cd67..b463a42e 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -47,7 +47,7 @@ "NLOUDEST = 10\n", "\n", "BUILD_ARRAYS = False\n", - "SAVEFIG = False\n", + "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", "\n", @@ -93,13 +93,18 @@ "source": [ "def get_data(\n", " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", - "\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", - " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_redz':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", + " else:\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", " if red_gamma is not None and red2white is not None:\n", " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", " load_dets_from_file = load_dets_from_file+'.npz'\n", "\n", " if os.path.exists(load_data_from_file) is False:\n", @@ -121,7 +126,7 @@ "\n", "def get_ratio_arrays(\n", " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " ):\n", " filename = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ratio_arrays.npz'\n", " file = np.load(filename)\n", @@ -142,7 +147,7 @@ " targets = [\n", " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " for target in targets:\n", " print(target)\n", "\n", @@ -275,10 +280,9 @@ "\n", "# fig.tight_layout()\n", "\n", - "SAVEFIG=False\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50_redzfixed.png'\n", " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] @@ -334,11 +338,10 @@ "plt.subplots_adjust(wspace=0)\n", "# fig.tight_layout()\n", "\n", - "SAVEFIG=False\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095_redzfixed.png'\n", " fig.savefig(savename, dpi=100)" ] }, diff --git a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb index af08db67..db6eccf3 100644 --- a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb +++ b/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb @@ -38,7 +38,7 @@ "metadata": {}, "outputs": [], "source": [ - "CALC = True" + "CALC = False" ] }, { @@ -478,7 +478,6 @@ "TARGET = 'hard_time'\n", "NSKIES = 100\n", "NVARS = 21\n", - "CALC=False\n", "\n", "def calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES):\n", " # get edges\n", @@ -627,7 +626,7 @@ " orientation='vertical', pad=0.01, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -668,7 +667,7 @@ " orientation='vertical', pad=0.01, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_dcom_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -709,7 +708,7 @@ " orientation='vertical', pad=0.01, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_dcom_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -779,7 +778,7 @@ " plt.colorbar(im, ax=axs[ii,:].ravel().tolist(), shrink=0.7, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_props_hist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -841,7 +840,7 @@ "plt.colorbar(im2, ax=axs.ravel().tolist(), shrink=0.5, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_props_bluehist_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -917,6 +916,83 @@ "### Add background" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_hists_3ax_with_bg(TARGET, NVARS, mt_edges, dc_edges, ff_edges,\n", + " sn_edges, hist_mt, hist_dc, hist_ff, \n", + " bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap, label,\n", + "):\n", + " # PLOT\n", + " xlabel1='Mass [M$_\\odot$]'\n", + " xlabel2='Distance [Mpc]'\n", + " xlabel3='Frequency [yr$^{-1}$]'\n", + " ylabel='SNR'\n", + "\n", + " # build grid from edges\n", + " mtgrid, sngrid1, = np.meshgrid(mt_edges, sn_edges)\n", + " dcgrid, sngrid2, = np.meshgrid(dc_edges, sn_edges)\n", + " ffgrid, sngrid3 = np.meshgrid(ff_edges, sn_edges)\n", + "\n", + " # make figure\n", + " fig, axs = plot.figax_single(\n", + " ncols=3, nrows=3, sharex=False, sharey=True, height=8)\n", + "\n", + " cols = [0,2,4]\n", + "\n", + " # plot histograms\n", + " for aa, ax in enumerate(axs[0,:]):\n", + " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[cols[aa]]), cmap=ss_cmap, vmin=0, vmax=5)\n", + " im0 = ax.pcolormesh(mtgrid, sngrid1, np.log10(bghist_mt[cols[aa]]), cmap=blacks, alpha=0.75)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.99, f\"{label}={text[cols[aa]]}\", horizontalalignment='left', verticalalignment='top', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + " # # axs[ii].set_facecolor('k')\n", + "\n", + " # plot dcom histograms\n", + " for aa, ax in enumerate(axs[1,:]):\n", + " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[cols[aa]]), cmap=ss_cmap, vmin=0, vmax=5)\n", + " im0 = ax.pcolormesh(dcgrid, sngrid2, np.log10(bghist_dc[cols[aa]]), cmap=blacks, alpha=0.75)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", + " # transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + " # plot freq histograms\n", + " for aa, ax in enumerate(axs[2,:]):\n", + " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[cols[aa]]), cmap=ss_cmap, vmin=0, vmax=5)\n", + " im0 = ax.pcolormesh(ffgrid, sngrid3, np.log10(bghist_ff[cols[aa]]), cmap=blacks, alpha=0.75)\n", + " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", + " ax.text(0.01, 0.01, f\"{label}={text[cols[aa]]}\", horizontalalignment='left', verticalalignment='bottom', \n", + " transform=ax.transAxes, color='k', fontsize=12)\n", + "\n", + "\n", + "\n", + " # set labels\n", + " axs[1,0].set_ylabel(ylabel)\n", + " axs[0,1].set_xlabel(xlabel1)\n", + " axs[1,1].set_xlabel(xlabel2)\n", + " axs[2,1].set_xlabel(xlabel3)\n", + " fig.tight_layout()\n", + "\n", + " plt.subplots_adjust(wspace=0)\n", + " # add colorbar\n", + " # for ii, im in enumerate([im1, im2, im3]):\n", + " plt.colorbar(im2, ax=axs.ravel().tolist(), shrink=0.5, \n", + " orientation='vertical', pad=0.03, label='$\\log N$', )\n", + " # save\n", + " fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", + " + f'/snr_vs_props_hist_3axs_bg_{TARGET}_v{NVARS}.png', dpi=100)\n", + "\n", + "fig = plot_hists_3ax_with_bg(\n", + " TARGET, NVARS, mt_edges, dc_edges, ff_edges, sn_edges,\n", + " hist_mt, hist_dc, hist_ff, bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap=cm.Blues, label = \"$\\\\tau_\\mathrm{hard}$\")" + ] + }, { "cell_type": "code", "execution_count": null, @@ -924,105 +1000,39 @@ "outputs": [], "source": [ "# PLOT\n", - "xlabel1='Mass [M$_\\odot$]'\n", - "xlabel2='Distance [Mpc]'\n", - "xlabel3='Frequency [yr$^{-1}$]'\n", + "xlabel='Mass [M$_\\odot$]'\n", "ylabel='SNR'\n", "\n", "# build grid from edges\n", - "mtgrid, sngrid1, = np.meshgrid(mt_edges, sn_edges)\n", - "dcgrid, sngrid2, = np.meshgrid(dc_edges, sn_edges)\n", - "ffgrid, sngrid3 = np.meshgrid(ff_edges, sn_edges)\n", + "mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", "\n", "# make figure\n", "fig, axs = plot.figax_single(\n", - " ncols=3, nrows=3, sharex=False, sharey=True, height=8)\n", - "\n", - "cols = [0,2,4]\n", + " nrows=5, sharex=True, sharey=True, height=16)\n", "\n", "# plot histograms\n", - "for aa, ax in enumerate(axs[0,:]):\n", - " im1 = ax.pcolormesh(mtgrid, sngrid1, np.log10(hist_mt[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", - " im0 = ax.pcolormesh(mtgrid, sngrid1, np.log10(bghist_mt[cols[aa]]), cmap=blacks, alpha=0.75)\n", - " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", - " ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", - " transform=ax.transAxes, color='k', fontsize=12)\n", - "# # axs[ii].set_facecolor('k')\n", - "\n", - "# plot dcom histograms\n", - "for aa, ax in enumerate(axs[1,:]):\n", - " im2 = ax.pcolormesh(dcgrid, sngrid2, np.log10(hist_dc[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", - " im0 = ax.pcolormesh(dcgrid, sngrid2, np.log10(bghist_dc[cols[aa]]), cmap=blacks, alpha=0.75)\n", - " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", - " # ax.text(0.01, 0.99, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='top', \n", - " # transform=ax.transAxes, color='k', fontsize=12)\n", - "\n", - "# plot freq histograms\n", - "for aa, ax in enumerate(axs[2,:]):\n", - " im3 = ax.pcolormesh(ffgrid, sngrid3, np.log10(hist_ff[cols[aa]]), cmap=cm.Blues, vmin=0, vmax=5)\n", - " im0 = ax.pcolormesh(ffgrid, sngrid3, np.log10(bghist_ff[cols[aa]]), cmap=blacks, alpha=0.75)\n", + "for aa, ax in enumerate(axs):\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=cm.magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", - " ax.text(0.01, 0.01, '$\\\\tau_\\mathrm{hard}$=%s' % text[cols[aa]], horizontalalignment='left', verticalalignment='bottom', \n", - " transform=ax.transAxes, color='k', fontsize=12)\n", - "\n", - "\n", + " axs[aa].text(0, 1, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], \n", + " horizontalalignment='left', verticalalignment='top', \n", + " transform=axs[aa].transAxes, color='k', fontsize=18)\n", + " # axs[ii].set_facecolor('k')\n", "\n", "# set labels\n", - "axs[1,0].set_ylabel(ylabel)\n", - "axs[0,1].set_xlabel(xlabel1)\n", - "axs[1,1].set_xlabel(xlabel2)\n", - "axs[2,1].set_xlabel(xlabel3)\n", + "axs[2].set_ylabel(ylabel)\n", + "axs[-1].set_xlabel(xlabel)\n", "fig.tight_layout()\n", + "plt.subplots_adjust(hspace=0)\n", "\n", - "plt.subplots_adjust(wspace=0)\n", "# add colorbar\n", - "# for ii, im in enumerate([im1, im2, im3]):\n", - "plt.colorbar(im2, ax=axs.ravel().tolist(), shrink=0.5, \n", - " orientation='vertical', pad=0.03, label='$\\log N$', )\n", - "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " + f'/snr_vs_props_bluehist_{TARGET}_v{NVARS}_3axs.png', dpi=100)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# # PLOT\n", - "# xlabel='Mass [M$_\\odot$]'\n", - "# ylabel='SNR'\n", - "\n", - "# # build grid from edges\n", - "# mtgrid, sngrid, = np.meshgrid(mt_edges, sn_edges)\n", - "\n", - "# # make figure\n", - "# fig, axs = plot.figax_single(\n", - "# nrows=5, sharex=True, sharey=True, height=16)\n", - "\n", - "# # plot histograms\n", - "# for aa, ax in enumerate(axs):\n", - "# im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=cm.magma_r)\n", - "# # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", - "# axs[aa].text(0, 1, '$\\\\tau_\\mathrm{hard}$=%s' % text[aa], \n", - "# horizontalalignment='left', verticalalignment='top', \n", - "# transform=axs[aa].transAxes, color='k', fontsize=18)\n", - "# # axs[ii].set_facecolor('k')\n", - "\n", - "# # set labels\n", - "# axs[2].set_ylabel(ylabel)\n", - "# axs[-1].set_xlabel(xlabel)\n", - "# fig.tight_layout()\n", - "\n", - "# # add colorbar\n", - "# plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", - "# orientation='horizontal', pad=0.08, label='$\\log N$', )\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='horizontal', pad=0.08, label='$\\log N$', )\n", "\n", "\n", - "# # save\n", - "# fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - "# + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" + "# save\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", + " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, { @@ -1042,7 +1052,7 @@ "TARGET = 'hard_gamma_inner'\n", "NSKIES = 100\n", "NVARS = 21\n", - "CALC=True\n", + "# CALC=False\n", "\n", "if CALC: \n", " calculate_histograms(TARGET, NFREQS, NREALS, NLOUDEST, NSKIES)\n", @@ -1064,50 +1074,10 @@ " bghist_ff = file['bghist_ff']\n", " file.close()\n", "\n", - "# if CALC:\n", - "# # get edges\n", - "# NBINS = 40\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[20:-12]/MSOL\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - "# # get histograms\n", - "# ssmtt = []\n", - "# snssi = []\n", - "# hist = []\n", - "# text = []\n", - "# for ii in [0,5,10,15,20]: # vars to use\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - "# _ssmtt = data['sspar'][0]/MSOL\n", - "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - "# ssmtt.append(_ssmtt)\n", - "\n", - "# _snssi = dsdat['snr_ss']\n", - "# snssi.append(_snssi)\n", - "# # get histogram\n", - "# _hist, mte, sne = np.histogram2d(\n", - "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# hist.append(_hist)\n", - "\n", - "# _text = '%.2f' % (params[TARGET])\n", - "# text.append(_text)\n", - "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - "# mt_edges=mt_edges, sn_edges=sn_edges,\n", - "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", - "# else:\n", - "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", - "# mt_edges = file['mt_edges']\n", - "# sn_edges = file['sn_edges']\n", - "# ssmtt = file['ssmtt']\n", - "# snssi = file['snssi']\n", - "# hist = file['hist']\n", - "# text = file['text']\n", - "# file.close()\n", - " " + "fig = plot_hists_3ax_with_bg(\n", + " TARGET, NVARS, mt_edges, dc_edges, ff_edges, sn_edges,\n", + " hist_mt, hist_dc, hist_ff, bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap=cm.Blues, label = \"$\\\\nu_\\mathrm{inner}$\")" ] }, { @@ -1129,7 +1099,7 @@ "\n", "# plot histograms\n", "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " axs[aa].text(0.01, 0.99, '$\\\\nu_\\mathrm{inner}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", " transform=axs[aa].transAxes, color='k', fontsize=12)\n", @@ -1138,14 +1108,15 @@ "# set labels\n", "axs[0].set_ylabel(ylabel)\n", "axs[2].set_xlabel(xlabel)\n", - "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", + "# fig.tight_layout()\n", "\n", "# add colorbar\n", "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -1202,50 +1173,11 @@ " bghist_dc = file['bghist_dc']\n", " bghist_ff = file['bghist_ff']\n", " file.close()\n", - " \n", - "# if CALC:\n", - "# # get edges\n", - "# NBINS = 40\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[20:-10]/MSOL\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - "# # get histograms\n", - "# ssmtt = []\n", - "# snssi = []\n", - "# hist = []\n", - "# text = []\n", - "# for ii in [0,5,10,15,20]: # vars to use\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - "# _ssmtt = data['sspar'][0]/MSOL\n", - "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - "# ssmtt.append(_ssmtt)\n", - "\n", - "# _snssi = dsdat['snr_ss']\n", - "# snssi.append(_snssi)\n", - "# # get histogram\n", - "# _hist, mte, sne = np.histogram2d(\n", - "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# hist.append(_hist)\n", - "\n", - "# _text = '%.2f' % (params[TARGET])\n", - "# text.append(_text)\n", - "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - "# mt_edges=mt_edges, sn_edges=sn_edges,\n", - "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", - "# else:\n", - "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", - "# mt_edges = file['mt_edges']\n", - "# sn_edges = file['sn_edges']\n", - "# ssmtt = file['ssmtt']\n", - "# snssi = file['snssi']\n", - "# hist = file['hist']\n", - "# text = file['text']\n", - "# file.close()" + "\n", + "fig = plot_hists_3ax_with_bg(\n", + " TARGET, NVARS, mt_edges, dc_edges, ff_edges, sn_edges,\n", + " hist_mt, hist_dc, hist_ff, bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap=cm.Greens, label = \"$\\psi_0$\")" ] }, { @@ -1267,7 +1199,7 @@ "\n", "# plot histograms\n", "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " axs[aa].text(0.01, 0.99, '$\\psi_0$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", " transform=axs[aa].transAxes, color='k', fontsize=12)\n", @@ -1277,13 +1209,14 @@ "axs[0].set_ylabel(ylabel)\n", "axs[2].set_xlabel(xlabel)\n", "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", "\n", "# add colorbar\n", "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -1327,50 +1260,12 @@ " bghist_dc = file['bghist_dc']\n", " bghist_ff = file['bghist_ff']\n", " file.close()\n", - " \n", - "# if CALC:\n", - "# # get edges\n", - "# NBINS = 40\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[20:-6]/MSOL\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - "# # get histograms\n", - "# ssmtt = []\n", - "# snssi = []\n", - "# hist = []\n", - "# text = []\n", - "# for ii in [0,5,10,15,20]: # vars to use\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - "# _ssmtt = data['sspar'][0]/MSOL\n", - "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - "# ssmtt.append(_ssmtt)\n", - "\n", - "# _snssi = dsdat['snr_ss']\n", - "# snssi.append(_snssi)\n", - "# # get histogram\n", - "# _hist, mte, sne = np.histogram2d(\n", - "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# hist.append(_hist)\n", - "\n", - "# _text = '%.2f' % (params[TARGET])\n", - "# text.append(_text)\n", - "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - "# mt_edges=mt_edges, sn_edges=sn_edges,\n", - "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", - "# else:\n", - "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", - "# mt_edges = file['mt_edges']\n", - "# sn_edges = file['sn_edges']\n", - "# ssmtt = file['ssmtt']\n", - "# snssi = file['snssi']\n", - "# hist = file['hist']\n", - "# text = file['text']\n", - "# file.close()" + "\n", + "\n", + "fig = plot_hists_3ax_with_bg(\n", + " TARGET, NVARS, mt_edges, dc_edges, ff_edges, sn_edges,\n", + " hist_mt, hist_dc, hist_ff, bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap=cm.Greens, label = \"$\\log M_{\\psi,0}$\")" ] }, { @@ -1392,7 +1287,7 @@ "\n", "# plot histograms\n", "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " axs[aa].text(0.01, 0.99, '$M_\\mathrm{char,0}$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", " transform=axs[aa].transAxes, color='k', fontsize=12)\n", @@ -1402,13 +1297,14 @@ "axs[0].set_ylabel(ylabel)\n", "axs[2].set_xlabel(xlabel)\n", "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", "\n", "# add colorbar\n", "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -1452,50 +1348,13 @@ " bghist_dc = file['bghist_dc']\n", " bghist_ff = file['bghist_ff']\n", " file.close()\n", - " \n", - "# if CALC:\n", - "# # get edges\n", - "# NBINS = 40\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[20:-8]/MSOL\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - "# # get histograms\n", - "# ssmtt = []\n", - "# snssi = []\n", - "# hist = []\n", - "# text = []\n", - "# for ii in [0,5,10,15,20]: # vars to use\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - "# _ssmtt = data['sspar'][0]/MSOL\n", - "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - "# ssmtt.append(_ssmtt)\n", - "\n", - "# _snssi = dsdat['snr_ss']\n", - "# snssi.append(_snssi)\n", - "# # get histogram\n", - "# _hist, mte, sne = np.histogram2d(\n", - "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# hist.append(_hist)\n", - "\n", - "# _text = '%.2f' % (params[TARGET])\n", - "# text.append(_text)\n", - "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - "# mt_edges=mt_edges, sn_edges=sn_edges,\n", - "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", - "# else:\n", - "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", - "# mt_edges = file['mt_edges']\n", - "# sn_edges = file['sn_edges']\n", - "# ssmtt = file['ssmtt']\n", - "# snssi = file['snssi']\n", - "# hist = file['hist']\n", - "# text = file['text']\n", - "# file.close()" + "\n", + "\n", + "\n", + "fig = plot_hists_3ax_with_bg(\n", + " TARGET, NVARS, mt_edges, dc_edges, ff_edges, sn_edges,\n", + " hist_mt, hist_dc, hist_ff, bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap=cm.Oranges, label = \"$\\log\\mu$\")\n" ] }, { @@ -1517,7 +1376,7 @@ "\n", "# plot histograms\n", "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " axs[aa].text(0.01, 0.99, '$\\mu$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", " transform=axs[aa].transAxes, color='k', fontsize=12)\n", @@ -1527,13 +1386,14 @@ "axs[0].set_ylabel(ylabel)\n", "axs[2].set_xlabel(xlabel)\n", "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", "\n", "# add colorbar\n", "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, @@ -1578,50 +1438,11 @@ " bghist_ff = file['bghist_ff']\n", " file.close()\n", "\n", - "# if CALC:\n", - "# # get edges\n", - "# NBINS = 40\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[20:-8]/MSOL\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - "# # get histograms\n", - "# ssmtt = []\n", - "# snssi = []\n", - "# hist = []\n", - "# text = []\n", - "# for ii in [0,5,10,15,20]: # vars to use\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=ii, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' )\n", - "# _ssmtt = data['sspar'][0]/MSOL\n", - "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - "# ssmtt.append(_ssmtt)\n", - "\n", - "# _snssi = dsdat['snr_ss']\n", - "# snssi.append(_snssi)\n", - "# # get histogram\n", - "# _hist, mte, sne = np.histogram2d(\n", - "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# hist.append(_hist)\n", - "\n", - "# _text = '%.2f' % (params[TARGET])\n", - "# text.append(_text)\n", - " \n", - "# np.savez('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz',\n", - "# mt_edges=mt_edges, sn_edges=sn_edges,\n", - "# ssmtt = ssmtt, snssi=snssi, hist=hist, text=text)\n", - "# else:\n", - "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_09B/figdata'\n", - "# +f'/snr_vs_mass_hist_{TARGET}_v{NVARS}_5axs.npz')\n", - "# mt_edges = file['mt_edges']\n", - "# sn_edges = file['sn_edges']\n", - "# ssmtt = file['ssmtt']\n", - "# snssi = file['snssi']\n", - "# hist = file['hist']\n", - "# text = file['text']\n", - "# file.close()" + "\n", + "fig = plot_hists_3ax_with_bg(\n", + " TARGET, NVARS, mt_edges, dc_edges, ff_edges, sn_edges,\n", + " hist_mt, hist_dc, hist_ff, bghist_mt, bghist_dc, bghist_ff,\n", + " ss_cmap=cm.Oranges, label = \"$\\epsilon_\\mu$\")" ] }, { @@ -1643,7 +1464,7 @@ "\n", "# plot histograms\n", "for aa, ax in enumerate(axs):\n", - " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist[aa]), cmap=magma_r)\n", + " im = axs[aa].pcolormesh(mtgrid, sngrid, np.log10(hist_mt[aa]), cmap=magma_r)\n", " # title = '%s = %.2f' % ('$\\psi_0$', params[TARGET])\n", " axs[aa].text(0.01, 0.99, '$\\epsilon_\\mu$=%s' % text[aa], horizontalalignment='left', verticalalignment='top', \n", " transform=axs[aa].transAxes, color='k', fontsize=12)\n", @@ -1653,16 +1474,23 @@ "axs[0].set_ylabel(ylabel)\n", "axs[2].set_xlabel(xlabel)\n", "fig.tight_layout()\n", + "plt.subplots_adjust(wspace=0)\n", "\n", "# add colorbar\n", "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", " orientation='vertical', pad=0.03, label='$\\log N$', )\n", - "\n", "# save\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_hist'\n", " + f'/snr_vs_mass_numden_{TARGET}_v{NVARS}_5axs.png', dpi=100)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, From 8674a2d49271151fc15a229a5958b22f9b2843ac Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 5 Jul 2023 22:14:50 -0700 Subject: [PATCH 237/291] Plot number density of EV_ss/DP_bg vs parameter for entire library. --- .../library_ratio_hist.ipynb | 292 ++++++++++++++++++ .../tk13_clbrted_lib.ipynb | 21 +- 2 files changed, 307 insertions(+), 6 deletions(-) create mode 100644 ecg-notebooks/parameter_investigation/library_ratio_hist.ipynb diff --git a/ecg-notebooks/parameter_investigation/library_ratio_hist.ipynb b/ecg-notebooks/parameter_investigation/library_ratio_hist.ipynb new file mode 100644 index 00000000..82fe3f21 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/library_ratio_hist.ipynb @@ -0,0 +1,292 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file_path = '/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10'\n", + "hdf = h5py.File(file_path+'/sam_lib.hdf5', 'r')\n", + "\n", + "print(hdf.keys())\n", + "sample_params = hdf['sample_params'][...]\n", + "hc_ss = hdf['hc_ss'][...]\n", + "hc_bg = hdf['hc_bg'][...]\n", + "sspar = hdf['sspar'][...]\n", + "bgpar = hdf['bgpar'][...]\n", + "fobs_gw_cents = hdf['fobs'][:]\n", + "hdf.close()\n", + "\n", + "dur = 1/fobs_gw_cents[0]\n", + "fobs_gw_cents, fobs_gw_edges = holo.utils.pta_freqs(dur, num=len(fobs_gw_cents))\n", + "nsamps, nfreqs, nreals, nloudest = [*hc_ss.shape]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "npz = np.load(file_path+'/PS_Uniform_09B.pspace.npz', allow_pickle=True)\n", + "print(npz.files)\n", + "param_names = npz['param_names']\n", + "print(param_names)\n", + "print(npz['class_name'])\n", + "lib_name = '%s v%s, %d samples' % (npz['class_name'], npz['librarian_version'], nsamps)\n", + "print(lib_name)\n", + "# print(npz['sam_shape'])\n", + "npz.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Load detstats\n", + "npz = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss63_09Bparams_2023-06-22_uniform-09b_n500_r100_f40_l10/detstats/clbrt_psrs40/detstats_lib.npz')\n", + "print(npz.files)\n", + "# print(npz['snr_ss'].shape)\n", + "dp_ss = npz['dp_ss']\n", + "dp_bg = npz['dp_bg']\n", + "df_ss = npz['df_ss']\n", + "df_bg = npz['df_bg']\n", + "ev_ss = npz['ev_ss']\n", + "nskies = dp_ss.shape[-1]\n", + "print(f\"{ev_ss.shape=}, {dp_ss.shape=}\")\n", + "npz.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(sample_params.shape\n", + " )" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Edges" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NBINS = 40\n", + "ht_min = np.min(sample_params[:,0])\n", + "ht_max = np.max(sample_params[:,0])\n", + "print(f\"{ht_min=}, {ht_max=}\")\n", + "ht_edges = np.linspace(ht_min, ht_max, NBINS)\n", + "ev_edges = np.geomspace(2.5e-3, 10.0, NBINS)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "ev2dp = ev_ss/dp_bg[...,np.newaxis]\n", + "thard = sample_params[:,0]\n", + "print(f\"{ev2dp.shape=}, {thard.shape=}\")\n", + "thard = np.repeat(thard, nreals*nskies).reshape(nsamps, nreals, nskies)\n", + "print(f\"{ev2dp.shape=}, {thard.shape=}\")\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Make Histogram" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hist, eve, hte = np.histogram2d(ev2dp.flatten(), thard.flatten(), \n", + " bins=(ev_edges, ht_edges))\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "xlabel = plot.PARAM_KEYS['hard_time']\n", + "ylabel = '$EV_\\mathrm{SS}/DP_\\mathrm{BG}$'\n", + "xscale = 'linear'\n", + "yscale = 'log'\n", + "\n", + "\n", + "htgrid, evgrid = np.meshgrid(ht_edges, ev_edges)\n", + "fig, ax = plot.figax_single(xscale=xscale, yscale=yscale, xlabel=xlabel, ylabel=ylabel)\n", + "im = ax.pcolormesh(htgrid, evgrid, np.log10(hist))\n", + "plt.colorbar(im, ax=ax, label='$\\log N$')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# For Every Parameter" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NBINS = 40\n", + "\n", + "yy = ev_ss/dp_bg[...,np.newaxis]\n", + "yy_edges = np.geomspace(2.5e-4, 15.0, NBINS)\n", + "\n", + "param_hists = []\n", + "param_edges = []\n", + "for ii, target in enumerate(param_names):\n", + " xx = sample_params[:,ii]\n", + " xx = np.repeat(xx, nreals*nskies)\n", + " xmin = np.min(xx)\n", + " xmax = np.max(xx)\n", + " xx_edges = np.linspace(xmin, xmax, NBINS)\n", + " print(f\"{target} {xmin=}, {xmax=}\")\n", + "\n", + " hist, yye, xxe = np.histogram2d(yy.flatten(), xx, bins=(yy_edges, xx_edges))\n", + " param_hists.append(hist)\n", + " param_edges.append(xx_edges)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[param_names[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " \n", + " xxgrid, yygrid = np.meshgrid(param_edges[ii], yy_edges)\n", + " im = ax.pcolormesh(xxgrid, yygrid, param_hists[ii])\n", + "\n", + "plt.subplots_adjust(wspace=0.03)\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.01, label='$N$', )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[param_names[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " \n", + " xxgrid, yygrid = np.meshgrid(param_edges[ii], yy_edges)\n", + " im = ax.pcolormesh(xxgrid, yygrid, np.log10(param_hists[ii]))\n", + "\n", + "plt.subplots_adjust(wspace=0.03)\n", + "\n", + "# add colorbar\n", + "plt.colorbar(im, ax=axs.ravel().tolist(), shrink=0.7, \n", + " orientation='vertical', pad=0.01, label='$\\log N$', )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb b/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb index 6fe6b2aa..bf2cab3b 100644 --- a/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb +++ b/ecg-notebooks/parameter_investigation/tk13_clbrted_lib.ipynb @@ -130,8 +130,17 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = plot.figax(xlabel='hard_time', ylabel='ev_ss/dp_bg')\n", - "ax.scatter(thard, ratio, s=1)" + "fig, ax = plot.figax(xlabel='hard_time', ylabel='ev_ss/dp_bg', xscale='linear')\n", + "ax.scatter(thard, ratio, s=0.5, alpha=0.1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ht_edges - " ] }, { @@ -182,9 +191,9 @@ "source": [ "cmap='PiYG'\n", "def scatter_with_color(xx, yy, cc, norm, xlabel=None, ylabel=None, clabel=None,\n", - " xscale='log', yscale='log', ccent=0, cmap='PiYG'):\n", + " xscale='log', yscale='log', ccent=0, cmap='PiYG', alpha=0.5):\n", " fig, ax = plot.figax(xlabel=xlabel, ylabel=ylabel, yscale=yscale, xscale=xscale)\n", - " sax = ax.scatter(xx.flatten(), yy.flatten(), c=cc.flatten(), cmap=cmap, norm=norm)\n", + " sax = ax.scatter(xx.flatten(), yy.flatten(), c=cc.flatten(), cmap=cmap, norm=norm, alpha=alpha)\n", " cbar = plt.colorbar(sax, ax=ax, label=clabel)\n", " return fig\n", "# create the colorbar\n", @@ -206,7 +215,7 @@ "ylabel = 'GSMF mchar0 log10'\n", "clabel = 'SS/BG Detprob'\n", "yscale='linear'\n", - "xscale='log'\n", + "xscale='linear'\n", "norm = normalize(cc, center=0)\n", "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", "\n", @@ -228,7 +237,7 @@ "ylabel = 'GSMF Phi0'\n", "clabel = 'SS/BG Detprob'\n", "yscale='linear'\n", - "xscale='log'\n", + "xscale='linear'\n", "norm = normalize(cc, center=0)\n", "print(f\"{xx.shape=}, {yy.shape=}, {cc.shape=}\")\n", "\n", From 147ad2e68df64d978ab3dd55dce59a92055737d3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 6 Jul 2023 13:03:05 -0700 Subject: [PATCH 238/291] Make mass vs distance contour plots. --- .../paper_plots/snr2_mass_vs_distance.ipynb | 1004 +++++++++++++++++ 1 file changed, 1004 insertions(+) create mode 100644 ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb new file mode 100644 index 00000000..cbe711e0 --- /dev/null +++ b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb @@ -0,0 +1,1004 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "from tqdm import tqdm\n", + "import os\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "cmap_base = 'magma_r'\n", + "magma_r = truncate_colormap(cmap_base, 0, 0.85)\n", + "blacks = truncate_colormap('binary', 0.4, 1.0)\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", + "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)\n", + "cmap_Purples = truncate_colormap('Purples', 0.4, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "RED_GAMMA = None\n", + "RED2WHITE = None\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_var_data( target, var=None, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + "\n", + " path = path + f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}' \n", + " load_data_from_file = path+f'/data_params.npz' \n", + " load_dets_from_file = path+f'/detstats_s{nskies}' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " if var is not None:\n", + " data = file['data'][var]\n", + " params = file['params'][var]\n", + " else:\n", + " data = file['data']\n", + " params = file['params']\n", + "\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " if var is not None:\n", + " dsdat = file['dsdat'][var]\n", + " else:\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Edges" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# get edges\n", + "NBINS = 40\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[25:-15]/MSOL\n", + "dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", + "sn_edges = np.geomspace(2.e-6,515, NBINS)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Hist Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TARGET = 'hard_time'\n", + "# var = None\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=0, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + "# print(params)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "hist_mt = []\n", + "hist_dc = []\n", + "bghist_mt = []\n", + "bghist_dc = []\n", + "\n", + "for var in [0,-1]:\n", + " data, params, dsdat = get_var_data(target=TARGET, var=var, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + "\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " bgpar = data['bgpar']\n", + "\n", + " # total mass\n", + " _ssmtt = sspar[0]/MSOL\n", + " _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "\n", + " _bgmtt = bgpar[0]/MSOL # F,R\n", + " print(f\"{_bgmtt.shape=}\")\n", + "\n", + " # comoving distance\n", + " _ssdcm = sspar[4]/MPC\n", + " _ssdcm = np.repeat(_ssdcm, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " _ssdcm = np.swapaxes(_ssdcm, -2, -1)\n", + "\n", + " _bgdcm = bgpar[4]/MPC\n", + "\n", + " # snr\n", + " _snssi = dsdat['snr_ss']\n", + " _snrbg = dsdat['snr_bg']\n", + " _snrbg = np.repeat(_snrbg, NFREQS).reshape(NREALS, NFREQS)\n", + " _snrbg = np.swapaxes(_snrbg, 0, 1)\n", + " \n", + "\n", + " # get total mass histograms\n", + " _hist_mt, sne, mte, = np.histogram2d(\n", + " _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " hist_mt.append(_hist_mt)\n", + "\n", + " _bghist_mt, sne, mte, = np.histogram2d(\n", + " _snrbg.flatten(), _bgmtt.flatten(), bins=(sn_edges, mt_edges))\n", + " bghist_mt.append(_bghist_mt)\n", + "\n", + " # get comoving distance histograms\n", + " _hist_dc, sne, dce, = np.histogram2d(\n", + " _snssi.flatten(), _ssdcm.flatten(), bins=(sn_edges, dc_edges))\n", + " hist_dc.append(_hist_dc)\n", + "\n", + " _bghist_dc, sne, dce = np.histogram2d(\n", + " _snrbg.flatten(), _bgdcm.flatten(), bins=(sn_edges, dc_edges))\n", + " bghist_dc.append(_bghist_dc)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Try AGAIN" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# get edges\n", + "NBINS = 20\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[25:-15]/MSOL\n", + "dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", + "sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "dcgrid, mtgrid, = np.meshgrid(dc_edges, mt_edges, )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "snr = dsdat['snr_ss']\n", + "sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "mtt = np.swapaxes(mtt, -1, -2)\n", + "dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "dcm = np.swapaxes(dcm, -1, -2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "snr_grid = np.zeros((len(mt_edges)-1, len(dc_edges)-1))\n", + "sum_grid = np.zeros_like(snr_grid)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(snr_grid.shape)\n", + "print(mtt.shape, dcm.shape, snr.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for mm in range(len(mt_edges)-1):\n", + " # inmass = np.where(np.logical_and(mtt>mt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcm=3:\n", + " ax.set_xlabel(xlabel)\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " title = plot.PARAM_KEYS[targets[ii]]\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins_tk1.npz'\n", + "\n", + " handles = draw_contours(ax, targets[ii], title, mt_edges=mt_edges, dc_edges=dc_edges, \n", + " levels=levels, colors=colors, load_from=filename)\n", + " ax.legend(handles=handles, title=title, loc='upper left')\n", + "\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " return fig\n", + "\n", + "fig = plot_all_targets(targets)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_all_targets_catcolors(targets, NBINS=20,\n", + " mt_idx_min=mt_idx_min, mt_idx_max=mt_idx_max,\n", + " dc_edge_min=dc_edge_min, dc_edge_max=dc_edge_max,\n", + " levels=np.linspace(3.5,5,5)):\n", + " green_colors = ['#98d594', '#98d594', '#00441b']\n", + " blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", + " orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", + "\n", + " catcolors = [green_colors, orange_colors, blue_colors, \n", + " green_colors, orange_colors, blue_colors]\n", + "\n", + " # get edges\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", + " dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + "\n", + " # make figure\n", + " xlabel='Mass'\n", + " ylabel='Distance'\n", + " fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=True)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " for ii, ax in enumerate(tqdm(axs.flatten())):\n", + " if ii >=3:\n", + " ax.set_xlabel(xlabel)\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " title = plot.PARAM_KEYS[targets[ii]]\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins_tk1.npz'\n", + "\n", + " handles = draw_contours(ax, targets[ii], title, mt_edges=mt_edges, dc_edges=dc_edges, \n", + " levels=levels, colors=catcolors[ii], load_from=filename)\n", + " ax.legend(handles=handles, title=title, loc='upper left')\n", + " \n", + " # plt.subplots_adjust(wspace=0, hspace=0)\n", + " return fig\n", + "\n", + "fig = plot_all_targets_catcolors(targets)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b72dd729d8fe4ccac85394c544606e913bcb0007 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 6 Jul 2023 13:03:24 -0700 Subject: [PATCH 239/291] Plot dp_ssi-weighted frequency mean vs. varying parameter. --- .../tk16_frequency_of_detection.ipynb | 249 ++++++++++++++++++ 1 file changed, 249 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb diff --git a/ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb b/ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb new file mode 100644 index 00000000..148b7388 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb @@ -0,0 +1,249 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import os\n", + "from tqdm import tqdm\n", + "\n", + "from holodeck import plot, detstats, utils\n", + "from holodeck.constants import YR, MSOL, MPC, GYR\n", + "import holodeck as holo" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Set up" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# NSKIES = 15" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get param names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get data and dets file functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_redz':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", + " else:\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target='hard_time'\n", + "\n", + "data, params, dsdat = get_data(target)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "var=10\n", + "dpssi = dsdat[var]['gamma_ssi']\n", + "freqs = data[var]['fobs_cents']\n", + "freqs = np.repeat(freqs, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", + "print(f\"{dpssi.shape=}, {freqs.shape=}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "freq_mean = np.average(freqs, weights=dpssi)\n", + "print(freq_mean*YR)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if BUILD_ARRAYS:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " for target in tqdm(targets):\n", + " print(target)\n", + " xx = [] # param\n", + " yy = [] # frequency means\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target)\n", + " freqs = data[var]['fobs_cents']\n", + " freqs = np.repeat(freqs, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", + "\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dpssi = dsdat[pp]['gamma_ssi']\n", + " freq_mean = np.average(freqs, weights=dpssi)\n", + " yy.append(freq_mean)\n", + "\n", + " np.savez(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", + " xx_params = xx, yy_fmeans = yy)\n", + "else:\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " file = np.load(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " xx = file['xx_params']\n", + " yy = file['yy_params']\n", + " file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "colors = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " \n", + "\n", + "ylabel = '$DP_\\mathrm{SS}$-weighted Frequency [yr$^{-1}$]'\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "\n", + "fig.text(0.04, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "plt.subplots_adjust(wspace=0)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " # if ii == 0 or ii == 3:\n", + " # ax.set_ylabel(ylabel)\n", + " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " xx = file['xx_params']\n", + " yy = file['yy_fmeans']*YR\n", + " ax.plot(xx, yy, color=colors[ii])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 0a58d37bda5ef43d1a6347ad3e6871d5bfd199ec Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 7 Jul 2023 10:56:30 -0700 Subject: [PATCH 240/291] Clean up contours. --- .../paper_plots/dc_vs_mt_snr_contours.ipynb | 344 ++++++++++++++++++ .../paper_plots/snr2_mass_vs_distance.ipynb | 262 +++++++------ 2 files changed, 498 insertions(+), 108 deletions(-) create mode 100644 ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb diff --git a/ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb b/ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb new file mode 100644 index 00000000..daaaa297 --- /dev/null +++ b/ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb @@ -0,0 +1,344 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "from tqdm import tqdm\n", + "import os\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo\n", + "from holodeck.sams import sam\n", + "\n", + "import hasasia.sim as hsim\n", + "\n", + "import sys\n", + "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", + "import anatomy as anat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "cmap_base = 'magma_r'\n", + "magma_r = truncate_colormap(cmap_base, 0, 0.85)\n", + "blacks = truncate_colormap('binary', 0.4, 1.0)\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", + "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)\n", + "cmap_Purples = truncate_colormap('Purples', 0.4, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "RED_GAMMA = None\n", + "RED2WHITE = None\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_var_data( target, var=None, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + "\n", + " path = path + f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}' \n", + " load_data_from_file = path+f'/data_params.npz' \n", + " load_dets_from_file = path+f'/detstats_s{nskies}' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " if var is not None:\n", + " data = file['data'][var]\n", + " params = file['params'][var]\n", + " else:\n", + " data = file['data']\n", + " params = file['params']\n", + "\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " if var is not None:\n", + " dsdat = file['dsdat'][var]\n", + " else:\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Histogram Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def hist_min_med_max(TARGET, mt_edges, dc_edges):\n", + "\n", + " # get minimum weighted histogram\n", + " VAR = 0\n", + " data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + " par_min = params[TARGET]\n", + "\n", + " snr = dsdat['snr_ss']\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " mtt = np.swapaxes(mtt, -1, -2)\n", + " dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " dcm = np.swapaxes(dcm, -1, -2)\n", + "\n", + " hist_min, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", + " bins=(dc_edges, mt_edges), weights=snr.flatten())\n", + " \n", + " # get median weighted histogram\n", + " VAR = 10\n", + " data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + " par_med = params[TARGET]\n", + "\n", + " snr = dsdat['snr_ss']\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " mtt = np.swapaxes(mtt, -1, -2)\n", + " dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " dcm = np.swapaxes(dcm, -1, -2)\n", + "\n", + "\n", + " hist_med, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", + " bins=(dc_edges, mt_edges), weights=snr.flatten())\n", + " \n", + " # get maximum weighted histogram\n", + " VAR = -1\n", + " data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + " par_max = params[TARGET]\n", + "\n", + " snr = dsdat['snr_ss']\n", + " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + " mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " mtt = np.swapaxes(mtt, -1, -2)\n", + " dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + " dcm = np.swapaxes(dcm, -1, -2)\n", + "\n", + "\n", + " hist_max, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", + " bins=(dc_edges, mt_edges), weights=snr.flatten())\n", + " \n", + " rv = dict(hist_min=hist_min, hist_med=hist_med, hist_max=hist_max, \n", + " par_min=par_min, par_med=par_med, par_max=par_max)\n", + " \n", + " return rv\n", + "\n", + "\n", + "def draw_contours(ax, TARGET, title, mt_edges=mt_edges, dc_edges=dc_edges,\n", + " levels=np.linspace(3.5,5,8), colors=None, load_from=None):\n", + " if load_from is None:\n", + " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " else:\n", + " rv = np.load(load_from)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " rv.close()\n", + "\n", + " mt_cents = holo.utils.midpoints(mt_edges)\n", + " dc_cents= holo.utils.midpoints(dc_edges)\n", + "\n", + " if colors is None:\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_min), cmap=cmap_Greens, levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_med), cmap=cmap_Blues, levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_max), cmap=cmap_Purples, levels=levels)\n", + " else:\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_min), colors=colors[0], levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_med), colors=colors[1], levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_max), colors=colors[2], levels=levels)\n", + " # plt.colorbar(im, ax=ax, label='log$\\sum \\mathrm{SNR} (\\\\tau_\\mathrm{hard}=%.2f \\mathrm{Gyr})$' % ht_max)\n", + " \n", + " if colors is None:\n", + " colors = ['#1e8144', \"#347ebb\", '#6e56a6' ]\n", + " handles = [\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_min:.2f}\", color=colors[0]),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_med:.2f}\", color=colors[1]),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_max:.2f}\", color=colors[2])\n", + " ]\n", + " return handles\n", + "\n", + "\n", + "def draw_kale_contours2d(ax, TARGET, title, mt_edges=mt_edges, dc_edges=dc_edges,\n", + " levels=np.linspace(3.5,5,8), colors=None, load_from=None):\n", + " if load_from is None:\n", + " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " else:\n", + " rv = np.load(load_from)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " rv.close()\n", + "\n", + " mt_cents = holo.utils.midpoints(mt_edges)\n", + " dc_cents= holo.utils.midpoints(dc_edges)\n", + "\n", + " if colors is None:\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_min), cmap=cmap_Greens, levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_med), cmap=cmap_Blues, levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_max), cmap=cmap_Purples, levels=levels)\n", + " else:\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_med), colors=colors[1], levels=levels)\n", + " ax.contour(mt_cents, dc_cents, np.log10(hist_max), colors=colors[2], levels=levels)\n", + " plt.colorbar(im, ax=ax, label='log$\\sum \\mathrm{SNR} (\\\\tau_\\mathrm{hard}=%.2f \\mathrm{Gyr})$' % ht_max)\n", + " \n", + " if colors is None:\n", + " colors = ['#1e8144', \"#347ebb\", '#6e56a6' ]\n", + " handles = [\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_min:.2f}\", color=colors[0]),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_med:.2f}\", color=colors[1]),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_max:.2f}\", color=colors[2])\n", + " ]\n", + " return handles" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Save all hist data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# get edges\n", + "NBINS = 40\n", + "TAKE = 4\n", + "mt_idx_min=30 \n", + "mt_idx_max=-8\n", + "dc_edge_min=3e1\n", + "dc_edge_max=1e4\n", + "\n", + "# get edges\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", + "dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + "\n", + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "\n", + "if BUILD_ARRAYS:\n", + " for TARGET in tqdm(targets):\n", + " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'mt_dc_hist_tk{TAKE}_{TARGET}_{NBINS}bins_tk1.npz'\n", + " np.savez(filename,\n", + " hist_min=hist_min, hist_med=hist_med, hist_max=hist_max, \n", + " par_min=par_min, par_med=par_med, par_max=par_max)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb index cbe711e0..4abc0754 100644 --- a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb +++ b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb @@ -298,16 +298,16 @@ "metadata": {}, "outputs": [], "source": [ - "for mm in range(len(mt_edges)-1):\n", - " # inmass = np.where(np.logical_and(mtt>mt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcm=3:\n", + " ax.set_xlabel(xlabel)\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " title = plot.PARAM_KEYS[targets[ii]]\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins_tk1.npz'\n", + "\n", + " handles = draw_contours(ax, targets[ii], title, mt_edges=mt_edges, dc_edges=dc_edges, \n", + " levels=levels, colors=catcolors[ii], load_from=filename)\n", + " ax.legend(handles=handles, title=title, loc='upper left')\n", + " \n", + " # plt.subplots_adjust(wspace=0, hspace=0)\n", + " return fig\n", + "\n", + "fig = plot_all_targets_catcolors(targets)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_all_targets_catcolors(targets, NBINS=20,\n", + " mt_idx_min=mt_idx_min, mt_idx_max=mt_idx_max,\n", + " dc_edge_min=dc_edge_min, dc_edge_max=dc_edge_max,\n", + " levels=np.linspace(3.5,5,5)):\n", + " green_colors = ['#98d594', '#2e984e', '#00441b']\n", " blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", " orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", "\n", From 4df4655f33d73cfdab92a654db68ac778f21fae4 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 7 Jul 2023 11:17:37 -0700 Subject: [PATCH 241/291] Plot one contour plot with kalepy. --- .../paper_plots/snr2_mass_vs_distance.ipynb | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb index 4abc0754..a005dcd9 100644 --- a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb +++ b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb @@ -17,6 +17,7 @@ "import h5py\n", "from tqdm import tqdm\n", "import os\n", + "import kalepy as kale\n", "\n", "\n", "from holodeck import plot, detstats\n", @@ -1018,6 +1019,70 @@ "fig = plot_all_targets_catcolors(targets)" ] }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Kale Contours" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TAKE = 3\n", + "mt_idx_min=30 \n", + "mt_idx_max=-8\n", + "dc_edge_min=3e1\n", + "dc_edge_max=1e4\n", + "\n", + "# get edges\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", + "dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "target = 'hard_time'\n", + "\n", + "green_colors = ['#98d594', '#2e984e', '#00441b']\n", + "blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", + "orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", + "\n", + "filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + "load_from = filename+f'mt_dc_hist_tk{TAKE}_{target}_{NBINS}bins_tk1.npz'\n", + "\n", + "rv = np.load(load_from)\n", + "hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + "par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + "rv.close()\n", + "\n", + "mt_cents = holo.utils.midpoints(mt_edges)\n", + "dc_cents= holo.utils.midpoints(dc_edges)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='Mass [M$_\\odot$]', ylabel='Distance [Mpc]')\n", + "cmap_idx = [0.4, 0.7, 1.0]\n", + "for ii, hist in enumerate([hist_min, hist_med, hist_max]):\n", + " cmap = truncate_colormap('Blues', cmap_idx[ii], cmap_idx[ii])\n", + " kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", + " np.swapaxes(hist,0,1), cmap=cmap)" + ] + }, { "cell_type": "code", "execution_count": null, From a154da95b1af6c4d28acce41d824f9573ab17fc3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 7 Jul 2023 12:35:22 -0700 Subject: [PATCH 242/291] Plot new hc, mass, and distance vs. frequency in new_spectra_charstrain_and_props.ipynb. --- .../paper_plots/charstrain_and_props.ipynb | 3 +- .../new_spectra_charstrain_and_props.ipynb | 754 ++++++++++++++++++ 2 files changed, 756 insertions(+), 1 deletion(-) create mode 100644 ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb index 94df96f4..e5e96513 100644 --- a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb +++ b/ecg-notebooks/paper_plots/charstrain_and_props.ipynb @@ -1131,7 +1131,8 @@ "NVARS = 21\n", "NREALS = 500\n", "\n", - "parvars = [0,5,10,15,20]\n", + "# parvars = [0,5,10,15,20]\n", + "parvars = [0,10,20]\n", "yy_ss = []\n", "yy_bg = []\n", "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", diff --git a/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb new file mode 100644 index 00000000..12ce94c3 --- /dev/null +++ b/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb @@ -0,0 +1,754 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### truncate colormaps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", + "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 3\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "# NSKIES = 15" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "get_data()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + "\n", + " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_09B':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " else:\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " # if os.path.exists(load_dets_from_file) is False:\n", + " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " # raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " # file = np.load(load_dets_from_file, allow_pickle=True)\n", + " # dsdat = file['dsdat']\n", + " # file.close()\n", + "\n", + " return data, params" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Plotting functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "fobs_cents = data[0]['fobs_cents']\n", + "xx = fobs_cents*YR" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_midpoints(xx, yy_ss, yy_bg, parvars, colors):\n", + " ylabels = ['Characteristic Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[var], alpha=0.8, s=20)\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra/midpoints_ci95_var{len(parvars)}_{TARGET}.png',\n", + " dpi=300)\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_95ci(xx, yy_ss, yy_bg, parvars, colors):\n", + " ylabels = ['Characteristic Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra/95ci_var{len(parvars)}_{TARGET}.png',\n", + " dpi=300)\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_errbars(xx, yy_ss, yy_bg, parvars, colors):\n", + " ylabels = ['Characteristic Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " pp = 95\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50, 50 + percs]\n", + " ymin, ymed, ymax = np.percentile(yy_ss[vv][ii], percs, axis=-1)\n", + "\n", + " ax.errorbar(xx, ymed, yerr=(ymed-ymin, ymax-ymed), color=colors[var], alpha=0.5, \n", + " capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the confidence intervals\n", + " for pp in [95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra/95errbars_var{len(parvars)}_{TARGET}.png',\n", + " dpi=300)\n", + " return fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_uplims(xx, yy_ss, yy_bg, parvars, colors):\n", + " ylabels = ['Characteristic Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " pp = 95\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50, 50 + percs]\n", + " ymin, ymed, ymax = np.percentile(yy_ss[vv][ii], percs, axis=-1)\n", + "\n", + " if ii == 2:\n", + " ax.errorbar(xx, ymin, yerr=(ymin-ymin, ymed-ymin), color=colors[var], alpha=0.5, \n", + " capsize=2, lolims=True, marker='o', markersize=3, linestyle='')\n", + " else:\n", + " ax.errorbar(xx, ymax, yerr=(ymax-ymed, ymax-ymax), color=colors[var], alpha=0.5, \n", + " capsize=2, uplims=True, marker='o', markersize=3, linestyle='')\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + " \n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra/95lims_var{len(parvars)}_{TARGET}.png',\n", + " dpi=300)\n", + " return fig\n", + "# fig = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plots From Functions" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "# parvars = [0,10,20]\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig4 = plot_midpoints(xx, yy_ss, yy_bg, parvars, colors)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GSMF_phi0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig4 = plot_midpoints(xx, yy_ss, yy_bg, parvars, colors)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GSMF_mchar0_log10, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig4 = plot_midpoints(xx, yy_ss, yy_bg, parvars, colors)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## mmb_mamp_log10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_mamp_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "colors = cmap_Oranges(np.linspace(0, 1, NVARS))\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig4 = plot_midpoints(xx, yy_ss, yy_bg, parvars, colors)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_scatter_dex" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_scatter_dex'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + " \n", + "colors = cmap_Oranges(np.linspace(0, 1, NVARS))\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig4 = plot_midpoints(xx, yy_ss, yy_bg, parvars, colors)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = colors)\n", + "fig4 = plot_midpoints(xx, yy_ss, yy_bg, parvars, colors)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 83f3d65cd8fed51a3b234a961f32a7b84244aa87 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 7 Jul 2023 14:30:47 -0700 Subject: [PATCH 243/291] Make some small plot corrections. --- .../paper_plots/new_spectra_charstrain_and_props.ipynb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb index 12ce94c3..35e42081 100644 --- a/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb +++ b/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb @@ -163,8 +163,6 @@ " xx = fobs_cents*YR\n", " nsamp = 5\n", "\n", - " colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", - " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", "\n", " for ii, ax in enumerate(axs.flatten()):\n", " # Plot the median \n", @@ -395,7 +393,7 @@ " labels.append(f\"{params[var][TARGET]:.2f}\")\n", "\n", " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", - " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra/95lims_var{len(parvars)}_{TARGET}.png',\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra/95lims_68ci_var{len(parvars)}_{TARGET}.png',\n", " dpi=300)\n", " return fig\n", "# fig = plot_uplims(xx, yy_ss, yy_bg, parvars, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" @@ -476,7 +474,7 @@ "metadata": {}, "outputs": [], "source": [ - "TARGET = 'gsmf_mchar0_log10'\n", + "TARGET = 'gsmf_phi0'\n", "NVARS = 21\n", "NREALS = 500\n", "\n", From 32d5fd8a4991b8ffb72efb0b428e2be652604201 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 7 Jul 2023 15:51:36 -0700 Subject: [PATCH 244/291] Plot dp-weighted frequency confidence intervals with twin nHz y-axes in single and double column formats. --- .../frequency_of_detection.ipynb} | 95 +++++- .../paper_plots/snr2_mass_vs_distance.ipynb | 301 ++++++++++++++---- 2 files changed, 322 insertions(+), 74 deletions(-) rename ecg-notebooks/{parameter_investigation/tk16_frequency_of_detection.ipynb => paper_plots/frequency_of_detection.ipynb} (68%) diff --git a/ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb b/ecg-notebooks/paper_plots/frequency_of_detection.ipynb similarity index 68% rename from ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb rename to ecg-notebooks/paper_plots/frequency_of_detection.ipynb index 148b7388..08c55588 100644 --- a/ecg-notebooks/parameter_investigation/tk16_frequency_of_detection.ipynb +++ b/ecg-notebooks/paper_plots/frequency_of_detection.ipynb @@ -23,6 +23,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -41,7 +42,7 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "BUILD_ARRAYS = True\n", + "BUILD_ARRAYS = False\n", "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", @@ -55,6 +56,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -72,6 +74,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ @@ -152,6 +155,26 @@ "print(freq_mean*YR)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def _twiny_hz(ax, nano=True, fs=10, label=True, **kw):\n", + " tw = ax.twinx()\n", + " tw.grid(False)\n", + " ylim = np.array(ax.get_ylim()) / YR\n", + " if nano:\n", + " ylim *= 1e9\n", + "\n", + " tw.set(ylim=ylim, yscale=ax.get_yscale())\n", + " if label:\n", + " label = plot.LABEL_GW_FREQUENCY_NHZ if nano else plot.LABEL_GW_FREQUENCY_YR\n", + " tw.set_ylabel(label, fontsize=fs, **kw)\n", + " return tw" + ] + }, { "cell_type": "code", "execution_count": null, @@ -176,7 +199,7 @@ " for pp, par in enumerate(params):\n", " xx.append(params[pp][target])\n", " dpssi = dsdat[pp]['gamma_ssi']\n", - " freq_mean = np.average(freqs, weights=dpssi)\n", + " freq_mean = np.average(freqs, weights=dpssi, axis=(0,-1))\n", " yy.append(freq_mean)\n", "\n", " np.savez(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", @@ -185,7 +208,7 @@ " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " file = np.load(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", " xx = file['xx_params']\n", - " yy = file['yy_params']\n", + " yy = file['yy_fmeans']\n", " file.close()\n" ] }, @@ -202,10 +225,14 @@ "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " \n", "\n", - "ylabel = '$DP_\\mathrm{SS}$-weighted Frequency [yr$^{-1}$]'\n", + "ylabel = 'Frequency [yr$^{-1}$]'\n", + "ylabel_nHz = 'Frequency [nHz]'\n", + "\n", + "\n", "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", "\n", - "fig.text(0.04, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "fig.text(0.06, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "fig.text(1.02, 0.5, ylabel_nHz, ha='right', va='center', rotation=270)\n", "plt.subplots_adjust(wspace=0)\n", "for ii, ax in enumerate(axs.flatten()):\n", " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", @@ -214,7 +241,63 @@ " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", " xx = file['xx_params']\n", " yy = file['yy_fmeans']*YR\n", - " ax.plot(xx, yy, color=colors[ii])" + " print(f\"{yy.shape=}\")\n", + " plot.draw_med_conf_color(ax, xx, yy.reshape(NVARS, NREALS*NSKIES), color=colors[ii])\n", + " if ii==2 or ii==5:\n", + " _twiny_hz(ax, label=False, nano=True)\n", + " \n", + "\n", + "# saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "# savename = saveloc+'/frequencies_double.png'\n", + "# fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "colors = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " \n", + "\n", + "ylabel = 'Frequency [yr$^{-1}$]'\n", + "ylabel_nHz = 'Frequency [nHz]'\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, \n", + " sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " # if ii == 0 or ii == 3:\n", + " # ax.set_ylabel(ylabel)\n", + " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " xx = file['xx_params']\n", + " yy = file['yy_fmeans']*YR\n", + " print(f\"{yy.shape=}\")\n", + " plot.draw_med_conf_color(ax, xx, yy.reshape(NVARS, NREALS*NSKIES), color=colors[ii])\n", + " if ii%2 == 1:\n", + " _twiny_hz(ax, label=False)\n", + "# fig.tight_layout()\n", + " # ax.tick_params(axis='x', labelrotation=45)\n", + "\n", + "fig.text(0.08, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "fig.text(1.04, 0.5, ylabel_nHz, ha='right', va='center', rotation=270)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "savename = saveloc+'/frequencies_single.png'\n", + "fig.savefig(savename, dpi=100)" ] }, { diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb index a005dcd9..e930a3ef 100644 --- a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb +++ b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb @@ -695,12 +695,6 @@ "metadata": {}, "outputs": [], "source": [ - "# get edges\n", - "NBINS = 20\n", - "sam = holo.sams.Semi_Analytic_Model()\n", - "mt_edges = sam.mtot[25:-15]/MSOL\n", - "dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", - "\n", "def hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,):\n", "\n", " # get minimum weighted histogram\n", @@ -759,7 +753,7 @@ " return rv\n", "\n", "\n", - "def draw_contours(ax, TARGET, title, mt_edges=mt_edges, dc_edges=dc_edges,\n", + "def draw_contours(ax, TARGET, mt_edges=mt_edges, dc_edges=dc_edges,\n", " levels=np.linspace(3.5,5,8), colors=None, load_from=None):\n", " if load_from is None:\n", " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", @@ -808,26 +802,39 @@ "metadata": {}, "outputs": [], "source": [ - "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", - " 'hard_time', 'hard_gamma_inner']\n", - "TAKE = 3\n", - "mt_idx_min=30 \n", - "mt_idx_max=-8\n", - "dc_edge_min=3e1\n", - "dc_edge_max=1e4\n", + "print(f\"{sam.mtot[42]/MSOL:.2e}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "NBINS = 40\n", + "TAKE = 4\n", + "MT_IDX_MIN=42 \n", + "MT_IDX_MAX=-8\n", + "DC_EDGE_MIN=3e1\n", + "DC_EDGE_MAX=1e4\n", + "\n", "\n", "# get edges\n", "sam = holo.sams.Semi_Analytic_Model()\n", - "mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - "dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + "mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + "dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", + "\n", "\n", + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", "if BUILD_ARRAYS:\n", " for TARGET in tqdm(targets):\n", " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - " filename = filename+f'mt_dc_hist_tk{TAKE}_{TARGET}_{NBINS}bins_tk1.npz'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{TARGET}_{NBINS}bins.npz'\n", " np.savez(filename,\n", " hist_min=hist_min, hist_med=hist_med, hist_max=hist_max, \n", " par_min=par_min, par_med=par_med, par_max=par_max)" @@ -848,32 +855,35 @@ "outputs": [], "source": [ "\n", - "def plot_one_target(TARGET, title, NBINS=20,\n", - " mt_idx_min=mt_idx_min, mt_idx_max=mt_idx_max,\n", - " dc_edge_min=dc_edge_min, dc_edge_max=dc_edge_max,\n", + "def plot_one_target(TARGET, title, NBINS=NBINS,\n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", + " DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", " levels=np.linspace(3.5,5,8), load_from=None):\n", "\n", " # get edges\n", " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - " dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + " mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", "\n", " # make figure\n", " fig, ax = plot.figax_single(xlabel='Mass', ylabel='Distance',)\n", - " handles = draw_contours(ax, TARGET, title, mt_edges=mt_edges, dc_edges=dc_edges, levels=levels, load_from=load_from)\n", + " handles = draw_contours(ax, TARGET, mt_edges=mt_edges, dc_edges=dc_edges, levels=levels, load_from=load_from)\n", " ax.legend(handles=handles, title=title, loc='upper left')\n", " return fig\n", "\n", + "\n", "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", " 'hard_time', 'hard_gamma_inner']\n", - "for tt, target in enumerate(tqdm(targets)):\n", - " title = plot.PARAM_KEYS[target]\n", "\n", - " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - " filename = filename+f'mt_dc_hist_tk{TAKE}_{TARGET}_{NBINS}bins_tk1.npz'\n", "\n", + "for tt, TARGET in enumerate(tqdm(targets)):\n", + " title = plot.PARAM_KEYS[TARGET]\n", + "\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{TARGET}_{NBINS}bins.npz'\n", + " print(filename)\n", " print(title)\n", - " fig = plot_one_target(target, title, load_from=filename)" + " fig = plot_one_target(TARGET, title, load_from=filename)" ] }, { @@ -893,15 +903,15 @@ "targets = ['gsmf_phi0', 'mmb_mamp_log10', 'hard_time',\n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", "\n", - "def plot_all_targets(targets, NBINS=20,\n", - " mt_idx_min=mt_idx_min, mt_idx_max=mt_idx_max,\n", - " dc_edge_min=dc_edge_min, dc_edge_max=dc_edge_max,\n", + "def plot_all_targets(targets, NBINS=NBINS,\n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", + " DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", " levels=np.linspace(3.5,5,8), colors=None):\n", "\n", " # get edges\n", " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - " dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + " mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", "\n", " # make figure\n", " xlabel='Mass [M$_\\odot$]'\n", @@ -915,9 +925,9 @@ " ax.set_ylabel(ylabel)\n", " title = plot.PARAM_KEYS[targets[ii]]\n", " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - " filename = filename+f'mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins_tk1.npz'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins.npz'\n", "\n", - " handles = draw_contours(ax, targets[ii], title, mt_edges=mt_edges, dc_edges=dc_edges, \n", + " handles = draw_contours(ax, targets[ii], mt_edges=mt_edges, dc_edges=dc_edges, \n", " levels=levels, colors=colors, load_from=filename)\n", " ax.legend(handles=handles, title=title, loc='upper left')\n", "\n", @@ -933,9 +943,9 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_all_targets_catcolors(targets, NBINS=20,\n", - " mt_idx_min=mt_idx_min, mt_idx_max=mt_idx_max,\n", - " dc_edge_min=dc_edge_min, dc_edge_max=dc_edge_max,\n", + "def plot_all_targets_catcolors(targets, NBINS=NBINS,\n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", + " DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", " levels=np.linspace(3.5,5,5)):\n", " green_colors = ['#98d594', '#2e984e', '#00441b']\n", " blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", @@ -946,8 +956,8 @@ "\n", " # get edges\n", " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - " dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + " mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", "\n", " # make figure\n", " xlabel='Mass'\n", @@ -961,16 +971,16 @@ " ax.set_ylabel(ylabel)\n", " title = plot.PARAM_KEYS[targets[ii]]\n", " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - " filename = filename+f'mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins_tk1.npz'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins.npz'\n", "\n", - " handles = draw_contours(ax, targets[ii], title, mt_edges=mt_edges, dc_edges=dc_edges, \n", + " handles = draw_contours(ax, targets[ii], mt_edges=mt_edges, dc_edges=dc_edges, \n", " levels=levels, colors=catcolors[ii], load_from=filename)\n", " ax.legend(handles=handles, title=title, loc='upper left')\n", " \n", " # plt.subplots_adjust(wspace=0, hspace=0)\n", " return fig\n", "\n", - "fig = plot_all_targets_catcolors(targets)" + "fig = plot_all_targets_catcolors(targets)\n" ] }, { @@ -979,9 +989,9 @@ "metadata": {}, "outputs": [], "source": [ - "def plot_all_targets_catcolors(targets, NBINS=20,\n", - " mt_idx_min=mt_idx_min, mt_idx_max=mt_idx_max,\n", - " dc_edge_min=dc_edge_min, dc_edge_max=dc_edge_max,\n", + "def plot_all_targets_catcolors(targets, NBINS=NBINS,\n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", + " DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", " levels=np.linspace(3.5,5,5)):\n", " green_colors = ['#98d594', '#2e984e', '#00441b']\n", " blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", @@ -992,8 +1002,8 @@ "\n", " # get edges\n", " sam = holo.sams.Semi_Analytic_Model()\n", - " mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - " dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", + " mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", "\n", " # make figure\n", " xlabel='Mass'\n", @@ -1007,9 +1017,9 @@ " ax.set_ylabel(ylabel)\n", " title = plot.PARAM_KEYS[targets[ii]]\n", " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - " filename = filename+f'mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins_tk1.npz'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins.npz'\n", "\n", - " handles = draw_contours(ax, targets[ii], title, mt_edges=mt_edges, dc_edges=dc_edges, \n", + " handles = draw_contours(ax, targets[ii], mt_edges=mt_edges, dc_edges=dc_edges, \n", " levels=levels, colors=catcolors[ii], load_from=filename)\n", " ax.legend(handles=handles, title=title, loc='upper left')\n", " \n", @@ -1024,7 +1034,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Kale Contours" + "# Kale Contours\n", + "\n", + "Using default sigmas: _DEF_SIGMAS = [0.5, 1.0, 1.5, 2.0]" ] }, { @@ -1033,16 +1045,25 @@ "metadata": {}, "outputs": [], "source": [ - "TAKE = 3\n", - "mt_idx_min=30 \n", - "mt_idx_max=-8\n", - "dc_edge_min=3e1\n", - "dc_edge_max=1e4\n", - "\n", - "# get edges\n", - "sam = holo.sams.Semi_Analytic_Model()\n", - "mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - "dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)" + "print(f\"{sam.mtot[35]/MSOL:.2e}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TAKE = 3\n", + "# MT_IDX_MIN=30 \n", + "# MT_IDX_MAX=-8\n", + "# DC_EDGE_MIN=3e1\n", + "# DC_EDGE_MAX=1e4\n", + "\n", + "# # get edges\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + "# dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)" ] }, { @@ -1058,7 +1079,7 @@ "orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", "\n", "filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - "load_from = filename+f'mt_dc_hist_tk{TAKE}_{target}_{NBINS}bins_tk1.npz'\n", + "load_from = filename+f'/mt_dc_hist_tk{TAKE}_{target}_{NBINS}bins.npz'\n", "\n", "rv = np.load(load_from)\n", "hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", @@ -1075,12 +1096,156 @@ "metadata": {}, "outputs": [], "source": [ - "fig, ax = plot.figax(xlabel='Mass [M$_\\odot$]', ylabel='Distance [Mpc]')\n", - "cmap_idx = [0.4, 0.7, 1.0]\n", - "for ii, hist in enumerate([hist_min, hist_med, hist_max]):\n", - " cmap = truncate_colormap('Blues', cmap_idx[ii], cmap_idx[ii])\n", - " kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", - " np.swapaxes(hist,0,1), cmap=cmap)" + "# fig, ax = plot.figax(xlabel='Mass [M$_\\odot$]', ylabel='Distance [Mpc]')\n", + "# cmap_idx = [0.4, 0.7, 1.0]\n", + "# for ii, hist in enumerate([hist_min, hist_med, hist_max]):\n", + "# cmap = truncate_colormap('Blues', cmap_idx[ii], cmap_idx[ii])\n", + "# kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", + "# np.swapaxes(hist,0,1), cmap=cmap, outline=False)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# fig, ax = plot.figax(xlabel='Mass [M$_\\odot$]', ylabel='Distance [Mpc]')\n", + "# cmap_idx = [0.4, 0.7, 1.0]\n", + "# for ii, hist in enumerate([hist_min, hist_med, hist_max]):\n", + "# cmap = truncate_colormap('Blues', cmap_idx[ii], cmap_idx[ii])\n", + "# kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", + "# np.swapaxes(hist,0,1), cmap=cmap, outline=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "quantiles, sigmas = kale.plot._default_quantiles(sigmas=[0.5,1.0,1.5])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_all_targets_catcolors(\n", + " targets, NBINS=NBINS, \n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX, DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", + " quantiles=None, smooth=None):\n", + " green_colors = ['#98d594', '#2e984e', '#00441b']\n", + " blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", + " orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", + "\n", + " catcolors = [green_colors, orange_colors, blue_colors, \n", + " green_colors, orange_colors, blue_colors]\n", + " \n", + "\n", + " cmap_idx = [0.4, 0.7, 1.0]\n", + " cmaps = ['Greens', 'Oranges', 'Blues',\n", + " 'Greens', 'Oranges', 'Blues',]\n", + "\n", + " # get edges\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", + "\n", + " # make figure\n", + " xlabel='Mass'\n", + " ylabel='Distance'\n", + " fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=True)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " for ii, ax in enumerate(tqdm(axs.flatten())):\n", + " colors = catcolors[ii]\n", + " if ii >=3:\n", + " ax.set_xlabel(xlabel)\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " title = plot.PARAM_KEYS[targets[ii]]\n", + "\n", + " # load histogram data\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins.npz'\n", + " rv = np.load(filename)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " rv.close()\n", + "\n", + " # plot histogram\n", + " for hh, hist in enumerate([hist_min, hist_med, hist_max]):\n", + " cmap = truncate_colormap(cmaps[ii], cmap_idx[hh], cmap_idx[hh])\n", + " kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", + " np.swapaxes(hist,0,1), cmap=cmap, \n", + " outline=False, quantiles=quantiles, smooth=smooth)\n", + " \n", + "\n", + " # make legend\n", + " alpha = 1- np.sqrt(1-0.8)\n", + " handles = [\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_min:.2f}\", color=colors[0], alpha=alpha),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_med:.2f}\", color=colors[1], alpha=alpha),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_max:.2f}\", color=colors[2], alpha=alpha),\n", + " ]\n", + " ax.legend(handles=handles, title=title, loc='upper left')\n", + " \n", + " # plt.subplots_adjust(wspace=0, hspace=0)\n", + " return fig\n", + "\n", + "fig = plot_all_targets_catcolors(targets)\n", + "\n", + "savepath = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_contours'\n", + "savename = f\"{savepath}/snr_kale_contours.png\"\n", + "fig.savefig(savename, dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sigmas = [1.0, 2.0]\n", + "quantiles = 1.0 - np.exp(-0.5 * np.square(sigmas))\n", + "print(quantiles)\n", + "\n", + "fig = plot_all_targets_catcolors(targets, NBINS=NBINS,\n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", + " DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", + " smooth=True)\n", + "savepath = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_contours'\n", + "savename = f\"{savepath}/snr_smooth_contours.png\"\n", + "fig.savefig(savename, dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "sigmas = [1.0, 2.0]\n", + "quantiles = 1.0 - np.exp(-0.5 * np.square(sigmas))\n", + "print(quantiles)\n", + "\n", + "fig = plot_all_targets_catcolors(targets, NBINS=NBINS,\n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", + " DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", + " quantiles=quantiles)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "alpha=0.99\n", + "alpha = 1- np.sqrt(1-alpha)\n", + "print(alpha)" ] }, { From 4bd73bfc6e1eff31d68e9706e2d125b755945b64 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 9 Jul 2023 05:01:26 -0700 Subject: [PATCH 245/291] Random plot stuff. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 17 ++++++++++++++--- .../paper_plots/snr2_mass_vs_distance.ipynb | 11 +++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index b463a42e..871a69b3 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -15,6 +15,7 @@ "import matplotlib.cm as cm\n", "import h5py\n", "import matplotlib as mpl\n", + "from tqdm import tqdm\n", "\n", "\n", "from holodeck import plot, detstats\n", @@ -46,7 +47,7 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "BUILD_ARRAYS = False\n", + "BUILD_ARRAYS = True\n", "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", @@ -148,7 +149,7 @@ " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", - " for target in targets:\n", + " for target in tqdm(targets):\n", " print(target)\n", "\n", " # white noise only\n", @@ -178,10 +179,20 @@ " y3p0.append(dp_ss/dp_bg)\n", "\n", " \n", - " np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", + " np.savez(path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/mmb_scatter_dex_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-3.0.npz')\n", + "print(file.files)" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb index e930a3ef..5a35db31 100644 --- a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb +++ b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb @@ -33,6 +33,17 @@ "import anatomy as anat" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents, fobs_edges = holo.utils.pta_freqs()\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "print(cad/YR)" + ] + }, { "cell_type": "code", "execution_count": null, From e62491d5ed4d5cf3bda791226ed7750acef98640 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 9 Jul 2023 05:22:21 -0700 Subject: [PATCH 246/291] Run GW-only PTA calibration model using detect_model_clbrt_7GW.py script. --- .../detect_model_clbrt_7GW.py | 236 ++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py new file mode 100644 index 00000000..cfb8d26a --- /dev/null +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py @@ -0,0 +1,236 @@ +import numpy as np +import holodeck as holo +import argparse +from holodeck import detstats +from datetime import datetime +import os + +# sample +DEF_SHAPE = None +DEF_NLOUDEST = 10 +DEF_NREALS = 100 +DEF_NFREQS = 40 +DEF_NVARS = 21 + +# pta calibration +DEF_NSKIES = 100 +DEF_NPSRS = 40 +DEF_RED_AMP = None +DEF_RED_GAMMA = None +DEF_RED2WHITE = None + +DEF_TOL = 0.01 +DEF_MAXBADS = 5 +GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' + +# settings to vary +DEF_CONSTRUCT = False +DEF_DETSTATS = False + + +def _setup_argparse(): + parser = argparse.ArgumentParser() + parser.add_argument('target', action='store', type=str, + help="target parameter to vary") + # parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + # help="gamma-rho interpolation grid path") + + # sample models setup + parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, + help='number of frequency bins') + parser.add_argument('-r', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, + help='number of strain realizations') + parser.add_argument('-l', '--nloudest', action='store', dest='nloudest', type=int, default=DEF_NLOUDEST, + help='number of loudest single sources') + parser.add_argument('-v', '--nvars', action='store', dest='nvars', type=int, default=DEF_NVARS, + help='number of variations on target param') + parser.add_argument('--shape', action='store', dest='shape', type=int, default=DEF_SHAPE, + help='sam shape') + # parser.add_argument('-d', '--dur', action='store', dest='dur', type=int, default=DEF_PTA_DUR, + # help='pta duration in yrs') + + + + # pta setup + parser.add_argument('-p', '--npsrs', action='store', dest='npsrs', type=int, default=DEF_NPSRS, + help='number of pulsars in pta') + parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, + help='number of ss sky realizations') + parser.add_argument('--red_amp', action='store', dest='red_amp', type=float, default=DEF_RED_AMP, + help='Red noise amplitude') + parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=float, default=DEF_RED_GAMMA, + help='Red noise gamma') + parser.add_argument('--red2white', action='store', dest='red2white', type=float, default=DEF_RED2WHITE, + help='Red noise amplitude to white noise amplitude ratio.') + + # pta calibration settings + parser.add_argument('--sigstart', action='store', dest='sigstart', type=float, default=1e-7, + help='starting sigma if for realization calibration') + parser.add_argument('--sigmin', action='store', dest='sigmin', type=float, default=1e-10, + help='sigma minimum for calibration') + parser.add_argument('--sigmax', action='store', dest='sigmax', type=float, default=1e-4, + help='sigma maximum for calibration') + parser.add_argument('--thresh', action='store', dest='thresh', type=float, default=0.5, + help='threshold for detection fractions') + parser.add_argument('-t', '--tol', action='store', dest='tol', type=float, default=DEF_TOL, + help='tolerance for BG DP calibration') + parser.add_argument('-b', '--maxbads', action='store', dest='maxbads', type=int, default=DEF_MAXBADS, + help='number of bad sigmas to try before expanding the search range') + + # general settings + parser.add_argument('--construct', action='store_true', default=DEF_CONSTRUCT, + help='construct data and detstats for each varying param') + parser.add_argument('--detstats', action='store_true', default=DEF_DETSTATS, + help='construct detstats, using saved data') + parser.add_argument('--debug', action='store_true', default=False, + help='print steps along the way') + + # rarely need changing + parser.add_argument('--snr_cython', action='store_true', default=True, + help='Use cython for ss snr calculations') + parser.add_argument('--save_ssi', action='store_true', default=True, + help="Save 'gamma_ssi', the detprob of each single source.") + parser.add_argument('--clbrt', action='store_true', default=True, + help="Whether or not to calibrate the PTA for individual realizations.") + parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + help="gamma-rho interpolation grid path") + parser.add_argument('--anatomy_path', action='store', dest ='anatomy_path', type=str, default=ANATOMY_PATH, + help="path to load and save anatomy files") + parser.add_argument('--load_file', action='store', dest ='load_file', type=str, default=None, + help="file to load sample data and params, excluding .npz suffice") + parser.add_argument('--save_file', action='store', dest ='save_file', type=str, default=None, + help="file to save sample data, excluding .npz suffix") + + args = parser.parse_args() + return args + + +# # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this +# pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None) + +def vary_parameter( + target_param, # the name of the parameter, has to exist in `param_names` + params_list, # the values we'll check + nreals, nfreqs, nloudest, + pspace, + pars=None, debug=True + ): + + # get the parameter names from this library-space + param_names = pspace.param_names + num_pars = len(pspace.param_names) + if debug: print(f"{num_pars=} :: {param_names=}") + + # choose each parameter to be half-way across the range provided by the library + if pars is None: + pars = 0.5 * np.ones(num_pars) + str_pars = str(pars).replace(" ", "_").replace("[", "").replace("]", "") + # Choose parameter to vary + param_idx = param_names.index(target_param) + + data = [] + params = [] + for ii, par in enumerate(params_list): + pars[param_idx] = par + if debug: print(f"{ii=}, {pars=}") + # _params = pspace.param_samples[0]*pars + _params = pspace.normalized_params(pars) + params.append(_params) + # construct `sam` and `hard` instances based on these parameters + sam, hard = pspace.model_for_params(_params, pspace.sam_shape) + # run this model, retrieving binary parameters and the GWB + _data = holo.librarian.run_model(sam, hard, nreals, nfreqs, nloudest=nloudest, + gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True) + data.append(_data) + + return (data, params) + + + +def main(): + start_time = datetime.now() + print("-----------------------------------------") + print(f"starting at {start_time}") + print("-----------------------------------------") + + # set up args + args = _setup_argparse() + print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" + % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) + + # set up output folder + output_path = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' + # check if output folder already exists, if not, make it. + if os.path.exists(output_path) is False: + os.makedirs(output_path) + + # set up load and save locations + if args.load_file is None: + load_data_from_file = output_path+'/data_params' + else: + load_data_from_file = args.load_file + + if args.save_file is None: + save_data_to_file = output_path+'/data_params' + else: + save_data_to_file = args.save_file + + save_dets_to_file = output_path+f'/detstats_s{args.nskies}' + if args.red2white is not None and args.red_gamma is not None: + save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' + elif args.red_amp is not None and args.red_gamma is not None: + save_dets_to_file = save_dets_to_file+f'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1f}' + else: + save_dets_to_file = save_dets_to_file+f'_white' + + if args.red2white is not None and args.red_amp is not None: + print(f"{args.red2white=} and {args.red_amp} both provided. red_amp will be overriden by red2white ratio.") + + print(f"{load_data_from_file=}.npz") + print(f"{save_data_to_file=}.npz") + print(f"{save_dets_to_file=}.npz") + + + # calculate model and/or detstats + if args.construct or args.detstats: + if args.construct: + params_list = np.linspace(0,1,args.nvars) + data, params, = vary_parameter( + target_param=args.target, params_list=params_list, + nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, + pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=args.shape, seed=None),) + np.savez(save_data_to_file+'.npz', data=data, params=params) # save before calculating detstats, in case of crash + else: + file = np.load(load_data_from_file+'.npz', allow_pickle=True) + print('loaded files:', file.files) + data = file['data'] + params = file['params'] + file.close() + + fobs_cents = data[0]['fobs_cents'] + + # get dsdat for each data/param + dsdat = [] + for ii, _data in enumerate(data): + if args.debug: print(f"on var {ii=} out of {args.nvars}") + hc_bg = _data['hc_bg'] + hc_ss = _data['hc_ss'] + _dsdat = detstats.detect_pspace_model_clbrt_pta( + fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, + sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, + thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma, red2white=args.red2white) + dsdat.append(_dsdat) + np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs, red2white=args.red2white) # overwrite + else: + print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") + + end_time = datetime.now() + print("-----------------------------------------") + print(f"ending at {end_time}") + print(f"total time: {end_time - start_time}") + print("-----------------------------------------") + +if __name__ == "__main__": + main() + From c74c3340c7f1869347025b8e4e0247cb576fcad8 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 9 Jul 2023 05:27:41 -0700 Subject: [PATCH 247/291] Clean up print statements from redz troubleshooting. --- holodeck/single_sources.py | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/holodeck/single_sources.py b/holodeck/single_sources.py index e13505db..a0287c19 100644 --- a/holodeck/single_sources.py +++ b/holodeck/single_sources.py @@ -122,12 +122,11 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): # raise ValueError(err) dcom_final = +np.inf*np.ones_like(redz) - # print(holo.utils.stats(redz), "before sel") + sel = (redz > 0.0) redz[~sel] = -1.0 - # print(holo.utils.stats(redz), "after sel") redz[redz<0] = -1.0 - # print(holo.utils.stats(redz), "after redz[redz<0]=-1") + dcom_final[sel] = cosmo.comoving_distance(redz[sel]).cgs.value if np.any(dcom_final<0): print('dcom_final<0 found') if np.any(np.isnan(dcom_final)): print('nan dcom_final found') @@ -141,11 +140,7 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): sepa = utils.kepler_sepa_from_freq(mt[:,np.newaxis,np.newaxis,np.newaxis], frst_orb_cents) # (M,Q,Z,F) in cm angs = utils.angs_from_sepa(sepa, dcom_final, redz) # (M,Q,Z,F) use sepa and dcom in cm - print(f"{mt.shape=}, {redz.shape=}, {edges[0].shape=}, {number.shape=}") - # if np.any(np.logical_and(redz<0, redz!=-1)): - # err = np.sum(np.logical_and(redz<0, redz!=-1)) - # err = f"{err} redz < 0 and !=-1 found in redz, in ss_gws_redz()" - # raise ValueError(err) + hc2ss, hc2bg, sspar, bgpar = \ holo.cyutils.loudest_hc_and_par_from_sorted_redz( @@ -156,25 +151,13 @@ def ss_gws_redz(edges, redz, number, realize, loudest = 1, params = False): hc_bg = np.sqrt(hc2bg) # calculate background strain - # either = np.logical_or(sspar[3]>0, sspar[3]==-1) - # print('either:', sspar[3][either]) - # neither = np.logical_not(either) - # print('neither:', sspar[3][neither]) + + # check that all final redshifts are positive or -1 if np.any(np.logical_and(sspar[3]<0, sspar[3]!=-1)): err = np.sum(np.logical_and(sspar[3]<0, sspar[3]!=-1)) err = f"check 1: {err} out of {sspar[3].size} sspar[3] are negative and not -1 in sings.ss_gws_redz()" - neither = (np.logical_and(sspar[3]<0, sspar[3]!=-1)) - # print('bad sspar:' ,sspar[3][neither], 'at', np.where(neither==True)) - print(err) raise ValueError(err) - - # check for negatives - # if np.any(sspar[3]<0): - sumfalse = np.sum(sspar[3]<0) - err = f"check 2: {sumfalse} out of {sspar[3].size} redz_final are negative in sings.ss_gws_redz()" - # print(np.where(neither==True)) - print(err) - # raise ValueError(err) + # return return hc_ss, hc_bg, sspar, bgpar From ea49e7ec763e8dc7cb1b801114c0ec6caa6a7101 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 9 Jul 2023 13:48:32 -0500 Subject: [PATCH 248/291] Add tqdm to script loops. --- .../parameter_investigation/detect_model_clbrt_7GW.py | 6 +++--- .../parameter_investigation/detect_model_clbrt_pta.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py index cfb8d26a..5ea48fad 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py @@ -3,6 +3,7 @@ import argparse from holodeck import detstats from datetime import datetime +from tqdm import tqdm import os # sample @@ -125,13 +126,12 @@ def vary_parameter( # choose each parameter to be half-way across the range provided by the library if pars is None: pars = 0.5 * np.ones(num_pars) - str_pars = str(pars).replace(" ", "_").replace("[", "").replace("]", "") # Choose parameter to vary param_idx = param_names.index(target_param) data = [] params = [] - for ii, par in enumerate(params_list): + for ii, par in enumerate(tqdm(params_list)): pars[param_idx] = par if debug: print(f"{ii=}, {pars=}") # _params = pspace.param_samples[0]*pars @@ -212,7 +212,7 @@ def main(): # get dsdat for each data/param dsdat = [] - for ii, _data in enumerate(data): + for ii, _data in enumerate(tqdm(data)): if args.debug: print(f"on var {ii=} out of {args.nvars}") hc_bg = _data['hc_bg'] hc_ss = _data['hc_ss'] diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index 690bb882..a2f31802 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -3,6 +3,7 @@ import argparse from holodeck import detstats from datetime import datetime +from tqdm import tqdm import os # sample @@ -131,7 +132,7 @@ def vary_parameter( data = [] params = [] - for ii, par in enumerate(params_list): + for ii, par in enumerate(tqdm(params_list)): pars[param_idx] = par if debug: print(f"{ii=}, {pars=}") # _params = pspace.param_samples[0]*pars @@ -208,7 +209,7 @@ def main(): # get dsdat for each data/param dsdat = [] - for ii, _data in enumerate(data): + for ii, _data in enumerate(tqdm(data)): if args.debug: print(f"on var {ii=} out of {args.nvars}") hc_bg = _data['hc_bg'] hc_ss = _data['hc_ss'] From f396dfea52ebf031b2f243e3865876203cfe71c3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 9 Jul 2023 14:14:53 -0500 Subject: [PATCH 249/291] Make detect model script with option for extended duration. --- .../detect_model_clbrt_100yr.py | 299 ++++++++++++++++++ 1 file changed, 299 insertions(+) create mode 100644 ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py new file mode 100644 index 00000000..c7f51ce8 --- /dev/null +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py @@ -0,0 +1,299 @@ +import numpy as np +import holodeck as holo +import argparse +from holodeck import detstats +from datetime import datetime +from tqdm import tqdm +import os + +from holodeck.sams import cyutils as sam_cyutils +from holodeck.constants import YR + + +# sample +DEF_SHAPE = None +DEF_NLOUDEST = 10 +DEF_NREALS = 100 +DEF_NFREQS = 40 +DEF_NVARS = 21 +DEF_PTA_DUR = holo.librarian.DEF_PTA_DUR + +# pta calibration +DEF_NSKIES = 100 +DEF_NPSRS = 40 +DEF_RED_AMP = None +DEF_RED_GAMMA = None +DEF_RED2WHITE = None + +DEF_TOL = 0.01 +DEF_MAXBADS = 5 +GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' + +# settings to vary +DEF_CONSTRUCT = False +DEF_DETSTATS = False + + +def _setup_argparse(): + parser = argparse.ArgumentParser() + parser.add_argument('target', action='store', type=str, + help="target parameter to vary") + # parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + # help="gamma-rho interpolation grid path") + + # sample models setup + parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, + help='number of frequency bins') + parser.add_argument('-r', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, + help='number of strain realizations') + parser.add_argument('-l', '--nloudest', action='store', dest='nloudest', type=int, default=DEF_NLOUDEST, + help='number of loudest single sources') + parser.add_argument('-v', '--nvars', action='store', dest='nvars', type=int, default=DEF_NVARS, + help='number of variations on target param') + parser.add_argument('--shape', action='store', dest='shape', type=int, default=DEF_SHAPE, + help='sam shape') + parser.add_argument('-d', '--dur', action='store', dest='pta_dur', type=int, default=DEF_PTA_DUR, + help='pta duration in yrs') + + + + # pta setup + parser.add_argument('-p', '--npsrs', action='store', dest='npsrs', type=int, default=DEF_NPSRS, + help='number of pulsars in pta') + parser.add_argument('-s', '--nskies', action='store', dest='nskies', type=int, default=DEF_NSKIES, + help='number of ss sky realizations') + parser.add_argument('--red_amp', action='store', dest='red_amp', type=float, default=DEF_RED_AMP, + help='Red noise amplitude') + parser.add_argument('--red_gamma', action='store', dest='red_gamma', type=float, default=DEF_RED_GAMMA, + help='Red noise gamma') + parser.add_argument('--red2white', action='store', dest='red2white', type=float, default=DEF_RED2WHITE, + help='Red noise amplitude to white noise amplitude ratio.') + + # pta calibration settings + parser.add_argument('--sigstart', action='store', dest='sigstart', type=float, default=1e-7, + help='starting sigma if for realization calibration') + parser.add_argument('--sigmin', action='store', dest='sigmin', type=float, default=1e-10, + help='sigma minimum for calibration') + parser.add_argument('--sigmax', action='store', dest='sigmax', type=float, default=1e-4, + help='sigma maximum for calibration') + parser.add_argument('--thresh', action='store', dest='thresh', type=float, default=0.5, + help='threshold for detection fractions') + parser.add_argument('-t', '--tol', action='store', dest='tol', type=float, default=DEF_TOL, + help='tolerance for BG DP calibration') + parser.add_argument('-b', '--maxbads', action='store', dest='maxbads', type=int, default=DEF_MAXBADS, + help='number of bad sigmas to try before expanding the search range') + + # general settings + parser.add_argument('--construct', action='store_true', default=DEF_CONSTRUCT, + help='construct data and detstats for each varying param') + parser.add_argument('--detstats', action='store_true', default=DEF_DETSTATS, + help='construct detstats, using saved data') + parser.add_argument('--debug', action='store_true', default=False, + help='print steps along the way') + + # rarely need changing + parser.add_argument('--snr_cython', action='store_true', default=True, + help='Use cython for ss snr calculations') + parser.add_argument('--save_ssi', action='store_true', default=True, + help="Save 'gamma_ssi', the detprob of each single source.") + parser.add_argument('--clbrt', action='store_true', default=True, + help="Whether or not to calibrate the PTA for individual realizations.") + parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, + help="gamma-rho interpolation grid path") + parser.add_argument('--anatomy_path', action='store', dest ='anatomy_path', type=str, default=ANATOMY_PATH, + help="path to load and save anatomy files") + parser.add_argument('--load_file', action='store', dest ='load_file', type=str, default=None, + help="file to load sample data and params, excluding .npz suffice") + parser.add_argument('--save_file', action='store', dest ='save_file', type=str, default=None, + help="file to save sample data, excluding .npz suffix") + + args = parser.parse_args() + return args + +def run_model(sam, hard, nreals, nfreqs, nloudest=5, + pta_dur = DEF_PTA_DUR, + gwb_flag=True, details_flag=False, singles_flag=False, params_flag=False): + """Run the given modeling, storing requested data + """ + fobs_cents, fobs_edges = holo.utils.pta_freqs(pta_dur) + if nfreqs is not None: + fobs_edges = fobs_edges[:nfreqs+1] + fobs_cents = fobs_cents[:nfreqs] + fobs_orb_cents = fobs_cents / 2.0 # convert from GW to orbital frequencies + fobs_orb_edges = fobs_edges / 2.0 # convert from GW to orbital frequencies + + data = dict(fobs_cents=fobs_cents, fobs_edges=fobs_edges) + + redz_final, diff_num = sam_cyutils.dynamic_binary_number_at_fobs( + fobs_orb_cents, sam, hard, holo.cosmo + ) + use_redz = redz_final + edges = [sam.mtot, sam.mrat, sam.redz, fobs_orb_edges] + number = sam_cyutils.integrate_differential_number_3dx1d(edges, diff_num) + if details_flag: + data['static_binary_density'] = sam.static_binary_density + data['number'] = number + data['redz_final'] = redz_final + data['coalescing'] = (redz_final > 0.0) + + gwb_pars, num_pars, gwb_mtot_redz_final, num_mtot_redz_final = holo.librarian._calc_model_details(edges, redz_final, number) + + data['gwb_params'] = gwb_pars + data['num_params'] = num_pars + data['gwb_mtot_redz_final'] = gwb_mtot_redz_final + data['num_mtot_redz_final'] = num_mtot_redz_final + + # calculate single sources and/or binary parameters + if singles_flag or params_flag: + nloudest = nloudest if singles_flag else 1 + + vals = holo.single_sources.ss_gws_redz( + edges, use_redz, number, realize=nreals, + loudest=nloudest, params=params_flag, + ) + if params_flag: + hc_ss, hc_bg, sspar, bgpar = vals + data['sspar'] = sspar + data['bgpar'] = bgpar + else: + hc_ss, hc_bg = vals + + if singles_flag: + data['hc_ss'] = hc_ss + data['hc_bg'] = hc_bg + + if gwb_flag: + gwb = holo.gravwaves._gws_from_number_grid_integrated_redz(edges, use_redz, number, nreals) + data['gwb'] = gwb + + return data + +# # construct a param_space instance, note that `nsamples` and `seed` don't matter here for how we'll use this +# pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None) + +def vary_parameter( + target_param, # the name of the parameter, has to exist in `param_names` + params_list, # the values we'll check + nreals, nfreqs, nloudest, + pspace, + pars=None, debug=True, pta_dur=DEF_PTA_DUR, + ): + + # get the parameter names from this library-space + param_names = pspace.param_names + num_pars = len(pspace.param_names) + if debug: print(f"{num_pars=} :: {param_names=}") + + # choose each parameter to be half-way across the range provided by the library + if pars is None: + pars = 0.5 * np.ones(num_pars) + # Choose parameter to vary + param_idx = param_names.index(target_param) + + data = [] + params = [] + for ii, par in enumerate(tqdm(params_list)): + pars[param_idx] = par + if debug: print(f"{ii=}, {pars=}") + # _params = pspace.param_samples[0]*pars + _params = pspace.normalized_params(pars) + params.append(_params) + # construct `sam` and `hard` instances based on these parameters + sam, hard = pspace.model_for_params(_params, pspace.sam_shape) + # run this model, retrieving binary parameters and the GWB + _data = run_model(sam, hard, nreals, nfreqs, nloudest=nloudest, pta_dur=pta_dur, + gwb_flag=False, singles_flag=True, params_flag=True, details_flag=True) + data.append(_data) + + return (data, params) + + + +def main(): + start_time = datetime.now() + print("-----------------------------------------") + print(f"starting at {start_time}") + print("-----------------------------------------") + + # set up args + args = _setup_argparse() + print("NREALS = %d, NSKIES = %d, NPSRS = %d, target = %s, NVARS=%d" + % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) + + # set up output folder + output_path = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' + # check if output folder already exists, if not, make it. + if os.path.exists(output_path) is False: + os.makedirs(output_path) + + # set up load and save locations + if args.load_file is None: + load_data_from_file = output_path+'/data_params' + else: + load_data_from_file = args.load_file + + if args.save_file is None: + save_data_to_file = output_path+'/data_params' + else: + save_data_to_file = args.save_file + + save_dets_to_file = output_path+f'/detstats_s{args.nskies}' + if args.red2white is not None and args.red_gamma is not None: + save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' + elif args.red_amp is not None and args.red_gamma is not None: + save_dets_to_file = save_dets_to_file+f'_ra{args.red_amp:.1e}_rg{args.red_gamma:.1f}' + else: + save_dets_to_file = save_dets_to_file+f'_white' + + if args.red2white is not None and args.red_amp is not None: + print(f"{args.red2white=} and {args.red_amp} both provided. red_amp will be overriden by red2white ratio.") + + print(f"{load_data_from_file=}.npz") + print(f"{save_data_to_file=}.npz") + print(f"{save_dets_to_file=}.npz") + + + # calculate model and/or detstats + if args.construct or args.detstats: + if args.construct: + params_list = np.linspace(0,1,args.nvars) + data, params, = vary_parameter( + target_param=args.target, params_list=params_list, + nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, + pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=args.shape, seed=None), + pta_dur=args.pta_dur) + np.savez(save_data_to_file+'.npz', data=data, params=params) # save before calculating detstats, in case of crash + else: + file = np.load(load_data_from_file+'.npz', allow_pickle=True) + print('loaded files:', file.files) + data = file['data'] + params = file['params'] + file.close() + + fobs_cents = data[0]['fobs_cents'] + + # get dsdat for each data/param + dsdat = [] + for ii, _data in enumerate(tqdm(data)): + if args.debug: print(f"on var {ii=} out of {args.nvars}") + hc_bg = _data['hc_bg'] + hc_ss = _data['hc_ss'] + _dsdat = detstats.detect_pspace_model_clbrt_pta( + fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, + sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, + thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma, red2white=args.red2white) + dsdat.append(_dsdat) + np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs, red2white=args.red2white) # overwrite + else: + print(f"Neither {args.construct=} or {args.detstats} are true. Doing nothing.") + + end_time = datetime.now() + print("-----------------------------------------") + print(f"ending at {end_time}") + print(f"total time: {end_time - start_time}") + print("-----------------------------------------") + +if __name__ == "__main__": + main() + From 257a2b4dd7ba35a2bd350340292e7a81b0cceb3e Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 10 Jul 2023 11:11:34 -0500 Subject: [PATCH 250/291] Update custom model pta calibration. --- ...t_model_clbrt_100yr.py => detect_custom_model.py} | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) rename ecg-notebooks/parameter_investigation/{detect_model_clbrt_100yr.py => detect_custom_model.py} (96%) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py b/ecg-notebooks/parameter_investigation/detect_custom_model.py similarity index 96% rename from ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py rename to ecg-notebooks/parameter_investigation/detect_custom_model.py index c7f51ce8..ca98f62b 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_100yr.py +++ b/ecg-notebooks/parameter_investigation/detect_custom_model.py @@ -28,7 +28,7 @@ DEF_TOL = 0.01 DEF_MAXBADS = 5 GAMMA_RHO_GRID_PATH = '/Users/emigardiner/GWs/holodeck/output/rho_gamma_grids' # modify for system -ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' +ANATOMY_PATH = '/Users/emigardiner/GWs/holodeck/output/anatomy' # settings to vary DEF_CONSTRUCT = False @@ -39,10 +39,13 @@ def _setup_argparse(): parser = argparse.ArgumentParser() parser.add_argument('target', action='store', type=str, help="target parameter to vary") + parser.add_argument('param_space', type=str, + help="Parameter space class name, found in 'holodeck.param_spaces'.") # parser.add_argument('--grid_path', action='store', dest ='grid_path', type=str, default=GAMMA_RHO_GRID_PATH, # help="gamma-rho interpolation grid path") # sample models setup + parser.add_argument('-f', '--nfreqs', action='store', dest='nfreqs', type=int, default=DEF_NFREQS, help='number of frequency bins') parser.add_argument('-r', '--nreals', action='store', dest='nreals', type=int, default=DEF_NREALS, @@ -111,6 +114,7 @@ def _setup_argparse(): args = parser.parse_args() return args + def run_model(sam, hard, nreals, nfreqs, nloudest=5, pta_dur = DEF_PTA_DUR, gwb_flag=True, details_flag=False, singles_flag=False, params_flag=False): @@ -222,7 +226,7 @@ def main(): % (args.nreals, args.nskies, args.npsrs, args.target, args.nvars)) # set up output folder - output_path = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' + output_path = args.anatomy_path+f'/{args.param_space}_{args.target}_v{args.nvars}_r{args.nreals}_d{args.pta_dur}' # check if output folder already exists, if not, make it. if os.path.exists(output_path) is False: os.makedirs(output_path) @@ -254,6 +258,8 @@ def main(): print(f"{save_dets_to_file=}.npz") + space_class = getattr(holo.param_spaces, args.param_space) + # calculate model and/or detstats if args.construct or args.detstats: if args.construct: @@ -261,7 +267,7 @@ def main(): data, params, = vary_parameter( target_param=args.target, params_list=params_list, nfreqs=args.nfreqs, nreals=args.nreals, nloudest=args.nloudest, - pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=args.shape, seed=None), + pspace = space_class(holo.log, nsamples=1, sam_shape=args.shape, seed=None), pta_dur=args.pta_dur) np.savez(save_data_to_file+'.npz', data=data, params=params) # save before calculating detstats, in case of crash else: From c34c609d692ac6b3caefe75b65eaf8264bae41cf Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 10 Jul 2023 12:09:36 -0500 Subject: [PATCH 251/291] Edit for longer duration. --- .../parameter_investigation/tk15_dp_ssi.ipynb | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb index d1ea00be..3c99df76 100644 --- a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb +++ b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb @@ -32,21 +32,22 @@ "outputs": [], "source": [ "SHAPE = None\n", - "NREALS = 500\n", - "NFREQS = 40\n", + "NREALS = 100\n", "NLOUDEST = 10\n", + "PARAM_SPACE = 'PS_Uniform_07_GW'\n", + "PTA_DUR = 100\n", "\n", "CONSTRUCT = False\n", "JUST_DETSTATS = False\n", - "SAVEFIG = True\n", + "SAVEFIG = False\n", "TOL=0.01\n", "MAXBADS=5\n", "\n", - "NVARS = 21\n", + "NVARS = 6\n", "\n", "NPSRS = 40\n", "NSKIES = 100\n", - "TARGET = 'hard_time' # EDIT AS NEEDED\n", + "TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", "\n", "\n", @@ -60,16 +61,16 @@ "metadata": {}, "outputs": [], "source": [ - "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B'\n", - "load_data_from_file = path+f'/{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz' \n", + "path = f'/Users/emigardiner/GWs/holodeck/output/anatomy/{PARAM_SPACE}_{TARGET}_v{NVARS}_r{NREALS}_d{PTA_DUR}'\n", + "load_data_from_file = path+f'/data_params.npz' \n", + "load_dets_from_file = path+f'/detstats_s{NSKIES}'\n", + "\n", + "load_dets_from_file += '.npz'\n", + "\n", "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", "\n", - "if CONSTRUCT is False:\n", - " import os\n", - " if os.path.exists(load_data_from_file) is False:\n", - " err = 'load data file does not exist, you need to construct it.'\n", - " raise Exception(err)\n", - "print(load_data_from_file)\n", + "err = 'load data file does not exist, you need to construct it.'\n", + "raise Exception(err)\n", "# print(save_data_to_file)" ] }, From 47b9908ff0f2462b1a1c7c51f81ea16bfb22dcb6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 10 Jul 2023 13:32:18 -0500 Subject: [PATCH 252/291] Plot dp_ssi vs freq for GW only. Try with GW only for 100 years but all the same. --- .../parameter_investigation/tk15_dp_ssi.ipynb | 106 +++++++----------- 1 file changed, 38 insertions(+), 68 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb index 3c99df76..3c6d85a0 100644 --- a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb +++ b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb @@ -15,6 +15,7 @@ "import matplotlib.cm as cm\n", "import h5py\n", "import matplotlib as mpl\n", + "import os\n", "\n", "\n", "from holodeck import plot, detstats\n", @@ -32,7 +33,7 @@ "outputs": [], "source": [ "SHAPE = None\n", - "NREALS = 100\n", + "NREALS = 50\n", "NLOUDEST = 10\n", "PARAM_SPACE = 'PS_Uniform_07_GW'\n", "PTA_DUR = 100\n", @@ -44,9 +45,11 @@ "MAXBADS=5\n", "\n", "NVARS = 6\n", + "RED2WHITE = None\n", + "RED_GAMMA = None\n", "\n", "NPSRS = 40\n", - "NSKIES = 100\n", + "NSKIES =25\n", "TARGET = 'gsmf_phi0' # EDIT AS NEEDED\n", "TITLE = '$\\\\tau_\\mathrm{hard}$' # EDIT AS NEEDED\n", "\n", @@ -61,17 +64,26 @@ "metadata": {}, "outputs": [], "source": [ - "path = f'/Users/emigardiner/GWs/holodeck/output/anatomy/{PARAM_SPACE}_{TARGET}_v{NVARS}_r{NREALS}_d{PTA_DUR}'\n", + "path = f'/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/{TARGET}_v{NVARS}_r{NREALS}_shapeNone'\n", + "\n", + "# path = f'/Users/emigardiner/GWs/holodeck/output/anatomy/{PARAM_SPACE}_{TARGET}_v{NVARS}_r{NREALS}_d{PTA_DUR}'\n", "load_data_from_file = path+f'/data_params.npz' \n", "load_dets_from_file = path+f'/detstats_s{NSKIES}'\n", - "\n", - "load_dets_from_file += '.npz'\n", + "if RED2WHITE is not None and RED_GAMMA is not None:\n", + " load_dets_from_file += f'_r2w{RED2WHITE:>.2f}_rg{RED_GAMMA:.2e}'\n", + "else:\n", + " load_dets_from_file += '_white.npz'\n", "\n", "# save_data_to_file = path+f'/{TARGET}_v{NVARS}vars_clbrt_pta.npz' \n", - "\n", - "err = 'load data file does not exist, you need to construct it.'\n", - "raise Exception(err)\n", - "# print(save_data_to_file)" + "# load_data_from_file='/Users/emigardiner/GWs/holodeck/output/anatomy/PS_Uniform_07_GW_gsmf_phi0_v6_r100_d100/data_params.npz'\n", + "if os.path.exists(load_data_from_file) is False:\n", + " print(load_data_from_file)\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)\n", + "if os.path.exists(load_dets_from_file) is False:\n", + " print(load_dets_from_file)\n", + " err = 'load data file does not exist, you need to construct it.'\n", + " raise Exception(err)" ] }, { @@ -92,6 +104,9 @@ "print(file.files)\n", "data = file['data']\n", "params = file['params']\n", + "file.close()\n", + "\n", + "file = np.load(load_dets_from_file, allow_pickle=True)\n", "dsdat = file['dsdat']\n", "file.close()\n" ] @@ -110,8 +125,9 @@ "metadata": {}, "outputs": [], "source": [ - "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", - "param_names = pspace.param_names" + "# pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "# param_names = pspace.param_names\n", + "# print(param_names)" ] }, { @@ -120,9 +136,9 @@ "metadata": {}, "outputs": [], "source": [ - "dat = data[0]\n", - "gamma_ssi = dsdat[0]['gamma_ssi'] # F,R,S,L\n", - "fobs_cents = data[0]['fobs_cents'] # F" + "fobs_cents = data[3]['fobs_cents'] # F\n", + "NFREQS = len(fobs_cents)\n", + "print(NFREQS)" ] }, { @@ -167,7 +183,7 @@ "metadata": {}, "outputs": [], "source": [ - "param_names.index(TARGET)" + "print(holo.utils.stats(dsdat[5]['dp_ss']))" ] }, { @@ -175,43 +191,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "print(params[0])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "xlabel = plot.LABEL_GW_FREQUENCY_YR\n", - "ylabel = 'Detection Probability, $\\gamma_\\mathrm{ss,i}$'\n", - "\n", - "fig, ax = plot.figax(xlabel=xlabel, ylabel=ylabel)\n", - "colors = cm.rainbow(np.linspace(0,1,NVARS))\n", - "alpha=0.1\n", - "\n", - "# tt = param_names.index(TARGET)\n", - "\n", - "handles = []\n", - "labels = []\n", - "for ii, dat in enumerate(data):\n", - " if ii%2==0:\n", - " print(ii)\n", - " xx = fobs_cents # F, #np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", - " yy = dsdat[ii]['gamma_ssi'][...,0] # (F,S,R)\n", - " yy = yy.reshape(NFREQS, NSKIES * NREALS)\n", - " hh = plot.draw_med_conf_color(ax, xx, yy, color=colors[ii],)\n", - " handles.append(hh)\n", - " labels.append(f\"{params[ii][TARGET]:.2f}\")\n", - " # ax.scatter(xx[:,:,:,0], yy[:,:,:,0], color=colors[ii], edgecolor='k', alpha=0.1)\n", - " # ax.scatter(xx[:,:,:,1:], yy[:,:,:,1:], color=colors[ii], alpha=0.1)\n", - "\n", - "ax.legend(handles=handles, labels=labels, title=TARGET)\n", - "fig.savefig('/Users/emigardiner/GWs/holodeck/output/figures/anatomy_09B'\n", - " +f'/dp_vs_freq_{TARGET}_r{NREALS}_s{NSKIES}.png')" - ] + "source": [] }, { "cell_type": "code", @@ -231,29 +211,19 @@ "handles = []\n", "labels = []\n", "for ii, dat in enumerate(data):\n", - " if ii%2==0:\n", + " if ii%3==0:\n", " print(ii)\n", - " xx = fobs_cents # F, #np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", - " yy = dsdat[ii]['gamma_ssi'][...,0] # (F,S,R)\n", - " # yy = yy.reshape(NFREQS, NSKIES * NREALS)\n", - " yy = yy[:,0,:]\n", + " xx = fobs_cents #np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS*NSKIES*NLOUDEST)\n", + " yy = dsdat[ii]['gamma_ssi'][...] # (F,S,R)\n", + " print(f\"{xx.shape=}, {yy.shape=}\")\n", + " yy = yy.reshape(NFREQS, NSKIES * NREALS * NLOUDEST)\n", " hh = plot.draw_med_conf_color(ax, xx, yy, color=colors[ii],)\n", " handles.append(hh)\n", " labels.append(f\"{params[ii][TARGET]:.2f}\")\n", " # ax.scatter(xx[:,:,:,0], yy[:,:,:,0], color=colors[ii], edgecolor='k', alpha=0.1)\n", " # ax.scatter(xx[:,:,:,1:], yy[:,:,:,1:], color=colors[ii], alpha=0.1)\n", "\n", - "ax.legend(handles=handles, labels=labels, title=TARGET)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "arr = np.array([[1,2],[3,4]], [[5,5],[5,5,]], [[6,6],[6,6]])\n", - "print(arr.shape)" + "ax.legend(handles=handles, labels=labels, title=TARGET)\n" ] }, { From 89d7649783aa187da175369a1d7c44e218fac95e Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 10 Jul 2023 23:25:23 -0500 Subject: [PATCH 253/291] Plot GW only ratio vs var. --- .../paper_plots/ratio_varpar_GWonly.ipynb | 346 ++++++++++++++++++ .../parameter_investigation/tk15_dp_ssi.ipynb | 11 + 2 files changed, 357 insertions(+) create mode 100644 ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb diff --git a/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb b/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb new file mode 100644 index 00000000..ac964530 --- /dev/null +++ b/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb @@ -0,0 +1,346 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "from tqdm import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Set up" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = True\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# NSKIES = 15" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get param names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_07_GW(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get data and dets file functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' \n", + "):\n", + " # if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_redz':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", + " # else:\n", + " # load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " # load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat\n", + "\n", + "def get_ratio_arrays(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata', red=False, \n", + " ):\n", + " filename = path+f'/ratio_arrays_{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz'\n", + " file = np.load(filename)\n", + " xx = file['xx_params']\n", + " y0p0 = file['yy_ratio']\n", + " if red:\n", + " y1p5 = file['y1p5_ratio']\n", + " y3p0 = file['y3p0_ratio']\n", + " if red:\n", + " return xx, y0p0, y1p5, y3p0\n", + " else:\n", + " return xx, y0p0" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if BUILD_ARRAYS:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', ]\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", + " for target in tqdm(targets):\n", + " print(target)\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target)\n", + " xx=[]\n", + " yy=[]\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + "\n", + " # # red_gamma = -1.5\n", + " # data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " # y1p5=[]\n", + " # for pp, par in enumerate(params):\n", + " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " # dp_ss = dsdat[pp]['ev_ss']\n", + " # y1p5.append(dp_ss/dp_bg)\n", + "\n", + " # # red_gamma = -3.0\n", + " # data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + " # y3p0=[]\n", + " # for pp, par in enumerate(params):\n", + " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " # dp_ss = dsdat[pp]['ev_ss']\n", + " # y3p0.append(dp_ss/dp_bg)\n", + "\n", + " \n", + " np.savez(path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", + " xx_params = xx, yy_ratio = yy, \n", + " ) #y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/mmb_scatter_dex_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-3.0.npz')\n", + "# print(file.files)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10',\n", + " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", + " ]\n", + "col0p0 = [\n", + " '#336948', '#336948',\n", + " '#9e5c41', '#9e5c41',\n", + "]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', \n", + "# '#4da169', '#e67739', \n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', \n", + "# '#8fcf91', '#fda363', \n", + "# ]\n", + "\n", + "fig, axs = plot.figax_single(nrows=2, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + " height=5)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 2:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", + "\n", + " # xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.32)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_GWvar{NVARS}_wn_pp5095.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', \n", + " ]\n", + "col0p0 = [\n", + " '#336948', '#9e5c41', \n", + " '#336948', '#9e5c41', \n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#e67739', \n", + " '#4da169', '#e67739', \n", + "]\n", + "col3p0 = [\n", + " '#8fcf91', '#fda363', \n", + " '#8fcf91', '#fda363', \n", + "]\n", + "\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " col=col0p0[ii]\n", + " # for pp in [50, 95]:\n", + " for pp in [68]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " savename = savename+f'/ratio_vs_GWvar{NVARS}_r2w_pp50_redzfixed.png'\n", + " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", + " fig.savefig(savename, dpi=100)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb index 3c6d85a0..82e3e55a 100644 --- a/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb +++ b/ecg-notebooks/parameter_investigation/tk15_dp_ssi.ipynb @@ -226,6 +226,17 @@ "ax.legend(handles=handles, labels=labels, title=TARGET)\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax()\n", + "\n", + "ax.set_title('Title in big text for $\\large{\\\\tau}$ or normal size $\\\\tau$')" + ] + }, { "cell_type": "code", "execution_count": null, From a23e8afa5a513973dd0f98288318d10f68baec80 Mon Sep 17 00:00:00 2001 From: Emiko Date: Tue, 11 Jul 2023 15:30:34 -0500 Subject: [PATCH 254/291] Plot ratio vs varpar with gws. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 282 +++++++----------- .../paper_plots/ratio_varpar_GWonly.ipynb | 99 +++--- 2 files changed, 160 insertions(+), 221 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 871a69b3..8795cc79 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -47,7 +47,7 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "BUILD_ARRAYS = True\n", + "BUILD_ARRAYS = False\n", "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", @@ -120,6 +120,7 @@ " file.close()\n", "\n", " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " print(file.files)\n", " dsdat = file['dsdat']\n", " file.close()\n", "\n", @@ -127,15 +128,21 @@ "\n", "def get_ratio_arrays(\n", " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata',\n", + " red=True, \n", " ):\n", - " filename = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ratio_arrays.npz'\n", + " filename = path+f'/ratio_arrays_{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz'\n", " file = np.load(filename)\n", " xx = file['xx_params']\n", " y0p0 = file['yy_ratio']\n", - " y1p5 = file['y1p5_ratio']\n", - " y3p0 = file['y3p0_ratio']\n", - " return xx, y0p0, y1p5, y3p0" + " if red:\n", + " y1p5 = file['y1p5_ratio']\n", + " y3p0 = file['y3p0_ratio']\n", + " file.close()\n", + " if red:\n", + " return xx, y0p0, y3p0, #y1p5, y3p0\n", + " else:\n", + " return xx, y0p0, " ] }, { @@ -144,10 +151,13 @@ "metadata": {}, "outputs": [], "source": [ - "if BUILD_ARRAYS:\n", + "if True:\n", + "# if BUILD_ARRAYS:\n", + " # targets = [\n", + " # 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " # 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", " targets = [\n", - " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", - " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + " 'mmb_scatter_dex']\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " for target in tqdm(targets):\n", " print(target)\n", @@ -162,13 +172,13 @@ " dp_ss = dsdat[pp]['ev_ss']\n", " yy.append(dp_ss/dp_bg)\n", "\n", - " # red_gamma = -1.5\n", - " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", - " y1p5=[]\n", - " for pp, par in enumerate(params):\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " y1p5.append(dp_ss/dp_bg)\n", + " # # red_gamma = -1.5\n", + " # data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " # y1p5=[]\n", + " # for pp, par in enumerate(params):\n", + " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " # dp_ss = dsdat[pp]['ev_ss']\n", + " # y1p5.append(dp_ss/dp_bg)\n", "\n", " # red_gamma = -3.0\n", " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", @@ -180,62 +190,8 @@ "\n", " \n", " np.savez(path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", - " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/mmb_scatter_dex_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-3.0.npz')\n", - "print(file.files)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# if BUILD_ARRAYS:\n", - "# targets = [\n", - "# 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", - "# 'gsmf_mchar0_log10', 'mmb_scatter_dex']#, 'hard_gamma_inner']\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B' \n", - "# for target in targets:\n", - "# print(target)\n", - "\n", - "# # white noise only\n", - "# data, params, dsdat = get_data(target,)\n", - "# xx=[]\n", - "# yy=[]\n", - "# for pp, par in enumerate(params):\n", - "# xx.append(params[pp][target])\n", - "# dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - "# dp_ss = dsdat[pp]['ev_ss']\n", - "# yy.append(dp_ss/dp_bg)\n", - "\n", - "# # red_gamma = -1.5\n", - "# data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", - "# y1p5=[]\n", - "# for pp, par in enumerate(params):\n", - "# dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - "# dp_ss = dsdat[pp]['ev_ss']\n", - "# y1p5.append(dp_ss/dp_bg)\n", - "\n", - "# # red_gamma = -3.0\n", - "# data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", - "# y3p0=[]\n", - "# for pp, par in enumerate(params):\n", - "# dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - "# dp_ss = dsdat[pp]['ev_ss']\n", - "# y3p0.append(dp_ss/dp_bg)\n", - "\n", - " \n", - "# np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", - "# xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" + " # xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)\n", + " xx_params = xx, yy_ratio = yy, y3p0_ratio=y3p0)" ] }, { @@ -293,11 +249,18 @@ "\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50_redzfixed.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50.png'\n", " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# White noise only" + ] + }, { "cell_type": "code", "execution_count": null, @@ -326,7 +289,7 @@ " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " if ii == 0 or ii == 3:\n", " ax.set_ylabel(ylabel)\n", - " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", " col=col0p0[ii]\n", " for pp in [50, 95]:\n", " # for pp in [50]: \n", @@ -352,16 +315,15 @@ "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095_redzfixed.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] }, { - "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ - "# Using 50 skies" + "# White noise with GW-Only" ] }, { @@ -370,114 +332,84 @@ "metadata": {}, "outputs": [], "source": [ - "SHAPE = None\n", - "NREALS = 500\n", - "# NREALS = 20\n", - "NFREQS = 40\n", - "NLOUDEST = 10\n", - "\n", - "BUILD_ARRAYS = True\n", - "SAVEFIG = False\n", - "TOL=0.01\n", - "MAXBADS=5\n", - "\n", - "NVARS = 21\n", - "# NVARS = 6\n", - "\n", - "NPSRS = 40\n", - "NSKIES = 50\n", - "# NSKIES = 15" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "if True:\n", - " targets = [\n", - " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", - " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", - " for target in ['hard_time']:\n", - " print(target)\n", - "\n", - " # white noise only\n", - " data, params, dsdat = get_data(target, path=path, nskies=50,)\n", - " xx=[]\n", - " yy=[]\n", - " for pp, par in enumerate(params):\n", - " xx.append(params[pp][target])\n", - " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " dp_ss = dsdat[pp]['ev_ss']\n", - " yy.append(dp_ss/dp_bg)\n", - "\n", - " # # red_gamma = -1.5\n", - " # data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", - " # y1p5=[]\n", - " # for pp, par in enumerate(params):\n", - " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " # dp_ss = dsdat[pp]['ev_ss']\n", - " # y1p5.append(dp_ss/dp_bg)\n", - "\n", - " # # red_gamma = -3.0\n", - " # data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", - " # y3p0=[]\n", - " # for pp, par in enumerate(params):\n", - " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " # dp_ss = dsdat[pp]['ev_ss']\n", - " # y3p0.append(dp_ss/dp_bg)\n", + "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# ]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", "\n", - " \n", - " # np.savez(path+f'/{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}_ratio_arrays.npz', \n", - " # xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "xx_hardtime = xx\n", - "yy_hardtime = yy" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", "for ii, ax in enumerate(axs.flatten()):\n", - " if ii != 2:\n", - " continue\n", " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " if ii == 0 or ii == 3:\n", " ax.set_ylabel(ylabel)\n", - " # xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", + "\n", " col=col0p0[ii]\n", " for pp in [50, 95]:\n", " # for pp in [50]: \n", - " med, *conf = np.percentile(yy_hardtime, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", - " ax.fill_between(xx_hardtime, *conf, color=col0p0[ii], alpha=0.25)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "file = np.load('/Users/emigardiner/GWs/holodeck/output/anatomy_redz/hard_time_21vars_clbrt_pta.npz',\n", - " allow_pickle=True)\n", - "print(file.files)\n", - "print(len(file['data']))\n", - "hc_bg = file['data'][0]['hc_bg']\n", - "print(hc_bg.shape)" + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if ii%3 != 2:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + " \n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_gw.png'\n", + " fig.savefig(savename, dpi=100)" ] }, { diff --git a/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb b/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb index ac964530..20151eaf 100644 --- a/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb +++ b/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb @@ -266,60 +266,67 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", - "targets = [\n", - " 'gsmf_phi0', 'mmb_mamp_log10', \n", - " 'gsmf_mchar0_log10', 'mmb_scatter_dex', \n", - " ]\n", - "col0p0 = [\n", - " '#336948', '#9e5c41', \n", - " '#336948', '#9e5c41', \n", - "]\n", - "col1p5 = [\n", - " '#4da169', '#e67739', \n", - " '#4da169', '#e67739', \n", - "]\n", - "col3p0 = [\n", - " '#8fcf91', '#fda363', \n", - " '#8fcf91', '#fda363', \n", - "]\n", + "# ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "# targets = [\n", + "# 'gsmf_phi0', 'mmb_mamp_log10', \n", + "# 'gsmf_mchar0_log10', 'mmb_scatter_dex', \n", + "# ]\n", + "# col0p0 = [\n", + "# '#336948', '#9e5c41', \n", + "# '#336948', '#9e5c41', \n", + "# ]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', \n", + "# '#4da169', '#e67739', \n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', \n", + "# '#8fcf91', '#fda363', \n", + "# ]\n", "\n", - "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", - "for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", - " if ii == 0 or ii == 3:\n", - " ax.set_ylabel(ylabel)\n", - " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", - " col=col0p0[ii]\n", - " # for pp in [50, 95]:\n", - " for pp in [68]: \n", - " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", - " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "# fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "# for ii, ax in enumerate(axs.flatten()):\n", + "# ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + "# if ii == 0 or ii == 3:\n", + "# ax.set_ylabel(ylabel)\n", + "# xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + "# col=col0p0[ii]\n", + "# # for pp in [50, 95]:\n", + "# for pp in [68]: \n", + "# med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + "# ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", "\n", - " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", - " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "# med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + "# ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", "\n", - " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", - " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "# med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + "# ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", "\n", - "handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", - " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", - " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", - "axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", "\n", - "plt.subplots_adjust(wspace=0)\n", + "# plt.subplots_adjust(wspace=0)\n", "\n", - "# fig.tight_layout()\n", + "# # fig.tight_layout()\n", "\n", - "if SAVEFIG:\n", - " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " savename = savename+f'/ratio_vs_GWvar{NVARS}_r2w_pp50_redzfixed.png'\n", - " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", - " fig.savefig(savename, dpi=100)" + "# if SAVEFIG:\n", + "# savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "# savename = savename+f'/ratio_vs_GWvar{NVARS}_r2w_pp50_redzfixed.png'\n", + "# # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", + "# fig.savefig(savename, dpi=100)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From e592cff42835b2dc33a990f0c5f0d871842cbe2e Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 12 Jul 2023 09:01:51 -0500 Subject: [PATCH 255/291] Add SHOW_GW option to ratio plots. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 155 ++++++------------ 1 file changed, 46 insertions(+), 109 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 8795cc79..78970386 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -57,7 +57,9 @@ "\n", "NPSRS = 40\n", "NSKIES = 100\n", - "# NSKIES = 15" + "# NSKIES = 15\n", + "\n", + "SHOW_GW=True" ] }, { @@ -140,7 +142,7 @@ " y3p0 = file['y3p0_ratio']\n", " file.close()\n", " if red:\n", - " return xx, y0p0, y3p0, #y1p5, y3p0\n", + " return xx, y0p0, y1p5, y3p0, #y1p5, y3p0\n", " else:\n", " return xx, y0p0, " ] @@ -151,14 +153,15 @@ "metadata": {}, "outputs": [], "source": [ - "if True:\n", - "# if BUILD_ARRAYS:\n", + "# if True:\n", + "if BUILD_ARRAYS:\n", " # targets = [\n", " # 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " # 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " targets = [\n", " 'mmb_scatter_dex']\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " # path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", " for target in tqdm(targets):\n", " print(target)\n", "\n", @@ -172,13 +175,13 @@ " dp_ss = dsdat[pp]['ev_ss']\n", " yy.append(dp_ss/dp_bg)\n", "\n", - " # # red_gamma = -1.5\n", - " # data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", - " # y1p5=[]\n", - " # for pp, par in enumerate(params):\n", - " # dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", - " # dp_ss = dsdat[pp]['ev_ss']\n", - " # y1p5.append(dp_ss/dp_bg)\n", + " # red_gamma = -1.5\n", + " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " y1p5=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y1p5.append(dp_ss/dp_bg)\n", "\n", " # red_gamma = -3.0\n", " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", @@ -190,8 +193,15 @@ "\n", " \n", " np.savez(path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", - " # xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)\n", - " xx_params = xx, yy_ratio = yy, y3p0_ratio=y3p0)" + " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)\n", + " # xx_params = xx, yy_ratio = yy, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Red Noise" ] }, { @@ -222,20 +232,22 @@ " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " if ii == 0 or ii == 3:\n", " ax.set_ylabel(ylabel)\n", - " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii])\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=True,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", " col=col0p0[ii]\n", " # for pp in [50, 95]:\n", " for pp in [68]: \n", " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii], linestyle='-')\n", " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", "\n", " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", "\n", " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", "\n", "handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", @@ -249,7 +261,10 @@ "\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50.png'\n", + " if SHOW_GW:\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50.png'\n", + " else:\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_gw.png'\n", " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] @@ -284,70 +299,6 @@ " '#8fcf91', '#fda363', '#38cbff',\n", "]\n", "\n", - "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", - "for ii, ax in enumerate(axs.flatten()):\n", - " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", - " if ii == 0 or ii == 3:\n", - " ax.set_ylabel(ylabel)\n", - " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", - " col=col0p0[ii]\n", - " for pp in [50, 95]:\n", - " # for pp in [50]: \n", - " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", - " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", - "\n", - " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", - " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", - "\n", - " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", - " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", - "\n", - "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", - "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", - "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", - "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", - "plt.subplots_adjust(wspace=0)\n", - "# fig.tight_layout()\n", - "\n", - "if SAVEFIG:\n", - " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095.png'\n", - " fig.savefig(savename, dpi=100)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# White noise with GW-Only" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", - "targets = [\n", - " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", - " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", - "col0p0 = [\n", - " '#336948', '#9e5c41', '#2d839f',\n", - " '#336948', '#9e5c41', '#2d839f',\n", - "]\n", - "# col1p5 = [\n", - "# '#4da169', '#e67739', '#35b6e0',\n", - "# '#4da169', '#e67739', '#35b6e0',\n", - "# ]\n", - "# col3p0 = [\n", - "# '#8fcf91', '#fda363', '#38cbff',\n", - "# '#8fcf91', '#fda363', '#38cbff',\n", - "# ]\n", "col_gw = [\n", " 'k', 'k', 'k',\n", " 'k', 'k', 'k'\n", @@ -359,36 +310,20 @@ " if ii == 0 or ii == 3:\n", " ax.set_ylabel(ylabel)\n", " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", - "\n", " col=col0p0[ii]\n", " for pp in [50, 95]:\n", " # for pp in [50]: \n", " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", - "\n", - " if ii%3 != 2:\n", - " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", - " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", - " for pp in [50]:\n", - " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", - " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", - " print(f\"{ii=}, {yy_gw.shape}\")\n", - " else:\n", - " xx_gw = xx\n", - " yy_gw = yy_gw[int(NVARS/2)]\n", - " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", - " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", - " print(f\"{ii=}, {yy_gw.shape}\")\n", - "\n", - " for pp in [50]:\n", - " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", - " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", - " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", - " print(f\"{ii=}, yy_gw.shape\")\n", - "\n", - " \n", + " if SHOW_GW:\n", + " if ii%3 != 2:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", "\n", " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", @@ -407,8 +342,10 @@ "\n", "if SAVEFIG:\n", " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", - " savename = savename+f'/ratio_vs_var{NVARS}_wn_gw.png'\n", + " if SHOW_GW:\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_gw.png'\n", + " else:\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_pp5095.png'\n", " fig.savefig(savename, dpi=100)" ] }, From 42f799d47e6ea16ce33b757b78c0c5cfa74730b2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 14 Jul 2023 17:51:45 -0500 Subject: [PATCH 256/291] Plot ratio vs varpar for single column and GW only red noise. --- .../paper_plots/ratio_and_hc_varpar.ipynb | 529 +++++++++++++++++- 1 file changed, 509 insertions(+), 20 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb index 78970386..1998b658 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb @@ -88,6 +88,18 @@ "Get data and dets file functions" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/mmb_mamp_log10_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-1.5.npz'\n", + "file = np.load(filename, allow_pickle=True)\n", + "print(file.files)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -98,12 +110,9 @@ " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", - " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_redz':\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", - " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", - " else:\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", - " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", + "\n", " if red_gamma is not None and red2white is not None:\n", " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", " else:\n", @@ -120,8 +129,9 @@ " data = file['data']\n", " params = file['params']\n", " file.close()\n", - "\n", + " print(target, \"got data\")\n", " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " print(target, \"loaded dets\")\n", " print(file.files)\n", " dsdat = file['dsdat']\n", " file.close()\n", @@ -129,12 +139,13 @@ " return data, params, dsdat\n", "\n", "def get_ratio_arrays(\n", - " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE,\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, debug=False,\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata',\n", " red=True, \n", " ):\n", " filename = path+f'/ratio_arrays_{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz'\n", " file = np.load(filename)\n", + " if debug: print(f\"{filename}\\n{file.files}\")\n", " xx = file['xx_params']\n", " y0p0 = file['yy_ratio']\n", " if red:\n", @@ -153,20 +164,38 @@ "metadata": {}, "outputs": [], "source": [ - "# if True:\n", - "if BUILD_ARRAYS:\n", + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata'\n", + "for target in ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex']:\n", + " filename = path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " file = np.load(filename)\n", + " print(f\"{filename}\\n{file.files}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if True:\n", + "# if BUILD_ARRAYS:\n", " # targets = [\n", " # 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " # 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " # path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " targets = [\n", - " 'mmb_scatter_dex']\n", - " # path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", + " # 'gsmf_phi0',\n", + " # 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', \n", + " # 'mmb_scatter_dex',\n", + " ]\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' \n", + " figpath = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", " for target in tqdm(targets):\n", " print(target)\n", "\n", " # white noise only\n", - " data, params, dsdat = get_data(target)\n", + " data, params, dsdat = get_data(target, path=path)\n", " xx=[]\n", " yy=[]\n", " for pp, par in enumerate(params):\n", @@ -176,7 +205,7 @@ " yy.append(dp_ss/dp_bg)\n", "\n", " # red_gamma = -1.5\n", - " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1)\n", + " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1.0, path=path)\n", " y1p5=[]\n", " for pp, par in enumerate(params):\n", " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", @@ -184,7 +213,7 @@ " y1p5.append(dp_ss/dp_bg)\n", "\n", " # red_gamma = -3.0\n", - " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1)\n", + " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1, path=path)\n", " y3p0=[]\n", " for pp, par in enumerate(params):\n", " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", @@ -192,11 +221,22 @@ " y3p0.append(dp_ss/dp_bg)\n", "\n", " \n", - " np.savez(path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", + " np.savez(figpath+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)\n", " # xx_params = xx, yy_ratio = yy, y3p0_ratio=y3p0)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/mmb_mamp_log10_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-3.0.npz'\n", + "file = np.load(filename)\n", + "print(file.files)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -227,14 +267,27 @@ " '#8fcf91', '#fda363', '#38cbff',\n", "]\n", "\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", "for ii, ax in enumerate(axs.flatten()):\n", " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " if ii == 0 or ii == 3:\n", " ax.set_ylabel(ylabel)\n", " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", - " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=True,\n", - " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " if SHOW_GW:\n", + " if ii%3 != 2:\n", + " xx_gw, yy_gw, y1p5_gw, y3p3_gw = get_ratio_arrays(targets[ii], red=True,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " \n", " col=col0p0[ii]\n", " # for pp in [50, 95]:\n", " for pp in [68]: \n", @@ -242,18 +295,31 @@ " ax.plot(xx, med, alpha=0.9, color=col0p0[ii], linestyle='-')\n", " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle=':')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + "\n", "handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", - "axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", "\n", "plt.subplots_adjust(wspace=0)\n", "\n", @@ -324,6 +390,15 @@ " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", "\n", " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", @@ -349,6 +424,420 @@ " fig.savefig(savename, dpi=100)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# White noise with GW-Only" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# ]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", + "\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if ii%3 != 2:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + " \n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_gw.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# ]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii ==2:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", + "\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if ii<4:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + " \n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_gw_single.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#4da169',\n", + " '#e67739', '#e67739',\n", + " '#35b6e0', '#35b6e0',\n", + " \n", + "]\n", + "col3p0 = [\n", + " '#8fcf91', '#8fcf91',\n", + " '#fda363', '#fda363',\n", + " '#38cbff', '#38cbff',\n", + "]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "SHOW_GW = True\n", + "SHOW_REDLINES = True\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii ==2:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", + " \n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if ii<4 and SHOW_GW:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + " elif SHOW_GW:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " # print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + " # print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + " if SHOW_REDLINES:\n", + " for pp in [50,]:\n", + " # Red Noise Models\n", + " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + " \n", + " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "\n", + " if SHOW_GW:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle=':')\n", + " \n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='0.0', color = col0p0[0], linestyle='-'),\n", + "# mpl.lines.Line2D([0], [0], label='-1.5', color = col1p5[0], linestyle='--'),\n", + "# mpl.lines.Line2D([0], [0], label='-3.0', color = col3p0[0], linestyle=':')]\n", + "# leg = fig.legend(handles=handles, bbox_to_anchor=(0.5,0.05), loc = 'center',\n", + "# title='$\\gamma_\\mathrm{RN}$', ncols=4, \n", + "# fontsize=10, title_fontsize=12, handletextpad=0.1, labelspacing=0.2)\n", + "# leg.get_title().set_position((-50,-10))\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_gw_single_rnlines.png'\n", + " fig.savefig(savename, dpi=100, bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Red Noise, GW, Single" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def repeat_mid_yy(yy):\n", + " yy = yy[int(NVARS/2)]\n", + " yy = np.repeat(yy, NVARS).reshape(NREALS*NSKIES, NVARS)\n", + " yy = np.swapaxes(yy, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " return yy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#4da169',\n", + " '#e67739', '#e67739',\n", + " '#35b6e0', '#35b6e0',\n", + " \n", + "]\n", + "col3p0 = [\n", + " '#8fcf91', '#8fcf91',\n", + " '#fda363', '#fda363',\n", + " '#38cbff', '#38cbff',\n", + "]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "SHOW_GW = True\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii ==2:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", + " \n", + " col=col0p0[ii]\n", + " for pp in [68,]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if SHOW_GW:\n", + " if ii<4:\n", + " xx_gw, gw_0p0, gw_1p5, gw_3p0 = get_ratio_arrays(targets[ii], red=True,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [68,]:\n", + " med, *conf = np.percentile(gw_0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + " else:\n", + " xx_gw = xx\n", + " gw_0p0 = repeat_mid_yy(gw_0p0)\n", + " gw_1p5 = repeat_mid_yy(gw_1p5)\n", + " gw_3p0 = repeat_mid_yy(gw_3p0)\n", + "\n", + "\n", + " for pp in [68,]:\n", + " med, *conf = np.percentile(gw_0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + "\n", + " med, *conf = np.percentile(gw_1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + " med, *conf = np.percentile(gw_3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle=':')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle=':')\n", + "\n", + "\n", + " for pp in [50,]:\n", + " # Red Noise Models\n", + " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + " \n", + " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", + " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + " \n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_rn_gw_single_68ci.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, { "cell_type": "code", "execution_count": null, From bcb8cc9d3aee2a2fb6ae9490d70e14c42a73dbb9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Fri, 14 Jul 2023 19:53:11 -0500 Subject: [PATCH 257/291] Update SNR plot legends. --- .../paper_plots/snr2_mass_vs_distance.ipynb | 93 +++++++++++++++++-- 1 file changed, 85 insertions(+), 8 deletions(-) diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb index 5a35db31..c15dd378 100644 --- a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb +++ b/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb @@ -1166,16 +1166,17 @@ " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", "\n", " # make figure\n", - " xlabel='Mass'\n", - " ylabel='Distance'\n", + " xlabel='Mass [$\\mathrm{M}_\\odot$]'\n", + " ylabel='Distance [$\\mathrm{Mpc}$]'\n", + " \n", " fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=True)\n", " plt.subplots_adjust(wspace=0, hspace=0)\n", + " fig.text(0.07, 0.5, ylabel, ha='right', va='center', rotation=90)\n", " for ii, ax in enumerate(tqdm(axs.flatten())):\n", " colors = catcolors[ii]\n", - " if ii >=3:\n", + " if ii ==4:\n", " ax.set_xlabel(xlabel)\n", - " if ii == 0 or ii == 3:\n", - " ax.set_ylabel(ylabel)\n", + "\n", " title = plot.PARAM_KEYS[targets[ii]]\n", "\n", " # load histogram data\n", @@ -1248,15 +1249,91 @@ " quantiles=quantiles)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Single" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "alpha=0.99\n", - "alpha = 1- np.sqrt(1-alpha)\n", - "print(alpha)" + "def plot_all_targets_single(\n", + " targets, NBINS=NBINS, \n", + " MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX, DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", + " quantiles=None, smooth=None):\n", + " green_colors = ['#98d594', '#2e984e', '#00441b']\n", + " blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", + " orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", + "\n", + " catcolors = [green_colors, green_colors, \n", + " orange_colors, orange_colors, \n", + " blue_colors, blue_colors]\n", + " \n", + "\n", + " cmap_idx = [0.4, 0.7, 1.0]\n", + " cmaps = ['Greens', 'Greens', \n", + " 'Oranges', 'Oranges',\n", + " 'Blues', 'Blues',]\n", + "\n", + " # get edges\n", + " sam = holo.sams.Semi_Analytic_Model()\n", + " mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + " dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)\n", + "\n", + " # make figure\n", + " xlabel='Mass [$\\mathrm{M}_\\odot$]'\n", + " ylabel='Distance [$\\mathrm{Mpc}$]'\n", + " fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=True,\n", + " height=7)\n", + " fig.text(0.55, 0.075, xlabel, ha='center', va='bottom', )\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " for ii, ax in enumerate(tqdm(axs.flatten())):\n", + " colors = catcolors[ii]\n", + " if ii == 2:\n", + " ax.set_ylabel(ylabel)\n", + " title = plot.PARAM_KEYS[targets[ii]]\n", + "\n", + " # load histogram data\n", + " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", + " filename = filename+f'/mt_dc_hist_tk{TAKE}_{targets[ii]}_{NBINS}bins.npz'\n", + " rv = np.load(filename)\n", + " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", + " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " rv.close()\n", + "\n", + " # plot histogram\n", + " for hh, hist in enumerate([hist_min, hist_med, hist_max]):\n", + " cmap = truncate_colormap(cmaps[ii], cmap_idx[hh], cmap_idx[hh])\n", + " kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", + " np.swapaxes(hist,0,1), cmap=cmap, \n", + " outline=False, quantiles=quantiles, smooth=smooth)\n", + " \n", + "\n", + " # make legend\n", + " alpha = 1- np.sqrt(1-0.8)\n", + " handles = [\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_min:.2f}\", color=colors[0], alpha=alpha),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_med:.2f}\", color=colors[1], alpha=alpha),\n", + " mpl.lines.Line2D([0], [0], label=f\"{par_max:.2f}\", color=colors[2], alpha=alpha),\n", + " ]\n", + " leg = ax.legend(handles=handles, title=title, loc='upper left', \n", + " handletextpad=0.25, borderpad=0.25, labelspacing=0.25, frameon=0,\n", + " borderaxespad=0.25)\n", + " leg._legend_box.align = \"left\"\n", + " \n", + " # plt.subplots_adjust(wspace=0, hspace=0)\n", + " return fig\n", + "\n", + "fig = plot_all_targets_single(targets, smooth=True)\n", + "\n", + "savepath = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_contours'\n", + "savename = f\"{savepath}/snr_kale_contours_single.png\"\n", + "fig.savefig(savename, dpi=300)" ] }, { From fe4f464b9e51bbe08facd3c7060266aec7a13698 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 15:14:17 -0500 Subject: [PATCH 258/291] Plot all new spectra on one 3x6 figure and one 9x2 figure. --- .../paper_plots/new_spectra_6panel.ipynb | 1611 +++++++++++++++++ 1 file changed, 1611 insertions(+) create mode 100644 ecg-notebooks/paper_plots/new_spectra_6panel.ipynb diff --git a/ecg-notebooks/paper_plots/new_spectra_6panel.ipynb b/ecg-notebooks/paper_plots/new_spectra_6panel.ipynb new file mode 100644 index 00000000..b8525b97 --- /dev/null +++ b/ecg-notebooks/paper_plots/new_spectra_6panel.ipynb @@ -0,0 +1,1611 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "from tqdm import tqdm\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### truncate colormaps" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", + "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 3\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 25\n", + "# NSKIES = 15" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Vary Parameter\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + "\n", + " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_09B':\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", + " else:\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " # if os.path.exists(load_dets_from_file) is False:\n", + " # err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " # raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + "\n", + " # file = np.load(load_dets_from_file, allow_pickle=True)\n", + " # dsdat = file['dsdat']\n", + " # file.close()\n", + "\n", + " return data, params" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Save arrays" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "targets = ['hard_time', 'gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', \n", + " 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz'\n", + "NVARS = 21\n", + "NSKIES = 50\n", + "NREALS = 500\n", + "\n", + "for TARGET in tqdm(targets):\n", + " parvars = [0,5,10,15,20] \n", + " yy_ss = []\n", + " yy_bg = []\n", + " data, params = get_data(TARGET, nvars=NVARS, nskies=NSKIES, nreals=NREALS,\n", + " path=path)\n", + " xx=data[0]['fobs_cents']*YR\n", + " for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + " save_name = path+f'/figdata/hcpar_arrays_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " np.savez(save_name, xx=xx, yy_ss=yy_ss, yy_bg=yy_bg)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Load arrays" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def load_hcpar_arrays(target, \n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz'):\n", + " \n", + " load_name = path+f'/figdata/hcpar_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " file = np.load(load_name)\n", + " xx = file['xx']\n", + " yy_ss = file['yy_ss']\n", + " yy_bg = file['yy_bg']\n", + " file.close()\n", + " return xx, yy_ss, yy_bg" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Draw Functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_95ci(ax, xx, yy_ss, yy_bg, ii, colors,\n", + " parvars=[0,5,10,15,20]):\n", + "\n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " if var is not 5 and var is not 15:\n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=1, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " if var is not 5 and var is not 15:\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " return handles\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_lims(ax, xx, yy_ss, yy_bg, ii, colors):\n", + "\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=1, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " if ii == 2:\n", + " ax.errorbar(xx, ymin, yerr=(ymin-ymin, ymed-ymin), color=colors[var], alpha=0.15, \n", + " capsize=0.5, lolims=True, marker='o', markersize=1, linestyle='')\n", + " else:\n", + " ax.errorbar(xx, ymax, yerr=(ymax-ymed, ymax-ymax), color=colors[var], alpha=0.15, \n", + " capsize=0.5, uplims=True, marker='o', markersize=1, linestyle='')\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " return handles " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 6 Panel Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", + " 'hard_time', 'hard_gamma_inner']\n", + "color_maps = [\n", + " cmap_Greens(np.linspace(0, 1, NVARS)), cmap_Greens(np.linspace(0, 1, NVARS)),\n", + " cmap_Oranges(np.linspace(0, 1, NVARS)), cmap_Oranges(np.linspace(0, 1, NVARS)),\n", + " cmap_Blues(np.linspace(0, 1, NVARS)), cmap_Blues(np.linspace(0, 1, NVARS)),\n", + "]\n", + "\n", + "ylim = [\n", + " (2e-19, 2e-13), # hc\n", + " (6.5e5, 8.5e10), # mass in Msun\n", + " (4e1, 7e3)\n", + "]\n", + "\n", + "ylabels = ['$h_c$', '$M\\ [\\mathrm{M}_\\odot]$', '$d_c\\ [\\mathrm{Mpc}]$',]\n", + "titles = ['$\\psi_0$', '$m_{\\psi,0}$', '$\\mu$', '$\\epsilon_\\mu$', \n", + " '$\\\\tau_\\mathrm{hard}$', '$\\\\nu_\\mathrm{inner}$']\n", + "\n", + "fig, axs = plot.figax(ncols=6, nrows=3, sharex=True, figsize=(12,4),)\n", + "fig.text(0.5,0.0, plot.LABEL_GW_FREQUENCY_YR, ha='center')\n", + "for ii, ax in enumerate(axs[:,0]):\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "for cc in range(6):\n", + " xx, yy_ss, yy_bg = load_hcpar_arrays(targets[cc])\n", + " for rr, ax in enumerate(axs[:,cc]):\n", + " handles = draw_95ci(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", + " ax.set_ylim(ylim[rr])\n", + " if cc>0:\n", + " ax.set_yticklabels([])\n", + " if rr==0:\n", + " # ax.text(0.98, 0.98, titles[cc], ha='right', va='top', transform=ax.transAxes)\n", + " ax.text(0.0, 0.0, plot.PARAM_KEYS[targets[cc]], ha='left', va='bottom', \n", + " transform=ax.transAxes, fontsize=12)\n", + "\n", + " # ax.sharey(axs[rr,0])\n", + "plt.subplots_adjust(hspace=0, wspace=0)\n", + "\n", + "\n", + "save_path = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra'\n", + "save_name = save_path+'/95ci_var3_3x6.png'\n", + "fig.savefig(save_name, dpi=300, bbox_inches='tight')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", + " 'hard_time', 'hard_gamma_inner']\n", + "color_maps = [\n", + " cmap_Greens(np.linspace(0, 1, NVARS)), cmap_Greens(np.linspace(0, 1, NVARS)),\n", + " cmap_Oranges(np.linspace(0, 1, NVARS)), cmap_Oranges(np.linspace(0, 1, NVARS)),\n", + " cmap_Blues(np.linspace(0, 1, NVARS)), cmap_Blues(np.linspace(0, 1, NVARS)),\n", + "]\n", + "\n", + "ylim = [\n", + " (2e-19, 3e-13), # hc\n", + " (6.5e5, 2e11), # mass in Msun\n", + " (3e1, 5e3)\n", + "]\n", + "\n", + "ylabels = ['$h_c$', '$M\\ [\\mathrm{M}_\\odot]$', '$d_c\\ [\\mathrm{Mpc}]$',]\n", + "titles = ['$\\psi_0$', '$m_{\\psi,0}$', '$\\mu$', '$\\epsilon_\\mu$', \n", + " '$\\\\tau_\\mathrm{hard}$', '$\\\\nu_\\mathrm{inner}$']\n", + "\n", + "fig, axs = plot.figax(ncols=6, nrows=3, sharex=True, figsize=(12,5),)\n", + "fig.text(0.5,0.0, plot.LABEL_GW_FREQUENCY_YR, ha='center')\n", + "for ii, ax in enumerate(axs[:,0]):\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "for cc in range(6):\n", + " xx, yy_ss, yy_bg = load_hcpar_arrays(targets[cc])\n", + " for rr, ax in enumerate(axs[:,cc]):\n", + " handles = draw_lims(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", + " ax.set_ylim(ylim[rr])\n", + " if cc>0:\n", + " ax.set_yticklabels([])\n", + " if rr==0:\n", + " # ax.text(0.98, 0.98, titles[cc], ha='right', va='top', transform=ax.transAxes)\n", + " ax.text(0.0, 0.0, plot.PARAM_KEYS[targets[cc]], ha='left', va='bottom', \n", + " transform=ax.transAxes, fontsize=12)\n", + "\n", + " # ax.sharey(axs[rr,0])\n", + "plt.subplots_adjust(hspace=0, wspace=0)\n", + "\n", + "\n", + "save_path = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra'\n", + "save_name = save_path+'/95lims_var3_3x6.png'\n", + "fig.savefig(save_name, dpi=300, bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 2 x 9" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", + " 'hard_time', 'hard_gamma_inner']\n", + "color_maps = [\n", + " cmap_Greens(np.linspace(0, 1, NVARS)), cmap_Greens(np.linspace(0, 1, NVARS)),\n", + " cmap_Oranges(np.linspace(0, 1, NVARS)), cmap_Oranges(np.linspace(0, 1, NVARS)),\n", + " cmap_Blues(np.linspace(0, 1, NVARS)), cmap_Blues(np.linspace(0, 1, NVARS)),\n", + "]\n", + "\n", + "ylim = [\n", + " (2e-19, 2e-13), # hc\n", + " (6.5e5, 8.5e10), # mass in Msun\n", + " (4e1, 7e3)\n", + "]\n", + "\n", + "ylabels = ['$h_c$', '$M\\ [\\mathrm{M}_\\odot]$', '$d_c\\ [\\mathrm{Mpc}]$',]\n", + "\n", + "fig, axs = plot.figax_single(ncols=2, nrows=9, sharex=True, height=10,)\n", + "fig.text(0.5,0.1, plot.LABEL_GW_FREQUENCY_YR, ha='center')\n", + "# for ii, ax in enumerate(axs[:,0]):\n", + "# ax.set_ylabel(ylabels[ii])\n", + "\n", + "for cc in range(6):\n", + " col = cc%2 # 0 or 1\n", + " xx, yy_ss, yy_bg = load_hcpar_arrays(targets[cc])\n", + " for rr in range(3):\n", + " row = rr + 3*int(cc/2)\n", + " print(f\"{col=}, {row=}\")\n", + " ax = axs[row, col]\n", + " handles = draw_95ci(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", + " ax.set_ylim(ylim[rr])\n", + " if col==0:\n", + " ax.set_ylabel(ylabels[row%3])\n", + " else:\n", + " ax.set_yticklabels([])\n", + " # ax.sharey(axs[rr,0])\n", + "\n", + "\n", + "\n", + "plt.subplots_adjust(hspace=0, wspace=0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Old Versions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the confidence intervals\n", + " for pp in [95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## fave hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Blues(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3)\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title='$\\\\tau_\\mathrm{hard}$')\n", + "# fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/charstrain_pars_vs_freq_var5_{TARGET}.png',\n", + " # dpi=300)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Separate char strains" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,5,10,15,20]\n", + "hc_ss_all = []\n", + "hc_bg_all = []\n", + "text = []\n", + "\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(params[var][TARGET])" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# GSMF_Phi0, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_phi0'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=2, linestyle='-')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " # ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " # ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[var], alpha=0.8, s=20)\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_midpoints.png',\n", + " dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=2, linestyle='-')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " # ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " # capsize=3, marker=None)\n", + " ax.scatter(xx, ymax, marker='v', color=colors[var], alpha=0.8, s=20)\n", + "\n", + " ax.scatter(xx, ymin, marker='^', color=colors[var], alpha=0.8, s=20)\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}.png',\n", + " dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_95ci(xx, yy_ss, yy_bg, colors):\n", + " ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [95,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_95ci.png',\n", + " dpi=300)\n", + " return fig\n", + "fig = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_errbars(xx, yy_ss, yy_bg, colors):\n", + " ylabels = ['Char. Strain', 'Mass [M$_\\odot$]', #'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var])\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)-ymed\n", + " ymin = ymed - np.min(yy_ss[vv][ii], axis=-1)\n", + " ax.errorbar(xx, ymed, yerr=(ymin, ymax), color=colors[var], alpha=0.5, \n", + " capsize=3, marker=None)\n", + " ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.8, s=20)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # Plot the confidence intervals\n", + " for pp in [95]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_bg[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_errbars.png',\n", + " dpi=300)\n", + " return fig\n", + "fig = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_uplims(xx, yy_ss, yy_bg, colors):\n", + " ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + " fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + " xx = fobs_cents*YR\n", + " nsamp = 5\n", + "\n", + " # colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + " # colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + " for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " if ii == 2:\n", + " ax.errorbar(xx, ymin, yerr=(ymin-ymin, ymed-ymin), color=colors[var], alpha=0.5, \n", + " capsize=2, lolims=True, marker='o', markersize=3, linestyle='')\n", + " else:\n", + " ax.errorbar(xx, ymax, yerr=(ymax-ymed, ymax-ymax), color=colors[var], alpha=0.5, \n", + " capsize=2, uplims=True, marker='o', markersize=3, linestyle='')\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + " \n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + " axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + " plt.subplots_adjust(wspace=0, hspace=0)\n", + " plot._twin_hz(axs[0], nano=True)\n", + "\n", + " # fig.tight_layout()\n", + " labels = []\n", + " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + " fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + " fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_uplims_68ci.png',\n", + " dpi=300)\n", + " return fig\n", + "fig = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabels = ['Char. Strain', 'Mass [M$_\\odot$]',# 'Mass Ratio', \n", + " 'Distance [Mpc]',]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=1, sharex=True, height=10)\n", + "xx = fobs_cents*YR\n", + "nsamp = 5\n", + "\n", + "colors = cmap_Greens(np.linspace(0, 1, NVARS))\n", + "# colors = cmap_PuBuGn(np.linspace(0, 1, NVARS))\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=3)\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " xx_ss = np.repeat(xx, NREALS).reshape(NFREQS,NREALS)\n", + " ax.scatter(xx_ss, yy_ss[vv][ii], marker='o', color=colors[var], alpha=0.1, s=5)\n", + "\n", + "\n", + " # for vv, var in enumerate(parvars):\n", + " # # Plot the loudest single sources confidence intervals\n", + " # for pp in [95,]:\n", + " # percs = pp / 2\n", + " # percs = [50 - percs, 50 + percs]\n", + " # ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.25, color=colors[var])\n", + "\n", + "\n", + " # label axes\n", + " # if ii>=3:\n", + " ax.set_ylabel(ylabels[ii])\n", + "\n", + "axs[-1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "plot._twin_hz(axs[0], nano=True)\n", + "\n", + "# fig.tight_layout()\n", + "labels = []\n", + "for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", + "fig.legend(handles=handles, labels=labels, bbox_to_anchor=(0.5,0.02), loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[TARGET])\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hcprop_var/hcprop_vs_freq_var5_{TARGET}_scatter.png',\n", + " dpi=300)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Plots From Functions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## hard_time" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_time'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "# parvars = [0,5,10,15,20]\n", + "parvars = [0,10,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GSMF_phi0, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## GSMF_mchar0_log10, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'gsmf_mchar0_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Greens(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## mmb_mamp_log10, 5vars" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_mamp_log10'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# mmb_scatter_dex" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'mmb_scatter_dex'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Oranges(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner'\n", + "NVARS = 21\n", + "NREALS = 500\n", + "\n", + "parvars = [0,5,10,15,20]\n", + "yy_ss = []\n", + "yy_bg = []\n", + "data, params = get_data(TARGET, nvars=NVARS, nreals=NREALS,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "print(data.shape)\n", + "for vv, var in enumerate(parvars):\n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + "\n", + " sspar = data[var]['sspar']\n", + " bgpar = data[var]['bgpar']\n", + "\n", + " sspar = sings.all_sspars(fobs_cents, sspar)\n", + " bgpar = bgpar*sings.par_units[:,np.newaxis,np.newaxis]\n", + " sspar = sspar*sings.par_units[:,np.newaxis,np.newaxis,np.newaxis]\n", + "\n", + "\n", + " # parameters to plot\n", + " _yy_ss = [hc_ss[...,0], sspar[0,...,0], #sspar[1,...,0], # sspar[2,], # strain, mass, mass ratio,\n", + " sspar[4,...,0]] # final comoving distance, single loudest only\n", + "\n", + " _yy_bg = [hc_bg, bgpar[0], #bgpar[1], # strain, mass, mass ratio, initial redshift, final com distance\n", + " bgpar[4],]\n", + " yy_ss.append(_yy_ss)\n", + " yy_bg.append(_yy_bg)\n", + "\n", + "\n", + "fig1 = plot_95ci(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig2 = plot_errbars(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))\n", + "fig3 = plot_uplims(xx, yy_ss, yy_bg, colors = cmap_Blues(np.linspace(0, 1, NVARS)))" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# The charstrain plot to end all charstrain plots" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,1,2]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'gsmf_phi0'\n", + "data, params = get_data(TARGET, nvars=3, nreals=500, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\psi_0$=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_phi0 = hc_ss_all\n", + "hc_bg_phi0 = hc_bg_all\n", + "text_phi0 = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,1,2]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'gsmf_mchar0_log10'\n", + "data, params = get_data(TARGET, nvars=3, nreals=500, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"log($M_{\\psi,0}$/M$_\\odot$)=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_mchar0 = hc_ss_all\n", + "hc_bg_mchar0 = hc_bg_all\n", + "text_mchar0 = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'mmb_mamp_log10'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"log($\\mu$/M$_\\odot$)=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_mamp = hc_ss_all\n", + "hc_bg_mamp = hc_bg_all\n", + "text_mamp = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'mmb_scatter_dex'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\epsilon_\\mu$=%.2f dex\" % params[var][TARGET])\n", + "\n", + "hc_ss_scatter = hc_ss_all\n", + "hc_bg_scatter = hc_bg_all\n", + "text_scatter = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all = []\n", + "text = []\n", + "TARGET = 'hard_time'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\\\tau_\\mathrm{hard}=%.2f$\" % params[var][TARGET])\n", + "\n", + "hc_ss_hardtime = hc_ss_all\n", + "hc_bg_hardtime = hc_bg_all\n", + "text_hardtime = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "parvars = [0,10,20]\n", + "hc_ss_all = []\n", + "hc_bg_all= []\n", + "text = []\n", + "TARGET = 'hard_gamma_inner'\n", + "data, params = get_data(TARGET, nvars=21, nreals=500, nskies=100, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_09B')\n", + "for vv, var in enumerate(parvars): \n", + " hc_ss = data[var]['hc_ss']\n", + " hc_bg = data[var]['hc_bg']\n", + " hc_ss_all.append(hc_ss)\n", + " hc_bg_all.append(hc_bg)\n", + " text.append(\"$\\\\nu_\\mathrm{inner}$=%.2f\" % params[var][TARGET])\n", + "\n", + "hc_ss_gamma = hc_ss_all\n", + "hc_bg_gamma = hc_bg_all\n", + "text_gamma = text" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.shares_memory(hc_ss_hardtime, hc_ss_all))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsamp = 5 # number of sample GWB spectra to plot\n", + "colors = [\n", + " '#ff7f0f', # orange\n", + " '#6a3d9a', # purple\n", + " '#f0027f', # pink\n", + " '#a6d853', # green\n", + " '#15becf', # teal\n", + "]\n", + "\n", + "target_colors = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41',\n", + " '#2d839f', '#2d839f',\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(ncols=3, nrows = 6, sharex=True, sharey=True, height=14)\n", + "# axs[0].set_ylabel(plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "fig.text(0.04, 0.5, plot.LABEL_CHARACTERISTIC_STRAIN, ha='center', va='bottom', rotation='vertical')\n", + "axs[-1, 1].set_xlabel(plot.LABEL_GW_FREQUENCY_YR)\n", + "plt.subplots_adjust(wspace=0, hspace=0)\n", + "\n", + "# plot as a function of frequency /yr\n", + "xx = fobs_cents * YR\n", + "xx_ss = np.repeat(xx, NLOUDEST).reshape(NFREQS, NLOUDEST)\n", + "# plot a reference, pure power-law strain spectrum: h_c(f) = 1e-15 * (f * yr) ^ -2/3\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "\n", + "\n", + "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex', 'hard_time', 'hard_gamma_inner']\n", + "hc_ss_targets = [hc_ss_phi0, hc_ss_mchar0, hc_ss_mamp, hc_ss_scatter, hc_ss_hardtime, hc_ss_gamma]\n", + "hc_bg_targets = [hc_bg_phi0, hc_bg_mchar0, hc_bg_mamp, hc_bg_scatter, hc_bg_hardtime, hc_bg_gamma]\n", + "text_targets = [text_phi0, text_mchar0, text_mamp, text_scatter, text_hardtime, text_gamma]\n", + "for rr, ax_row in enumerate(axs):\n", + " text = text_targets[rr]\n", + " hc_ss_all = hc_ss_targets[rr]\n", + " hc_bg_all = hc_bg_targets[rr]\n", + " for cc, ax in enumerate(ax_row):\n", + " \n", + " ax.plot(xx, yy, 'k--', alpha=0.25, lw=2.0)\n", + "\n", + " hc_ss = hc_ss_all[cc]\n", + " hc_bg = hc_bg_all[cc]\n", + "\n", + " # Plot the median GWB spectrum\n", + " ax.plot(xx, np.median(hc_bg, axis=-1), 'k-')\n", + "\n", + " # Plot `nsamp` random spectra \n", + " seed = np.random.randint(99999) # get a random number\n", + " print(f\"{ii=}, {seed=}\") # print it out so we can reuse it if desired\n", + " np.random.seed(seed) # set the random seed\n", + "\n", + " nsamp = np.min([nsamp, NREALS])\n", + "\n", + " # select random realizations to plot\n", + " idx = np.random.choice(NREALS, nsamp, replace=False)\n", + " for ci, ii in enumerate(idx):\n", + "\n", + " for ll in range(5):\n", + " edgecolor = 'k' if ll==0 else None\n", + " ax.scatter(xx, hc_ss[:,ii,ll], color=colors[ci], alpha=0.3, edgecolor=edgecolor,\n", + " s=20)\n", + "\n", + " for ci, ii in enumerate(idx):\n", + " ax.plot(xx, hc_bg[:,ii], linestyle='-', alpha=0.75, color=colors[ci]) \n", + "\n", + " # plot contours at 50% and 98% confidence intervals\n", + " for pp in [50, 98]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='k')\n", + " ax.text(\n", + " 0.01,0.01, text[cc], transform=ax.transAxes, color=target_colors[rr],\n", + " horizontalalignment='left', verticalalignment='bottom')\n", + " \n", + " # plt.show()\n", + "fig.savefig(f'/Users/emigardiner/GWs/holodeck/output/figures/bigplots/hc_3x6.png', dpi=300)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 04647fd31749e10c12f654af6a6482b0eff158b2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 15:30:32 -0500 Subject: [PATCH 259/291] Add Sh_ss_noise function, for single source noise in bg detection. --- holodeck/detstats.py | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 3a5b60bf..49c4397b 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -421,7 +421,11 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False sigma_0B : (R,) 1Darray sigma_1B : (R,) 1Darray + TODO: Update or deprecate. """ + + print("Detect_bg() is deprecated. Use detect_bg_pta() instead for red noise and ss noise.") + # Overlap Reduction Function num = len(thetas) # number of pulsars, P Gamma = np.zeros((num, num)) # (P,P) 2Darray of scalars, Overlap reduction function between all puolsar @@ -462,7 +466,7 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False -def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False, +def detect_bg_pta(pulsars, fobs, hc_bg, hc_ss, alpha_0=0.001, ret_snr = False, red_amp=None, red_gamma=None, ): """ Calculate the background detection probability, and all the intermediary steps from a list of hasasia.Pulsar objects. @@ -516,7 +520,7 @@ def detect_bg_pta(pulsars, fobs, hc_bg, alpha_0=0.001, ret_snr = False, if (red_amp is not None) and (red_gamma is not None): red_noise = _red_noise(red_amp, red_gamma, fobs)[np.newaxis,:] # (1,F,) noise = noise + red_noise # (P,F,) - + noise = noise[:,:,np.newaxis] + _Sh_ss_noise(hc_ss, freqs) # (P, F, R) mu_1B = _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg) @@ -838,6 +842,7 @@ def _antenna_pattern_functions(m_hat, n_hat, Omega_hat, pi_hat): ######################## Noise Spectral Density ######################## + def _Sh_rest_noise(hc_ss, hc_bg, freqs): """ Calculate the noise spectral density contribution from all but the current single source. @@ -852,11 +857,10 @@ def _Sh_rest_noise(hc_ss, hc_bg, freqs): Returns ------- - ss_noise : (F,R,L) NDarray of scalars + Sh_rest : (F,R,L) NDarray of scalars The noise in a single pulsar from other GW sources for detecting each single source. Follows Eq. (45) in Rosado et al. 2015. - TODO: modify this to allow for multiple loud sources. """ hc2_louds = np.sum(hc_ss**2, axis=2) # (F,R) # subtract the single source from rest of loud sources and the background, for each single source @@ -864,6 +868,33 @@ def _Sh_rest_noise(hc_ss, hc_bg, freqs): Sh_rest = hc2_rest / freqs[:,np.newaxis,np.newaxis]**3 /(12 * np.pi**2) # (F,R,L) return Sh_rest + +def _Sh_ss_noise(hc_ss, freqs): + """ Calculate the noise spectral density contribution from all single sources. + + Parameters + ---------- + hc_ss : (F,R,L) NDarray + Characteristic strain from all loud single sources. + hc_bg : (F,R) NDarray + Characteristic strain from all but loudest source at each frequency. + freqs : (F,) 1Darray + Frequency bin centers. + + Returns + ------- + Sh_ss : (F,R,L) NDarray of scalars + The noise in a single pulsar from other GW sources for detecting each single source. + + Follows Eq. (45) in Rosado et al. 2015. + """ + + # sum of noise from all loudest single sources + hc2_ss = np.sum(hc_ss**2, axis=2) # (F,R) + Sh_ss = hc2_ss / freqs[:,np.newaxis]**3 /(12 * np.pi**2) # (F,R,) + return Sh_ss + + def _red_noise(red_amp, red_gamma, freqs, f_ref=1/YR): """ Calculate the red noise for a given pulsar (or array of pulsars) red_amp * f sigma_i^red_gamma @@ -925,6 +956,7 @@ def _total_noise(delta_t, sigmas, hc_ss, hc_bg, freqs, red_amp=None, red_gamma=N return noise + ################### GW polarization, phase, amplitude ################### def _a_b_polarization(iotas): From 2ead255d74bb00a49cc05c6fe8b7ebe0b55f447e Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 15:37:23 -0500 Subject: [PATCH 260/291] Update sigma0_Bstatistic() --- holodeck/detstats.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 49c4397b..f550e7ab 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -214,7 +214,7 @@ def _sigma0_Bstatistic(noise, Gamma, Sh0_bg): Parameters ---------- - noise : (P,) 1darray of scalars + noise : (P,F,R) Ndarray of scalars Noise spectral density of each pulsar. Gamma : (P,P) 2Darray of scalars Overlap reduction function for j>i, 0 otherwise. @@ -238,14 +238,19 @@ def _sigma0_Bstatistic(noise, Gamma, Sh0_bg): # to get sum term in shape (P,P,F,R) we want: # Gamma in shape (P,P,1,1) # Sh0 and Sh in shape (1,1,F,R) - # P_i in shape (P,1,1,1) - # P_j in shape (1,P,1,1) + # P_i in shape (P,1,F,R) + # P_j in shape (1,P,F,R) - numer = (Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2 - * noise[:,np.newaxis,:,np.newaxis] * noise[np.newaxis,:,:,np.newaxis]) - denom = ((noise[:,np.newaxis,:,np.newaxis] + Sh0_bg[np.newaxis, np.newaxis,:]) - * (noise[np.newaxis,:,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) - + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2)**2 + Gamma = Gamma[:,:,np.newaxis,np.newaxis] + Sh0_bg = Sh0_bg[np.newaxis,np.newaxis,:] + noise_i = noise[:,np.newaxis,:,np.newaxis] + noise_j = noise[np.newaxis,:,:,np.newaxis] + + numer = (Gamma**2 * Sh0_bg**2 + * noise_i * noise_j]) + denom = ((noise_j + Sh0_bg) + * (noise_j + Sh0_bg) + + Gamma**2 * Sh0_bg**2)**2 sum = np.sum(numer/denom, axis=(0,1,2)) sigma_0B = np.sqrt(2*sum) @@ -442,7 +447,7 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False # print('Sh_bg:', Sh_bg.shape) # Noise - noise = _white_noise(cad, sigmas)[:,np.newaxis] # P, F + noise = _white_noise(cad, sigmas)[:,np.newaxis, np.newaxis] # P, 1, 1 # print('noise:', noise.shape) sigma_0B = _sigma0_Bstatistic(noise, Gamma, Sh0_bg) @@ -516,10 +521,15 @@ def detect_bg_pta(pulsars, fobs, hc_bg, hc_ss, alpha_0=0.001, ret_snr = False, Sh_bg = _power_spectral_density(hc_bg[:], fobs) Sh0_bg = Sh_bg # note this refers to same object, not a copy + # calculate white noise noise = _white_noise(cad, sigmas)[:,np.newaxis] # P,1 + + # add red noise if (red_amp is not None) and (red_gamma is not None): red_noise = _red_noise(red_amp, red_gamma, fobs)[np.newaxis,:] # (1,F,) noise = noise + red_noise # (P,F,) + + # add single source noise noise = noise[:,:,np.newaxis] + _Sh_ss_noise(hc_ss, freqs) # (P, F, R) mu_1B = _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg) From 82bd5c5066b10b9ad90c7411b211a77ccef8fab6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 15:53:20 -0500 Subject: [PATCH 261/291] Update sigma1_Bstatistic() and mean1_Bstatistic() for new noise. --- holodeck/detstats.py | 58 ++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index f550e7ab..9cfc8536 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -241,11 +241,13 @@ def _sigma0_Bstatistic(noise, Gamma, Sh0_bg): # P_i in shape (P,1,F,R) # P_j in shape (1,P,F,R) + # Cast parameters to desired shapes Gamma = Gamma[:,:,np.newaxis,np.newaxis] Sh0_bg = Sh0_bg[np.newaxis,np.newaxis,:] - noise_i = noise[:,np.newaxis,:,np.newaxis] - noise_j = noise[np.newaxis,:,:,np.newaxis] + noise_i = noise[:,np.newaxis,:,:] + noise_j = noise[np.newaxis,:,:,:] + # Calculate sigma_0B numer = (Gamma**2 * Sh0_bg**2 * noise_i * noise_j]) denom = ((noise_j + Sh0_bg) @@ -262,7 +264,7 @@ def _sigma1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): Parameters ---------- - noise : (P,) 1darray of scalars + noise : (P,F,R) 1darray of scalars Noise spectral density of each pulsar. Gamma : (P,P) 2Darray of scalars Overlap reduction function for j>i, 0 otherwise. @@ -291,26 +293,34 @@ def _sigma1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): # P_i in shape (P,1,1,1) # P_j in shape (1,P,1,1) - numer = (Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2 - * ((noise[:,np.newaxis,:,np.newaxis] + Sh_bg[np.newaxis,np.newaxis,:]) - * (noise[np.newaxis,:,:,np.newaxis] + Sh_bg[np.newaxis,np.newaxis,:]) - + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh_bg[np.newaxis,np.newaxis,:]**2)) + # Cast parameters to desired shapes + Gamma = Gamma[:,:,np.newaxis,np.newaxis] + Sh0_bg = Sh0_bg[np.newaxis,np.newaxis,:] + Sh_bg = Sh_bg[np.newaxis,np.newaxis,:] + noise_i = noise[:,np.newaxis,:,:] + noise_j = noise[np.newaxis,:,:,:] + - denom = ((noise[:,np.newaxis,:,np.newaxis] + Sh0_bg[np.newaxis, np.newaxis,:]) - * (noise[np.newaxis,:,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) - + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis,np.newaxis,:]**2)**2 + # Calculate sigma_1B + numer = (Gamma**2 * Sh0_bg**2 + * ((noise_i + Sh_bg) * (noise_j + Sh_bg) + + Gamma**2 * Sh_bg**2)) + + denom = ((noise_i + Sh0_bg) + * (noise_j + Sh0_bg) + + Gamma**2 * Sh0_bg**2)**2 sum = np.sum(numer/denom, axis=(0,1,2)) sigma_1B = np.sqrt(2*sum) return sigma_1B -def _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): +def _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg, debug=False): """ Calculate mu_1 for the background, by summing over all pulsars and frequencies. Assuming the B statistic, which maximizes S/N_B = mu_1/sigma_1 Parameters ---------- - noise : (P,F,) Ndarray of scalars + noise : (P,F,R) Ndarray of scalars Noise spectral density of each pulsar. Gamma : (P,P) 2Darray of scalars Overlap reduction function for j>i, 0 otherwise. @@ -328,9 +338,10 @@ def _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): """ # Check that Gamma_{j<=i} = - for ii in range(len(noise)): - for jj in range(ii+1): - assert Gamma[ii,jj] == 0, f'Gamma[{ii},{jj}] = {Gamma[ii,jj]}, but it should be 0!' + if debug: + for ii in range(len(Gamma)): + for jj in range(ii+1): + assert Gamma[ii,jj] == 0, f'Gamma[{ii},{jj}] = {Gamma[ii,jj]}, but it should be 0!' # to get sum term in shape (P,P,F,R) for ii,jj,kk we want: # Gamma in shape (P,P,1,1) @@ -338,12 +349,17 @@ def _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg): # P_i in shape (P,1,1,1) # P_j in shape (1,P,1,1) - numer = (Gamma[:,:,np.newaxis,np.newaxis] **2 - * Sh_bg[np.newaxis,np.newaxis,:] - * Sh0_bg[np.newaxis,np.newaxis,:]) - denom = ((noise[:,np.newaxis,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) - * (noise[np.newaxis,:,:,np.newaxis] + Sh0_bg[np.newaxis,np.newaxis,:]) - + Gamma[:,:,np.newaxis,np.newaxis]**2 * Sh0_bg[np.newaxis, np.newaxis, :]**2) + # Cast parameters to desired shapes + Gamma = Gamma[:,:,np.newaxis,np.newaxis] + Sh0_bg = Sh0_bg[np.newaxis,np.newaxis,:] + Sh_bg = Sh_bg[np.newaxis,np.newaxis,:] + noise_i = noise[:,np.newaxis,:,:] + noise_j = noise[np.newaxis,:,:,:] + + + # Calculate mu_1B + numer = (Gamma **2 * Sh_bg * Sh0_bg) + denom = ((noise_i + Sh0_bg) * (noise_j + Sh0_bg) + Gamma**2 * Sh0_bg**2) # Requires Gamma have all jj<=ii parts to zero sum = np.sum(numer/denom, axis=(0,1,2)) From cb003f68939011de03640da9f235d1cfc7a7f379 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 15:59:47 -0500 Subject: [PATCH 262/291] Update detstats output path to includ 'ssn' for new single source noise in background detstats. --- ecg-notebooks/parameter_investigation/detect_custom_model.py | 2 +- ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py | 2 +- ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py | 2 +- .../parameter_investigation/detect_model_clbrt_ramp.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_custom_model.py b/ecg-notebooks/parameter_investigation/detect_custom_model.py index ca98f62b..4b6459f8 100644 --- a/ecg-notebooks/parameter_investigation/detect_custom_model.py +++ b/ecg-notebooks/parameter_investigation/detect_custom_model.py @@ -242,7 +242,7 @@ def main(): else: save_data_to_file = args.save_file - save_dets_to_file = output_path+f'/detstats_s{args.nskies}' + save_dets_to_file = output_path+f'/detstats_s{args.nskies}_ssn' if args.red2white is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' elif args.red_amp is not None and args.red_gamma is not None: diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py index 5ea48fad..3c1a481d 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_7GW.py @@ -176,7 +176,7 @@ def main(): else: save_data_to_file = args.save_file - save_dets_to_file = output_path+f'/detstats_s{args.nskies}' + save_dets_to_file = output_path+f'/detstats_s{args.nskies}_ssn' if args.red2white is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' elif args.red_amp is not None and args.red_gamma is not None: diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index a2f31802..c03c019e 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -174,7 +174,7 @@ def main(): else: save_data_to_file = args.save_file - save_dets_to_file = output_path+f'/detstats_s{args.nskies}' + save_dets_to_file = output_path+f'/detstats_s{args.nskies}_ssn' if args.red2white is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' elif args.red_amp is not None and args.red_gamma is not None: diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py index 06a2763b..1ab3d52d 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_ramp.py @@ -172,7 +172,7 @@ def main(): save_data_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}' else: save_data_to_file = args.save_file - save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_s{args.nskies}_shape{str(args.shape)}_ds' + save_dets_to_file = args.anatomy_path+f'/{args.target}_v{args.nvars}_r{args.nreals}_shape{str(args.shape)}/detstats_s{args.nskies}_ssn' save_dets_to_file = save_dets_to_file+f'_sig{args.sigma:.1e}_rg{args.red_gamma:.1f}' print(f"{load_data_from_file=}.npz") From e25b69aa27b4f21d4f5b1334e52b1600b9ac56d3 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 16:02:46 -0500 Subject: [PATCH 263/291] Fix type. --- holodeck/detstats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 9cfc8536..7171dc02 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -249,7 +249,7 @@ def _sigma0_Bstatistic(noise, Gamma, Sh0_bg): # Calculate sigma_0B numer = (Gamma**2 * Sh0_bg**2 - * noise_i * noise_j]) + * noise_i * noise_j) denom = ((noise_j + Sh0_bg) * (noise_j + Sh0_bg) + Gamma**2 * Sh0_bg**2)**2 From 161c0fa07e1ad7a2a58e9d85b110b143e85c911c Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 16:10:17 -0500 Subject: [PATCH 264/291] Update detect_lib and calibration for ss noise. --- holodeck/detstats.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 7171dc02..958c4ff1 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -546,7 +546,7 @@ def detect_bg_pta(pulsars, fobs, hc_bg, hc_ss, alpha_0=0.001, ret_snr = False, noise = noise + red_noise # (P,F,) # add single source noise - noise = noise[:,:,np.newaxis] + _Sh_ss_noise(hc_ss, freqs) # (P, F, R) + noise = noise[:,:,np.newaxis] + _Sh_ss_noise(hc_ss, fobs) # (P, F, R) mu_1B = _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg) @@ -2315,7 +2315,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, real_dur = now # get calibrated psrs - psrs, red_amp, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], fobs_cents, npsrs, tol=tol, maxbads=maxbads, + psrs, red_amp, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], hc_ss[:,rr,:], fobs_cents, npsrs, tol=tol, maxbads=maxbads, sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, red_amp=red_amp, red_gamma=red_gamma, red2white=red2white) _sigmin /= 2 @@ -2327,7 +2327,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, # print(f"before calculation: {utils.stats(psrs[0].toaerrs)=}, \n{utils.stats(hc_bg[rr])=},\ # {utils.stats(fobs_cents)=}") # use those psrs to calculate realization detstats - _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) + _dp_bg, _snr_bg = detect_bg_pta(psrs, fobs_cents, hc_bg[:,rr:rr+1], hc_ss[:,rr:rr+1,:], ret_snr=True, red_amp=red_amp, red_gamma=red_gamma) # print(f"{utils.stats(psrs[0].toaerrs)=}, {utils.stats(hc_bg[rr])=},\ # {_dp_bg=},") # _dp_bg, = detect_bg_pta(psrs, fobs_cents, hc_bg=hc_bg[:,rr:rr+1], red_amp=red_amp, red_gamma=red_gamma) #, ret_snr=True) @@ -2358,6 +2358,8 @@ def detect_pspace_model_clbrt_ramp(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigm thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, red_amp=None, red_gamma=None): """ Detect pspace model using individual red noise amplitude calibration for each realization + + NOTE: Not supported, not updated for including single sources as noise for BG. """ dur = 1.0/fobs_cents[0] @@ -2564,7 +2566,7 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, ) return rsigmas, avg_dps, std_dps -def calibrate_one_pta(hc_bg, fobs, npsrs, +def calibrate_one_pta(hc_bg, hc_ss, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, phis=None, thetas=None, ret_sig = False, red_amp=None, red_gamma=None, red2white=None): """ Calibrate the specific PTA for a given realization, and return that PTA @@ -2573,6 +2575,8 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, ---------- hc_bg : (F,) 1Darray The background characteristic strain for one realization. + hc_ss : (F,L) NDarray + The SS characteristic strains for one realization fobs : (F,) 1Darray Observed GW frequencies. npsrs : integer @@ -2589,7 +2593,6 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, sigma : float final sigma, returned only if ret_sig=True - TODO: Correct ratio from red2white, so that they use the same units/convention! """ # get duration and cadence from fobs @@ -2605,7 +2608,8 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=red_amp, red_gamma=red_gamma)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], + red_amp=red_amp, red_gamma=red_gamma)[0] nclose=0 # number of attempts close to 0.5, could be stuck close nfar=0 # number of attempts far from 0.5, could be stuck far @@ -2617,7 +2621,8 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, red_amp = sigma * red2white psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=red_amp, red_gamma=red_gamma)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], + red_amp=red_amp, red_gamma=red_gamma)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): @@ -2666,7 +2671,7 @@ def calibrate_one_pta(hc_bg, fobs, npsrs, return psrs, red_amp, sigma, sigmin, sigmax return psrs, red_amp -def calibrate_one_ramp(hc_bg, fobs, psrs, +def calibrate_one_ramp(hc_bg, hc_ss, fobs, psrs, rampstart=1e-6, rampmin=1e-9, rampmax=1e-4, debug=False, maxbads=20, tol=0.03, phis=None, thetas=None, rgam=-1.5): """ Calibrate the red noise amplitude, for a given realization, and return that PTA @@ -2675,6 +2680,8 @@ def calibrate_one_ramp(hc_bg, fobs, psrs, ---------- hc_bg : (F,) 1Darray The background characteristic strain for one realization. + hc_ss : (F,L) NDarray + The SS characteristic strains for one realization fobs : (F,) 1Darray Observed GW frequencies. psrs : hasasia.sim.pta object @@ -2699,7 +2706,8 @@ def calibrate_one_ramp(hc_bg, fobs, psrs, # randomize pulsar positions ramp = rampstart - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=rgam, red_gamma=ramp)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], + red_amp=rgam, red_gamma=ramp)[0] nclose=0 # number of attempts close to 0.5, could be stuck close nfar=0 # number of attempts far from 0.5, could be stuck far @@ -2707,7 +2715,8 @@ def calibrate_one_ramp(hc_bg, fobs, psrs, # calibrate sigma while np.abs(dp_bg-0.50)>tol: ramp = np.mean([rampmin, rampmax]) # a weighted average would be better - dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], red_amp=ramp, red_gamma=rgam)[0] + dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], + red_amp=ramp, red_gamma=rgam)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): From eaa5cfafe031245c5a32e7f3c0d7a8538caafe50 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 19:31:55 -0500 Subject: [PATCH 265/291] Add EVDP label to plot.py --- holodeck/plot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/holodeck/plot.py b/holodeck/plot.py index 00fbed47..ac14345c 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -57,6 +57,8 @@ 'mmb_scatter_dex': r"MMB $\epsilon_{\mu}$", } +LABEL_EVDP_RATIO = r"$\langle N_\mathrm{SS} \rangle" + COLORS_MPL = plt.rcParams['axes.prop_cycle'].by_key()['color'] From 34633fe4e444cb599cb91656d236c5865ee669f6 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 20:07:38 -0500 Subject: [PATCH 266/291] Plot ratios with hard_time, hard_gamma_inner, and gsmf_phi0 using single source noise (ssn). --- .../paper_plots/ratio3_ssnoise.ipynb | 229 ++++++++++++++++++ holodeck/detstats.py | 1 + holodeck/plot.py | 2 +- 3 files changed, 231 insertions(+), 1 deletion(-) create mode 100644 ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb diff --git a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb new file mode 100644 index 00000000..a33f1aef --- /dev/null +++ b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb @@ -0,0 +1,229 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "from tqdm import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# NSKIES = 15\n", + "\n", + "SHOW_GW=True" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz', ssn='_ssn', \n", + "):\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}{ssn}' \n", + "\n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + " print(target, \"got data\")\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " print(target, \"loaded dets\")\n", + " print(file.files)\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat\n", + "\n", + "def get_ratio_arrays(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, debug=False,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata', ssn='_ssn', \n", + " red=False, \n", + " ):\n", + " filename = path+f'/ratio_arrays_{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}{ssn}.npz'\n", + " file = np.load(filename)\n", + " if debug: print(f\"{filename}\\n{file.files}\")\n", + " xx = file['xx_params']\n", + " y0p0 = file['yy_ratio']\n", + " if red:\n", + " y1p5 = file['y1p5_ratio']\n", + " y3p0 = file['y3p0_ratio']\n", + " file.close()\n", + " if red:\n", + " return xx, y0p0, y1p5, y3p0, #y1p5, y3p0\n", + " else:\n", + " return xx, y0p0, " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + "targets = [\n", + " 'gsmf_phi0',\n", + " # 'gsmf_mchar0_log10',\n", + " # 'mmb_mamp_log10',\n", + " # 'mmb_scatter_dex',\n", + " # 'hard_time', \n", + " # 'hard_gamma_inner',\n", + " ]\n", + "ssn = '_ssn'\n", + "for target in tqdm(targets):\n", + " data, params, dsdat = get_data(target,)\n", + " xx = []\n", + " yy = []\n", + " for pp, par in enumerate(tqdm(params)):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + " np.savez(path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}{ssn}.npz',\n", + " xx_params = xx, yy_ratio=yy)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = plot.LABEL_EVDP_RATIO\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", + " 'hard_time', 'hard_gamma_inner'\n", + " ]\n", + "\n", + "col0p0 = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + " ]\n", + "\n", + "col_gw = [\n", + " 'k', 'k', \n", + " 'k', 'k', \n", + " 'k', 'k'\n", + " ]\n", + "\n", + "# set which arrays are using ssn\n", + "ssn_arr = [\n", + " '_ssn', '',\n", + " '', '',\n", + " '_ssn', '_ssn'\n", + "]\n", + "\n", + "fig, axs = plot.figax_single(\n", + " nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear', height=7)\n", + "\n", + "fig.text(0.04, 0.5, ylabel, ha='left', va='center', rotation=90)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " xx, yy = get_ratio_arrays(targets[ii], red=False, ssn=ssn_arr[ii])\n", + " ax.set_xlabel(plot.PARAM_KEYS[target])\n", + "\n", + " for pp in [50,95]:\n", + " med, *conf = np.percentile(yy, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 958c4ff1..494f65c5 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -28,6 +28,7 @@ DEF_THRESH=0.5 + ###################### Overlap Reduction Function ###################### def _gammaij_from_thetaij(theta_ij): diff --git a/holodeck/plot.py b/holodeck/plot.py index ac14345c..47b6de23 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -57,7 +57,7 @@ 'mmb_scatter_dex': r"MMB $\epsilon_{\mu}$", } -LABEL_EVDP_RATIO = r"$\langle N_\mathrm{SS} \rangle" +LABEL_EVDP_RATIO = r"$\langle N_\mathrm{SS} \rangle / \mathrm{DP}_\mathrm{BG}$" COLORS_MPL = plt.rcParams['axes.prop_cycle'].by_key()['color'] From d2de8dc45dae65f347579836d5bd44918f6f6c97 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 20:09:38 -0500 Subject: [PATCH 267/291] Rename paper plot notebooks. --- .../paper_plots/dc_vs_mt_snr_contours.ipynb | 344 ------------------ ...ynb => favg1_frequency_of_detection.ipynb} | 0 ...ratio_and_hc_varpar.ipynb => ratio1.ipynb} | 21 +- ...Wonly.ipynb => ratio2_varpar_GWonly.ipynb} | 0 ...hist.ipynb => snr1_snr_vs_mass_hist.ipynb} | 0 ...b => snr2_mass_vs_distance_contours.ipynb} | 0 ...nb => spectra1_charstrain_and_props.ipynb} | 0 ...nb => spectra2_charstrain_and_props.ipynb} | 0 ...tra_6panel.ipynb => spectra3_6panel.ipynb} | 0 9 files changed, 7 insertions(+), 358 deletions(-) delete mode 100644 ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb rename ecg-notebooks/paper_plots/{frequency_of_detection.ipynb => favg1_frequency_of_detection.ipynb} (100%) rename ecg-notebooks/paper_plots/{ratio_and_hc_varpar.ipynb => ratio1.ipynb} (98%) rename ecg-notebooks/paper_plots/{ratio_varpar_GWonly.ipynb => ratio2_varpar_GWonly.ipynb} (100%) rename ecg-notebooks/paper_plots/{snr_vs_mass_hist.ipynb => snr1_snr_vs_mass_hist.ipynb} (100%) rename ecg-notebooks/paper_plots/{snr2_mass_vs_distance.ipynb => snr2_mass_vs_distance_contours.ipynb} (100%) rename ecg-notebooks/paper_plots/{charstrain_and_props.ipynb => spectra1_charstrain_and_props.ipynb} (100%) rename ecg-notebooks/paper_plots/{new_spectra_charstrain_and_props.ipynb => spectra2_charstrain_and_props.ipynb} (100%) rename ecg-notebooks/paper_plots/{new_spectra_6panel.ipynb => spectra3_6panel.ipynb} (100%) diff --git a/ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb b/ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb deleted file mode 100644 index daaaa297..00000000 --- a/ecg-notebooks/paper_plots/dc_vs_mt_snr_contours.ipynb +++ /dev/null @@ -1,344 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "%reload_ext autoreload\n", - "%autoreload 2\n", - "from importlib import reload\n", - "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "import matplotlib.cm as cm\n", - "import matplotlib as mpl\n", - "import h5py\n", - "from tqdm import tqdm\n", - "import os\n", - "\n", - "\n", - "from holodeck import plot, detstats\n", - "import holodeck.single_sources as sings\n", - "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", - "import holodeck as holo\n", - "from holodeck.sams import sam\n", - "\n", - "import hasasia.sim as hsim\n", - "\n", - "import sys\n", - "sys.path.append('/Users/emigardiner/GWs/holodeck/ecg-notebooks/parameter_investigation')\n", - "import anatomy as anat" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", - " '''\n", - " https://stackoverflow.com/a/18926541\n", - " '''\n", - " if isinstance(cmap, str):\n", - " cmap = plt.get_cmap(cmap)\n", - " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", - " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", - " cmap(np.linspace(minval, maxval, n)))\n", - " return new_cmap\n", - "\n", - "cmap_base = 'magma_r'\n", - "magma_r = truncate_colormap(cmap_base, 0, 0.85)\n", - "blacks = truncate_colormap('binary', 0.4, 1.0)\n", - "\n", - "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", - "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", - "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", - "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)\n", - "cmap_Purples = truncate_colormap('Purples', 0.4, 1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "SHAPE = None\n", - "NREALS = 500\n", - "NFREQS = 40\n", - "NLOUDEST = 10\n", - "\n", - "BUILD_ARRAYS = False\n", - "SAVEFIG = False\n", - "TOL=0.01\n", - "MAXBADS=5\n", - "\n", - "NVARS = 21\n", - "# NVARS = 6\n", - "\n", - "NPSRS = 40\n", - "NSKIES = 100\n", - "RED_GAMMA = None\n", - "RED2WHITE = None\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def get_var_data( target, var=None, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", - "):\n", - "\n", - " path = path + f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}' \n", - " load_data_from_file = path+f'/data_params.npz' \n", - " load_dets_from_file = path+f'/detstats_s{nskies}' \n", - " if red_gamma is not None and red2white is not None:\n", - " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", - " else:\n", - " load_dets_from_file = load_dets_from_file+f'_white'\n", - " load_dets_from_file = load_dets_from_file+'.npz'\n", - "\n", - " if os.path.exists(load_data_from_file) is False:\n", - " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", - " raise Exception(err)\n", - " if os.path.exists(load_dets_from_file) is False:\n", - " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", - " raise Exception(err)\n", - " file = np.load(load_data_from_file, allow_pickle=True)\n", - " if var is not None:\n", - " data = file['data'][var]\n", - " params = file['params'][var]\n", - " else:\n", - " data = file['data']\n", - " params = file['params']\n", - "\n", - " file.close()\n", - "\n", - " file = np.load(load_dets_from_file, allow_pickle=True)\n", - " if var is not None:\n", - " dsdat = file['dsdat'][var]\n", - " else:\n", - " dsdat = file['dsdat']\n", - " file.close()\n", - "\n", - " return data, params, dsdat" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Histogram Functions" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "def hist_min_med_max(TARGET, mt_edges, dc_edges):\n", - "\n", - " # get minimum weighted histogram\n", - " VAR = 0\n", - " data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", - " par_min = params[TARGET]\n", - "\n", - " snr = dsdat['snr_ss']\n", - " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - " mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " mtt = np.swapaxes(mtt, -1, -2)\n", - " dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " dcm = np.swapaxes(dcm, -1, -2)\n", - "\n", - " hist_min, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", - " bins=(dc_edges, mt_edges), weights=snr.flatten())\n", - " \n", - " # get median weighted histogram\n", - " VAR = 10\n", - " data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", - " par_med = params[TARGET]\n", - "\n", - " snr = dsdat['snr_ss']\n", - " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - " mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " mtt = np.swapaxes(mtt, -1, -2)\n", - " dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " dcm = np.swapaxes(dcm, -1, -2)\n", - "\n", - "\n", - " hist_med, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", - " bins=(dc_edges, mt_edges), weights=snr.flatten())\n", - " \n", - " # get maximum weighted histogram\n", - " VAR = -1\n", - " data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", - " par_max = params[TARGET]\n", - "\n", - " snr = dsdat['snr_ss']\n", - " sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - " mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " mtt = np.swapaxes(mtt, -1, -2)\n", - " dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - " dcm = np.swapaxes(dcm, -1, -2)\n", - "\n", - "\n", - " hist_max, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", - " bins=(dc_edges, mt_edges), weights=snr.flatten())\n", - " \n", - " rv = dict(hist_min=hist_min, hist_med=hist_med, hist_max=hist_max, \n", - " par_min=par_min, par_med=par_med, par_max=par_max)\n", - " \n", - " return rv\n", - "\n", - "\n", - "def draw_contours(ax, TARGET, title, mt_edges=mt_edges, dc_edges=dc_edges,\n", - " levels=np.linspace(3.5,5,8), colors=None, load_from=None):\n", - " if load_from is None:\n", - " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", - " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", - " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", - " else:\n", - " rv = np.load(load_from)\n", - " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", - " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", - " rv.close()\n", - "\n", - " mt_cents = holo.utils.midpoints(mt_edges)\n", - " dc_cents= holo.utils.midpoints(dc_edges)\n", - "\n", - " if colors is None:\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_min), cmap=cmap_Greens, levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_med), cmap=cmap_Blues, levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_max), cmap=cmap_Purples, levels=levels)\n", - " else:\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_min), colors=colors[0], levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_med), colors=colors[1], levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_max), colors=colors[2], levels=levels)\n", - " # plt.colorbar(im, ax=ax, label='log$\\sum \\mathrm{SNR} (\\\\tau_\\mathrm{hard}=%.2f \\mathrm{Gyr})$' % ht_max)\n", - " \n", - " if colors is None:\n", - " colors = ['#1e8144', \"#347ebb\", '#6e56a6' ]\n", - " handles = [\n", - " mpl.lines.Line2D([0], [0], label=f\"{par_min:.2f}\", color=colors[0]),\n", - " mpl.lines.Line2D([0], [0], label=f\"{par_med:.2f}\", color=colors[1]),\n", - " mpl.lines.Line2D([0], [0], label=f\"{par_max:.2f}\", color=colors[2])\n", - " ]\n", - " return handles\n", - "\n", - "\n", - "def draw_kale_contours2d(ax, TARGET, title, mt_edges=mt_edges, dc_edges=dc_edges,\n", - " levels=np.linspace(3.5,5,8), colors=None, load_from=None):\n", - " if load_from is None:\n", - " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", - " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", - " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", - " else:\n", - " rv = np.load(load_from)\n", - " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", - " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", - " rv.close()\n", - "\n", - " mt_cents = holo.utils.midpoints(mt_edges)\n", - " dc_cents= holo.utils.midpoints(dc_edges)\n", - "\n", - " if colors is None:\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_min), cmap=cmap_Greens, levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_med), cmap=cmap_Blues, levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_max), cmap=cmap_Purples, levels=levels)\n", - " else:\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_med), colors=colors[1], levels=levels)\n", - " ax.contour(mt_cents, dc_cents, np.log10(hist_max), colors=colors[2], levels=levels)\n", - " plt.colorbar(im, ax=ax, label='log$\\sum \\mathrm{SNR} (\\\\tau_\\mathrm{hard}=%.2f \\mathrm{Gyr})$' % ht_max)\n", - " \n", - " if colors is None:\n", - " colors = ['#1e8144', \"#347ebb\", '#6e56a6' ]\n", - " handles = [\n", - " mpl.lines.Line2D([0], [0], label=f\"{par_min:.2f}\", color=colors[0]),\n", - " mpl.lines.Line2D([0], [0], label=f\"{par_med:.2f}\", color=colors[1]),\n", - " mpl.lines.Line2D([0], [0], label=f\"{par_max:.2f}\", color=colors[2])\n", - " ]\n", - " return handles" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Save all hist data" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# get edges\n", - "NBINS = 40\n", - "TAKE = 4\n", - "mt_idx_min=30 \n", - "mt_idx_max=-8\n", - "dc_edge_min=3e1\n", - "dc_edge_max=1e4\n", - "\n", - "# get edges\n", - "sam = holo.sams.Semi_Analytic_Model()\n", - "mt_edges = sam.mtot[mt_idx_min:mt_idx_max]/MSOL\n", - "dc_edges = np.geomspace(dc_edge_min, dc_edge_max, NBINS)\n", - "\n", - "targets = ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", - " 'hard_time', 'hard_gamma_inner']\n", - "\n", - "if BUILD_ARRAYS:\n", - " for TARGET in tqdm(targets):\n", - " rv = hist_min_med_max(TARGET, mt_edges=mt_edges, dc_edges=dc_edges,)\n", - " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", - " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", - " filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - " filename = filename+f'mt_dc_hist_tk{TAKE}_{TARGET}_{NBINS}bins_tk1.npz'\n", - " np.savez(filename,\n", - " hist_min=hist_min, hist_med=hist_med, hist_max=hist_max, \n", - " par_min=par_min, par_med=par_med, par_max=par_max)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "holo310", - "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.10" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/ecg-notebooks/paper_plots/frequency_of_detection.ipynb b/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/frequency_of_detection.ipynb rename to ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb diff --git a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb b/ecg-notebooks/paper_plots/ratio1.ipynb similarity index 98% rename from ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb rename to ecg-notebooks/paper_plots/ratio1.ipynb index 1998b658..e7007ad7 100644 --- a/ecg-notebooks/paper_plots/ratio_and_hc_varpar.ipynb +++ b/ecg-notebooks/paper_plots/ratio1.ipynb @@ -177,20 +177,20 @@ "metadata": {}, "outputs": [], "source": [ - "if True:\n", - "# if BUILD_ARRAYS:\n", + "# if True:\n", + "if BUILD_ARRAYS:\n", " # targets = [\n", " # 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " # 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", - " # path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " targets = [\n", " # 'gsmf_phi0',\n", " # 'gsmf_mchar0_log10', \n", " 'mmb_mamp_log10', \n", " # 'mmb_scatter_dex',\n", " ]\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' \n", - " figpath = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", + " # path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' \n", + " # figpath = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", " for target in tqdm(targets):\n", " print(target)\n", "\n", @@ -250,7 +250,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "ylabel = plot.LABEL_EVDP_RATIO\n", "targets = [\n", " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", @@ -523,7 +523,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "ylabel = plot.LABEL_EVDP_RATIO\n", "targets = [\n", " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", @@ -837,13 +837,6 @@ " savename = savename+f'/ratio_vs_var{NVARS}_rn_gw_single_68ci.png'\n", " fig.savefig(savename, dpi=100)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb b/ecg-notebooks/paper_plots/ratio2_varpar_GWonly.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/ratio_varpar_GWonly.ipynb rename to ecg-notebooks/paper_plots/ratio2_varpar_GWonly.ipynb diff --git a/ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb b/ecg-notebooks/paper_plots/snr1_snr_vs_mass_hist.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/snr_vs_mass_hist.ipynb rename to ecg-notebooks/paper_plots/snr1_snr_vs_mass_hist.ipynb diff --git a/ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb b/ecg-notebooks/paper_plots/snr2_mass_vs_distance_contours.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/snr2_mass_vs_distance.ipynb rename to ecg-notebooks/paper_plots/snr2_mass_vs_distance_contours.ipynb diff --git a/ecg-notebooks/paper_plots/charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/spectra1_charstrain_and_props.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/charstrain_and_props.ipynb rename to ecg-notebooks/paper_plots/spectra1_charstrain_and_props.ipynb diff --git a/ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb b/ecg-notebooks/paper_plots/spectra2_charstrain_and_props.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/new_spectra_charstrain_and_props.ipynb rename to ecg-notebooks/paper_plots/spectra2_charstrain_and_props.ipynb diff --git a/ecg-notebooks/paper_plots/new_spectra_6panel.ipynb b/ecg-notebooks/paper_plots/spectra3_6panel.ipynb similarity index 100% rename from ecg-notebooks/paper_plots/new_spectra_6panel.ipynb rename to ecg-notebooks/paper_plots/spectra3_6panel.ipynb From e3676f3f0fec65cbaff4c5bd1bf1356f24e4f789 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 21:30:02 -0500 Subject: [PATCH 268/291] Plot ratio for ssn with all but mmb. --- .../paper_plots/ratio3_ssnoise.ipynb | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb index a33f1aef..5ed434a0 100644 --- a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb +++ b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb @@ -120,8 +120,8 @@ "source": [ "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", "targets = [\n", - " 'gsmf_phi0',\n", - " # 'gsmf_mchar0_log10',\n", + " # 'gsmf_phi0',\n", + " 'gsmf_mchar0_log10',\n", " # 'mmb_mamp_log10',\n", " # 'mmb_scatter_dex',\n", " # 'hard_time', \n", @@ -141,13 +141,6 @@ " xx_params = xx, yy_ratio=yy)\n" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, @@ -175,13 +168,17 @@ "\n", "# set which arrays are using ssn\n", "ssn_arr = [\n", - " '_ssn', '',\n", + " '_ssn', '_ssn',\n", " '', '',\n", " '_ssn', '_ssn'\n", "]\n", "\n", + "ylims = [(1e-3, 2e1), (1e-3, 2e1), \n", + " (1e-3, 5e0), (1e-3, 5e0),\n", + " (1e-3, 9e1), (1e-3, 9e1),]\n", + "\n", "fig, axs = plot.figax_single(\n", - " nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear', height=7)\n", + " nrows=3, ncols=2, sharey=False, sharex=False, xscale='linear', height=7)\n", "\n", "fig.text(0.04, 0.5, ylabel, ha='left', va='center', rotation=90)\n", "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", @@ -190,11 +187,15 @@ "for ii, ax in enumerate(axs.flatten()):\n", " xx, yy = get_ratio_arrays(targets[ii], red=False, ssn=ssn_arr[ii])\n", " ax.set_xlabel(plot.PARAM_KEYS[target])\n", + " ax.tick_params(axis='y', which='both', right=True, left=True, direction='in')\n", "\n", " for pp in [50,95]:\n", " med, *conf = np.percentile(yy, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", - " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)" + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + " ax.set_ylim(ylims[ii])\n", + " if ii%2==1:\n", + " ax.set_yticklabels([])\n" ] }, { From 4f796685fcf3d6c7909b700a366a4bc26acf3405 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 15 Jul 2023 22:28:03 -0500 Subject: [PATCH 269/291] Adjust axes lim setup. --- .../paper_plots/ratio3_ssnoise.ipynb | 20 +++++---- .../paper_plots/spectra3_6panel.ipynb | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb index 5ed434a0..aa58820d 100644 --- a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb +++ b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb @@ -121,8 +121,8 @@ "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", "targets = [\n", " # 'gsmf_phi0',\n", - " 'gsmf_mchar0_log10',\n", - " # 'mmb_mamp_log10',\n", + " # 'gsmf_mchar0_log10',\n", + " 'mmb_mamp_log10',\n", " # 'mmb_scatter_dex',\n", " # 'hard_time', \n", " # 'hard_gamma_inner',\n", @@ -169,13 +169,19 @@ "# set which arrays are using ssn\n", "ssn_arr = [\n", " '_ssn', '_ssn',\n", - " '', '',\n", + " '_ssn', '',\n", " '_ssn', '_ssn'\n", "]\n", "\n", - "ylims = [(1e-3, 2e1), (1e-3, 2e1), \n", - " (1e-3, 5e0), (1e-3, 5e0),\n", - " (1e-3, 9e1), (1e-3, 9e1),]\n", + "ylims = np.array(\n", + " [[1.5e-3, 1.5e1], [1.5e-3, 9e0], [1.5e-3, 7e1],])\n", + "print(ylims, ylims.shape) # 3,2\n", + "ylims = np.repeat(ylims, 2).reshape(3,2,2) # 3,2,2\n", + "print(ylims, ylims.shape)\n", + "ylims = np.swapaxes(ylims, 1, 2).reshape(6,2)\n", + "print(ylims, ylims.shape)\n", + "# ylims = np.swapaxes(ylims, 0, 1).reshape(6,2)\n", + "print(ylims, ylims.shape)\n", "\n", "fig, axs = plot.figax_single(\n", " nrows=3, ncols=2, sharey=False, sharex=False, xscale='linear', height=7)\n", @@ -186,7 +192,7 @@ "\n", "for ii, ax in enumerate(axs.flatten()):\n", " xx, yy = get_ratio_arrays(targets[ii], red=False, ssn=ssn_arr[ii])\n", - " ax.set_xlabel(plot.PARAM_KEYS[target])\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " ax.tick_params(axis='y', which='both', right=True, left=True, direction='in')\n", "\n", " for pp in [50,95]:\n", diff --git a/ecg-notebooks/paper_plots/spectra3_6panel.ipynb b/ecg-notebooks/paper_plots/spectra3_6panel.ipynb index b8525b97..9fbca673 100644 --- a/ecg-notebooks/paper_plots/spectra3_6panel.ipynb +++ b/ecg-notebooks/paper_plots/spectra3_6panel.ipynb @@ -279,6 +279,48 @@ " return handles " ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def draw_tri(ax, xx, yy_ss, yy_bg, ii, colors):\n", + "\n", + " # Plot the median \n", + " handles=[]\n", + " for vv, var in enumerate(parvars): \n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=1, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", + "\n", + "\n", + " for vv, var in enumerate(parvars):\n", + " # for aa, nn in enumerate(idx):\n", + " # for ll in range(3):\n", + " # edgecolor = 'k' if ll==0 else None\n", + " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " if ii == 2:\n", + " ax.errorbar(xx, ymin, yerr=(ymin-ymin, ymed-ymin), color=colors[var], alpha=0.15, \n", + " capsize=0.5, lolims=True, marker='o', markersize=1, linestyle='')\n", + " else:\n", + " ax.errorbar(xx, ymax, yerr=(ymax-ymed, ymax-ymax), color=colors[var], alpha=0.15, \n", + " capsize=0.5, uplims=True, marker='o', markersize=1, linestyle='')\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", + " \n", + " for vv, var in enumerate(parvars):\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " \n", + " return handles " + ] + }, { "cell_type": "markdown", "metadata": {}, From d2e1178fdeb83226e20531faa625c614e3f16272 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 16 Jul 2023 00:44:56 -0500 Subject: [PATCH 270/291] New single column spectra plots separated by model component. --- .../paper_plots/spectra3_6panel.ipynb | 203 +++++++++++++----- 1 file changed, 154 insertions(+), 49 deletions(-) diff --git a/ecg-notebooks/paper_plots/spectra3_6panel.ipynb b/ecg-notebooks/paper_plots/spectra3_6panel.ipynb index 9fbca673..5a16c4d4 100644 --- a/ecg-notebooks/paper_plots/spectra3_6panel.ipynb +++ b/ecg-notebooks/paper_plots/spectra3_6panel.ipynb @@ -129,7 +129,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Save arrays" + "# Calculate and save arrays" ] }, { @@ -138,8 +138,11 @@ "metadata": {}, "outputs": [], "source": [ - "targets = ['hard_time', 'gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', \n", - " 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "targets = [\n", + " # 'hard_time', 'gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', \n", + " 'mmb_scatter_dex', \n", + " # 'hard_gamma_inner'\n", + " ]\n", "path='/Users/emigardiner/GWs/holodeck/output/anatomy_redz'\n", "NVARS = 21\n", "NSKIES = 50\n", @@ -147,12 +150,17 @@ "\n", "for TARGET in tqdm(targets):\n", " parvars = [0,5,10,15,20] \n", + " labels = []\n", " yy_ss = []\n", " yy_bg = []\n", " data, params = get_data(TARGET, nvars=NVARS, nskies=NSKIES, nreals=NREALS,\n", " path=path)\n", - " xx=data[0]['fobs_cents']*YR\n", + " fobs_cents = data[0]['fobs_cents']\n", + " xx = fobs_cents * YR\n", + "\n", " for vv, var in enumerate(parvars):\n", + " labels.append(f\"{params[var][TARGET]:.2f}\")\n", + "\n", " hc_ss = data[var]['hc_ss']\n", " hc_bg = data[var]['hc_bg']\n", "\n", @@ -173,7 +181,7 @@ " yy_bg.append(_yy_bg)\n", "\n", " save_name = path+f'/figdata/hcpar_arrays_{TARGET}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", - " np.savez(save_name, xx=xx, yy_ss=yy_ss, yy_bg=yy_bg)" + " np.savez(save_name, xx=xx, yy_ss=yy_ss, yy_bg=yy_bg, labels=labels)" ] }, { @@ -197,8 +205,9 @@ " xx = file['xx']\n", " yy_ss = file['yy_ss']\n", " yy_bg = file['yy_bg']\n", + " labels = file['labels']\n", " file.close()\n", - " return xx, yy_ss, yy_bg" + " return xx, yy_ss, yy_bg, labels" ] }, { @@ -208,6 +217,13 @@ "# Draw Functions" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### draw_95ci()" + ] + }, { "cell_type": "code", "execution_count": null, @@ -219,14 +235,14 @@ "\n", " handles=[]\n", " for vv, var in enumerate(parvars): \n", - " if var is not 5 and var is not 15:\n", + " if var != 5 and var != 15:\n", " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=1, linestyle='--')\n", " # for aa, nn in enumerate(idx):\n", " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", " handles.append(hh)\n", "\n", " for vv, var in enumerate(parvars):\n", - " if var is not 5 and var is not 15:\n", + " if var != 5 and var != 15:\n", " # Plot the loudest single sources confidence intervals\n", " for pp in [95,]:\n", " percs = pp / 2\n", @@ -237,13 +253,21 @@ " \n" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### draw_lims()" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "def draw_lims(ax, xx, yy_ss, yy_bg, ii, colors):\n", + "def draw_lims(ax, xx, yy_ss, yy_bg, ii, colors,\n", + " parvars=[0,10,20]):\n", "\n", " # Plot the median \n", " handles=[]\n", @@ -279,44 +303,55 @@ " return handles " ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### draw_tris()" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "def draw_tri(ax, xx, yy_ss, yy_bg, ii, colors):\n", + "def draw_tris(ax, xx, yy_ss, yy_bg, ii, colors, parvars=[0,5,10,15,20]):\n", + " \"\"\" Plot mins/maxes with tri symbols and 68% ci\n", + " \"\"\"\n", "\n", " # Plot the median \n", " handles=[]\n", " for vv, var in enumerate(parvars): \n", - " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=1, linestyle='--')\n", - " # for aa, nn in enumerate(idx):\n", - " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", - " handles.append(hh)\n", + " if var != 5 and var != 15:\n", + "\n", + " hh, = ax.plot(xx, np.median(yy_bg[vv][ii], axis=-1), color=colors[var], lw=1, linestyle='--')\n", + " # for aa, nn in enumerate(idx):\n", + " # ax.plot(xx, yy_bg[ii][:,nn], linestyle='-', alpha=0.75, color=colors[aa]) \n", + " handles.append(hh)\n", "\n", "\n", " for vv, var in enumerate(parvars):\n", - " # for aa, nn in enumerate(idx):\n", - " # for ll in range(3):\n", - " # edgecolor = 'k' if ll==0 else None\n", - " ymed = np.median(yy_ss[vv][ii], axis=-1)\n", - " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", - " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", - " if ii == 2:\n", - " ax.errorbar(xx, ymin, yerr=(ymin-ymin, ymed-ymin), color=colors[var], alpha=0.15, \n", - " capsize=0.5, lolims=True, marker='o', markersize=1, linestyle='')\n", - " else:\n", - " ax.errorbar(xx, ymax, yerr=(ymax-ymed, ymax-ymax), color=colors[var], alpha=0.15, \n", - " capsize=0.5, uplims=True, marker='o', markersize=1, linestyle='')\n", - " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", - " \n", + " if var != 5 and var != 15:\n", + "\n", + " if ii == 2:\n", + " ymin = np.min(yy_ss[vv][ii], axis=-1)\n", + " ax.scatter(xx, ymin, color=colors[var], alpha=0.65, \n", + " marker='2', s=10, linestyle='')\n", + " else:\n", + " ymax = np.max(yy_ss[vv][ii], axis=-1)\n", + " ax.scatter(xx, ymax, color=colors[var], alpha=0.65, \n", + " marker='1', s=10, linestyle='')\n", + " # ax.scatter(xx, ymed, marker='o', color=colors[vv], alpha=0.5, s=20)\n", + " \n", " for vv, var in enumerate(parvars):\n", - " # Plot the loudest single sources confidence intervals\n", - " for pp in [68,]:\n", - " percs = pp / 2\n", - " percs = [50 - percs, 50 + percs]\n", - " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", + " if var != 5 and var != 15:\n", + "\n", + " # Plot the loudest single sources confidence intervals\n", + " for pp in [68,]:\n", + " percs = pp / 2\n", + " percs = [50 - percs, 50 + percs]\n", + " ax.fill_between(xx, *np.percentile(yy_ss[vv][ii], percs, axis=-1), alpha=0.15, color=colors[var])\n", " \n", " return handles " ] @@ -344,24 +379,25 @@ "]\n", "\n", "ylim = [\n", - " (2e-19, 2e-13), # hc\n", - " (6.5e5, 8.5e10), # mass in Msun\n", - " (4e1, 7e3)\n", + " (2e-19, 3e-13), # hc\n", + " (6.5e5, 2e11), # mass in Msun\n", + " (3e1, 5e3)\n", "]\n", "\n", + "\n", "ylabels = ['$h_c$', '$M\\ [\\mathrm{M}_\\odot]$', '$d_c\\ [\\mathrm{Mpc}]$',]\n", "titles = ['$\\psi_0$', '$m_{\\psi,0}$', '$\\mu$', '$\\epsilon_\\mu$', \n", " '$\\\\tau_\\mathrm{hard}$', '$\\\\nu_\\mathrm{inner}$']\n", "\n", - "fig, axs = plot.figax(ncols=6, nrows=3, sharex=True, figsize=(12,4),)\n", + "fig, axs = plot.figax(ncols=6, nrows=3, sharex=True, figsize=(12,5),)\n", "fig.text(0.5,0.0, plot.LABEL_GW_FREQUENCY_YR, ha='center')\n", "for ii, ax in enumerate(axs[:,0]):\n", " ax.set_ylabel(ylabels[ii])\n", "\n", "for cc in range(6):\n", - " xx, yy_ss, yy_bg = load_hcpar_arrays(targets[cc])\n", + " xx, yy_ss, yy_bg, labels = load_hcpar_arrays(targets[cc])\n", " for rr, ax in enumerate(axs[:,cc]):\n", - " handles = draw_95ci(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", + " handles = draw_tris(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", " ax.set_ylim(ylim[rr])\n", " if cc>0:\n", " ax.set_yticklabels([])\n", @@ -373,9 +409,9 @@ " # ax.sharey(axs[rr,0])\n", "plt.subplots_adjust(hspace=0, wspace=0)\n", "\n", - "\n", "save_path = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra'\n", - "save_name = save_path+'/95ci_var3_3x6.png'\n", + "# save_name = save_path+'/95lims_var3_3x6.png'\n", + "save_name = save_path+'/trilims_var3_3x6.png'\n", "fig.savefig(save_name, dpi=300, bbox_inches='tight')" ] }, @@ -395,24 +431,24 @@ "]\n", "\n", "ylim = [\n", - " (2e-19, 3e-13), # hc\n", - " (6.5e5, 2e11), # mass in Msun\n", - " (3e1, 5e3)\n", + " (2e-19, 2e-13), # hc\n", + " (6.5e5, 8.5e10), # mass in Msun\n", + " (4e1, 7e3)\n", "]\n", "\n", "ylabels = ['$h_c$', '$M\\ [\\mathrm{M}_\\odot]$', '$d_c\\ [\\mathrm{Mpc}]$',]\n", "titles = ['$\\psi_0$', '$m_{\\psi,0}$', '$\\mu$', '$\\epsilon_\\mu$', \n", " '$\\\\tau_\\mathrm{hard}$', '$\\\\nu_\\mathrm{inner}$']\n", "\n", - "fig, axs = plot.figax(ncols=6, nrows=3, sharex=True, figsize=(12,5),)\n", + "fig, axs = plot.figax(ncols=6, nrows=3, sharex=True, figsize=(12,4),)\n", "fig.text(0.5,0.0, plot.LABEL_GW_FREQUENCY_YR, ha='center')\n", "for ii, ax in enumerate(axs[:,0]):\n", " ax.set_ylabel(ylabels[ii])\n", "\n", "for cc in range(6):\n", - " xx, yy_ss, yy_bg = load_hcpar_arrays(targets[cc])\n", + " xx, yy_ss, yy_bg, labels = load_hcpar_arrays(targets[cc])\n", " for rr, ax in enumerate(axs[:,cc]):\n", - " handles = draw_lims(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", + " handles = draw_95ci(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[cc])\n", " ax.set_ylim(ylim[rr])\n", " if cc>0:\n", " ax.set_yticklabels([])\n", @@ -426,7 +462,7 @@ "\n", "\n", "save_path = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra'\n", - "save_name = save_path+'/95lims_var3_3x6.png'\n", + "save_name = save_path+'/95ci_var3_3x6.png'\n", "fig.savefig(save_name, dpi=300, bbox_inches='tight')" ] }, @@ -467,7 +503,7 @@ "\n", "for cc in range(6):\n", " col = cc%2 # 0 or 1\n", - " xx, yy_ss, yy_bg = load_hcpar_arrays(targets[cc])\n", + " xx, yy_ss, yy_bg, labels = load_hcpar_arrays(targets[cc])\n", " for rr in range(3):\n", " row = rr + 3*int(cc/2)\n", " print(f\"{col=}, {row=}\")\n", @@ -485,6 +521,75 @@ "plt.subplots_adjust(hspace=0, wspace=0)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 3 Separate Singles" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "color_maps = [\n", + " cmap_Greens(np.linspace(0, 1, NVARS)), \n", + " cmap_Oranges(np.linspace(0, 1, NVARS)), \n", + " cmap_Blues(np.linspace(0, 1, NVARS)), \n", + "]\n", + "\n", + "ylim = [\n", + " (2e-19, 3e-13), # hc\n", + " (6.5e5, 2e11), # mass in Msun\n", + " (3e1, 5e3)\n", + "]\n", + "\n", + "\n", + "ylabels = ['$h_c$', '$M\\ [\\mathrm{M}_\\odot]$', '$d_c\\ [\\mathrm{Mpc}]$',]\n", + "names = ['gsmf', 'mmb', 'hard']\n", + "\n", + "for tt, targets in enumerate(\n", + " [['gsmf_phi0', 'gsmf_mchar0_log10'],\n", + " ['mmb_mamp_log10', 'mmb_scatter_dex'],\n", + " ['hard_time', 'hard_gamma_inner']]):\n", + " fig, axs = plot.figax_single(ncols=2, nrows=3, sharex=True, height=5.5)\n", + " fig.text(0.5,0.06, plot.LABEL_GW_FREQUENCY_YR, ha='center')\n", + " for ii, ax in enumerate(axs[:,0]):\n", + " ax.set_ylabel(ylabels[ii])\n", + " for cc, target in enumerate(targets):\n", + " xx, yy_ss, yy_bg, labels = load_hcpar_arrays(targets[cc])\n", + " print(labels)\n", + " for rr, ax in enumerate(axs[:,cc]):\n", + " handles = draw_tris(ax, xx, yy_ss, yy_bg, ii=rr, colors=color_maps[tt])\n", + " ax.tick_params(axis='y', which='both', right=True, left=True, direction='in')\n", + " ax.tick_params(axis='x', which='both', top=True, direction='in')\n", + "\n", + " # ax.set_ylim(ylim[rr])\n", + " if cc>0:\n", + " ylim0 = axs[rr,0].get_ylim()\n", + " ax.set_ylim(ylim0)\n", + " ax.set_yticklabels([])\n", + "\n", + "\n", + " # set legend\n", + " labels = [labels[0], labels[2], labels[4]]\n", + " axs[0,cc].legend(\n", + " handles=handles, labels=labels, \n", + " bbox_to_anchor=(0.5,1.02), bbox_transform=axs[0,cc].transAxes, \n", + " loc='lower center', ncols=len(parvars), title=plot.PARAM_KEYS[target],\n", + " borderpad=0.1, title_fontsize=12, labelspacing=0.25, handlelength=1.5, \n", + " handletextpad=0.3, columnspacing=0.5, frameon=False )\n", + " # ax.sharey(axs[rr,0])\n", + " plt.subplots_adjust(hspace=0, wspace=0)\n", + "\n", + " save_path = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/new_spectra'\n", + " save_name = save_path+f'/trilims_{names[tt]}.png'\n", + " fig.savefig(save_name, dpi=300, bbox_inches='tight')" + ] + }, { "cell_type": "markdown", "metadata": {}, From 412577f67f27ecb42120b86dc30e9744e07f0f74 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 16 Jul 2023 16:32:22 -0500 Subject: [PATCH 271/291] Update dpratio label in plot.py and ratio figures. --- ecg-notebooks/paper_plots/ratio1.ipynb | 8 ++++---- ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb | 2 +- holodeck/plot.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ecg-notebooks/paper_plots/ratio1.ipynb b/ecg-notebooks/paper_plots/ratio1.ipynb index e7007ad7..4944062d 100644 --- a/ecg-notebooks/paper_plots/ratio1.ipynb +++ b/ecg-notebooks/paper_plots/ratio1.ipynb @@ -250,7 +250,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = plot.LABEL_EVDP_RATIO\n", + "ylabel = plot.LABEL_DPRATIO\n", "targets = [\n", " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", @@ -348,7 +348,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = '$EV_\\mathrm{SS} / DP_\\mathrm{BG}$'\n", + "ylabel = plot.LABEL_DPRATIO\n", "targets = [\n", " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", @@ -437,7 +437,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "ylabel = plot.LABEL_DPRATIO\n", "targets = [\n", " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", @@ -740,7 +740,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "ylabel = plot.LABEL_DPRATIO\n", "targets = [\n", " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", diff --git a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb index aa58820d..d82d96bb 100644 --- a/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb +++ b/ecg-notebooks/paper_plots/ratio3_ssnoise.ipynb @@ -147,7 +147,7 @@ "metadata": {}, "outputs": [], "source": [ - "ylabel = plot.LABEL_EVDP_RATIO\n", + "ylabel = plot.LABEL_DPRATIO\n", "targets = [\n", " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", " 'mmb_mamp_log10', 'mmb_scatter_dex', \n", diff --git a/holodeck/plot.py b/holodeck/plot.py index 47b6de23..423f9795 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -57,7 +57,7 @@ 'mmb_scatter_dex': r"MMB $\epsilon_{\mu}$", } -LABEL_EVDP_RATIO = r"$\langle N_\mathrm{SS} \rangle / \mathrm{DP}_\mathrm{BG}$" +LABEL_DPRATIO = r"$\langle N_\mathrm{SS} \rangle / \mathrm{DP}_\mathrm{BG}$" COLORS_MPL = plt.rcParams['axes.prop_cycle'].by_key()['color'] From d77c17165465de4acc3d71018b8fcb8061e23b49 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 16 Jul 2023 23:49:52 -0500 Subject: [PATCH 272/291] Make simple ss_demo notebook. --- ecg-notebooks/single_sources/ss_demo.ipynb | 130 +++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 ecg-notebooks/single_sources/ss_demo.ipynb diff --git a/ecg-notebooks/single_sources/ss_demo.ipynb b/ecg-notebooks/single_sources/ss_demo.ipynb new file mode 100644 index 00000000..b8bac14d --- /dev/null +++ b/ecg-notebooks/single_sources/ss_demo.ipynb @@ -0,0 +1,130 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %load ../init.ipy\n", + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import holodeck as holo\n", + "from holodeck import plot, utils" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Build Semi-Analytic Model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# SHAPE = None # default shape, if None, is 91,81,101.\n", + "SHAPE = 40 # make this smaller to run faster, for debugging\n", + "\n", + "# get PTA frequencies\n", + "fobs_gw_cents, fobs_gw_edges = utils.pta_freqs()\n", + "\n", + "# build Semi-Analytic Model\n", + "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE) " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate SS and GWB strain with sam.gwb()\n", + "This function calls single_sources.ss_gws_redz()\n", + "## using Hard_GW" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# uncomment one of the following hardening models\n", + "\n", + "# # GW only hardening\n", + "hard=holo.hardening.Hard_GW()\n", + "\n", + "# # Fixed Time (phenomenological) hardening\n", + "# hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "\n", + "assert isinstance(hard, (holo.hardening.Fixed_Time_2PL_SAM, holo.hardening.Hard_GW))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NREALS = 30 # Set the number of strain realizations\n", + "NLOUDEST = 1000 # set the number of loudest single sources to distinguish at each frequency" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# calculate the characteristic strain of the single sources and background\n", + "# hc_ss is shape [F,R,L] = [nfrequencies, nreals, nloudest], and gives the \n", + "# characteristic strain of each individual loudest source\n", + "# hc_bg is shape [F,R] and gives the char strain from all other sources at each frequency\n", + "hc_ss, hc_bg, = sam.gwb(fobs_gw_edges, hard=hard, \n", + " realize = NREALS, loudest = NLOUDEST)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig = plot.plot_bg_ss(fobs_gw_cents, hc_bg, hc_ss[:,:,:100]) # just plot 100 loudest" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + }, + "vscode": { + "interpreter": { + "hash": "b691867a38f678e88325b7be712686862775b0bc37454cc33917ba725d804d99" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From ac9d6db711ecfda8674f70e362b8940fff803e6a Mon Sep 17 00:00:00 2001 From: Emiko Date: Sun, 16 Jul 2023 23:50:25 -0500 Subject: [PATCH 273/291] Add background to snr plots, but something's wrong with hard_gamma_inner. --- ecg-notebooks/paper_plots/ratio1.ipynb | 5 + ecg-notebooks/paper_plots/snr3_kale_bg.ipynb | 1189 ++++++++++++++++++ 2 files changed, 1194 insertions(+) create mode 100644 ecg-notebooks/paper_plots/snr3_kale_bg.ipynb diff --git a/ecg-notebooks/paper_plots/ratio1.ipynb b/ecg-notebooks/paper_plots/ratio1.ipynb index 4944062d..32b777e1 100644 --- a/ecg-notebooks/paper_plots/ratio1.ipynb +++ b/ecg-notebooks/paper_plots/ratio1.ipynb @@ -721,6 +721,11 @@ "# Red Noise, GW, Single" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, { "cell_type": "code", "execution_count": null, diff --git a/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb b/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb new file mode 100644 index 00000000..4ac05ef6 --- /dev/null +++ b/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb @@ -0,0 +1,1189 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import matplotlib as mpl\n", + "import h5py\n", + "from tqdm import tqdm\n", + "import os\n", + "import kalepy as kale\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC, GYR, PC\n", + "import holodeck as holo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fobs_cents, fobs_edges = holo.utils.pta_freqs()\n", + "cad = 1.0/(2*fobs_cents[-1])\n", + "print(cad/YR)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def truncate_colormap(cmap, minval=0.0, maxval=1.0, n=100):\n", + " '''\n", + " https://stackoverflow.com/a/18926541\n", + " '''\n", + " if isinstance(cmap, str):\n", + " cmap = plt.get_cmap(cmap)\n", + " new_cmap = mpl.colors.LinearSegmentedColormap.from_list(\n", + " 'trunc({n},{a:.2f},{b:.2f})'.format(n=cmap.name, a=minval, b=maxval),\n", + " cmap(np.linspace(minval, maxval, n)))\n", + " return new_cmap\n", + "\n", + "cmap_base = 'magma_r'\n", + "magma_r = truncate_colormap(cmap_base, 0, 0.85)\n", + "blacks = truncate_colormap('binary', 0.4, 1.0)\n", + "\n", + "cmap_Blues = truncate_colormap('Blues', 0.4, 1)\n", + "cmap_PuBuGn = truncate_colormap('PuBuGn', 0.2, 1)\n", + "cmap_Greens = truncate_colormap('Greens', 0.4, 1)\n", + "cmap_Oranges = truncate_colormap('Oranges', 0.4, 1)\n", + "cmap_Purples = truncate_colormap('Purples', 0.4, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = False\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "RED_GAMMA = None\n", + "RED2WHITE = None\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_var_data( target, var=None, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + "\n", + " path = path + f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}' \n", + " load_data_from_file = path+f'/data_params.npz' \n", + " load_dets_from_file = path+f'/detstats_s{nskies}_ssn' \n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " if var is not None:\n", + " data = file['data'][var]\n", + " params = file['params'][var]\n", + " else:\n", + " data = file['data']\n", + " params = file['params']\n", + "\n", + " file.close()\n", + "\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " if var is not None:\n", + " dsdat = file['dsdat'][var]\n", + " else:\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Edges" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # get edges\n", + "# NBINS = 40\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[25:-15]/MSOL\n", + "# dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Get Hist Data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TARGET = 'hard_time'\n", + "# var = None\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=0, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + "# print(params)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# TARGET = 'hard_time'\n", + "# hist_mt = []\n", + "# hist_dc = []\n", + "# bghist_mt = []\n", + "# bghist_dc = []\n", + "\n", + "# for var in [0,-1]:\n", + "# data, params, dsdat = get_var_data(target=TARGET, var=var, nskies=NSKIES, nvars=NVARS,\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + "\n", + "# sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "# bgpar = data['bgpar']\n", + "\n", + "# # total mass\n", + "# _ssmtt = sspar[0]/MSOL\n", + "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", + "\n", + "# _bgmtt = bgpar[0]/MSOL # F,R\n", + "# print(f\"{_bgmtt.shape=}\")\n", + "\n", + "# # comoving distance\n", + "# _ssdcm = sspar[4]/MPC\n", + "# _ssdcm = np.repeat(_ssdcm, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# _ssdcm = np.swapaxes(_ssdcm, -2, -1)\n", + "\n", + "# _bgdcm = bgpar[4]/MPC\n", + "\n", + "# # snr\n", + "# _snssi = dsdat['snr_ss']\n", + "# _snrbg = dsdat['snr_bg']\n", + "# _snrbg = np.repeat(_snrbg, NFREQS).reshape(NREALS, NFREQS)\n", + "# _snrbg = np.swapaxes(_snrbg, 0, 1)\n", + " \n", + "\n", + "# # get total mass histograms\n", + "# _hist_mt, sne, mte, = np.histogram2d(\n", + "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# hist_mt.append(_hist_mt)\n", + "\n", + "# _bghist_mt, sne, mte, = np.histogram2d(\n", + "# _snrbg.flatten(), _bgmtt.flatten(), bins=(sn_edges, mt_edges))\n", + "# bghist_mt.append(_bghist_mt)\n", + "\n", + "# # get comoving distance histograms\n", + "# _hist_dc, sne, dce, = np.histogram2d(\n", + "# _snssi.flatten(), _ssdcm.flatten(), bins=(sn_edges, dc_edges))\n", + "# hist_dc.append(_hist_dc)\n", + "\n", + "# _bghist_dc, sne, dce = np.histogram2d(\n", + "# _snrbg.flatten(), _bgdcm.flatten(), bins=(sn_edges, dc_edges))\n", + "# bghist_dc.append(_bghist_dc)\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Try AGAIN" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# # get edges\n", + "# NBINS = 20\n", + "# sam = holo.sams.Semi_Analytic_Model()\n", + "# mt_edges = sam.mtot[25:-15]/MSOL\n", + "# dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", + "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", + "\n", + "# dcgrid, mtgrid, = np.meshgrid(dc_edges, mt_edges, )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# snr = dsdat['snr_ss']\n", + "# sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "# mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# mtt = np.swapaxes(mtt, -1, -2)\n", + "# dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "# dcm = np.swapaxes(dcm, -1, -2)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# snr_grid = np.zeros((len(mt_edges)-1, len(dc_edges)-1))\n", + "# sum_grid = np.zeros_like(snr_grid)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# print(snr_grid.shape)\n", + "# print(mtt.shape, dcm.shape, snr.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# for mm in range(len(mt_edges)-1):\n", + "# # inmass = np.where(np.logical_and(mtt>mt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcm Date: Mon, 17 Jul 2023 00:14:10 -0500 Subject: [PATCH 274/291] Add markdwon. --- ecg-notebooks/single_sources/ss_demo.ipynb | 36 +++++++++++++++++----- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/single_sources/ss_demo.ipynb b/ecg-notebooks/single_sources/ss_demo.ipynb index b8bac14d..9accbb1d 100644 --- a/ecg-notebooks/single_sources/ss_demo.ipynb +++ b/ecg-notebooks/single_sources/ss_demo.ipynb @@ -21,7 +21,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Build Semi-Analytic Model" + "# Build Semi-Analytic Model, sam\n", + "Select a shape (smaller for speed, larger for accuracy, best with None) and use defaults for all other parameters (GSMF, GMT, MMbulge) in sam" ] }, { @@ -46,8 +47,9 @@ "metadata": {}, "source": [ "# Calculate SS and GWB strain with sam.gwb()\n", - "This function calls single_sources.ss_gws_redz()\n", - "## using Hard_GW" + "This function calls single_sources.ss_gws_redz().\n", + "\n", + "### Choose a hardening model" ] }, { @@ -67,6 +69,13 @@ "assert isinstance(hard, (holo.hardening.Fixed_Time_2PL_SAM, holo.hardening.Hard_GW))" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Set the number of realizations and loudest sources" + ] + }, { "cell_type": "code", "execution_count": null, @@ -77,20 +86,33 @@ "NLOUDEST = 1000 # set the number of loudest single sources to distinguish at each frequency" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Calculate the characteristic strain of the single sources and background\n", + "* hc_ss is shape [F,R,L] = [nfrequencies, nreals, nloudest], and gives the characteristic strain of each individual loudest source\n", + "* hc_bg is shape [F,R] and gives the sum of the char strain from all other sources at each frequency" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "# calculate the characteristic strain of the single sources and background\n", - "# hc_ss is shape [F,R,L] = [nfrequencies, nreals, nloudest], and gives the \n", - "# characteristic strain of each individual loudest source\n", - "# hc_bg is shape [F,R] and gives the char strain from all other sources at each frequency\n", + "\n", "hc_ss, hc_bg, = sam.gwb(fobs_gw_edges, hard=hard, \n", " realize = NREALS, loudest = NLOUDEST)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot" + ] + }, { "cell_type": "code", "execution_count": null, From 49105ca0f418fd9d4093903cdf1eee5b123f4090 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 17 Jul 2023 12:27:44 -0500 Subject: [PATCH 275/291] Exclude the 1st loudest single source as a noise source for the background. --- holodeck/detstats.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 494f65c5..2ff87f25 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -897,7 +897,8 @@ def _Sh_rest_noise(hc_ss, hc_bg, freqs): def _Sh_ss_noise(hc_ss, freqs): - """ Calculate the noise spectral density contribution from all single sources. + """ Calculate the noise spectral density contribution from all but the first loudest + single sources. Parameters ---------- @@ -917,7 +918,7 @@ def _Sh_ss_noise(hc_ss, freqs): """ # sum of noise from all loudest single sources - hc2_ss = np.sum(hc_ss**2, axis=2) # (F,R) + hc2_ss = np.sum(hc_ss[...,1:]**2, axis=2) # (F,R) Sh_ss = hc2_ss / freqs[:,np.newaxis]**3 /(12 * np.pi**2) # (F,R,) return Sh_ss From 790fed22d0ea0d938f43dea3adacda00de7df24b Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 17 Jul 2023 12:32:29 -0500 Subject: [PATCH 276/291] only print time per realization every 100. --- holodeck/detstats.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 2ff87f25..37d53c8b 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2312,7 +2312,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, for rr in range(nreals): if debug: now = datetime.now() - if (rr%10==0): + if (rr%100==99): print(f"{rr=}, {now-real_dur} s per realization, {_sigmin=:.2e}, {_sigmax=:.2e}, {_sigstart=:.2e}") real_dur = now From a4d432fe817c1b2b19aa63e04b71ffb30412020c Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 17 Jul 2023 12:33:37 -0500 Subject: [PATCH 277/291] Update to print actual average time over 100 realizations --- holodeck/detstats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 37d53c8b..0eacbe70 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -2313,8 +2313,8 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, if debug: now = datetime.now() if (rr%100==99): - print(f"{rr=}, {now-real_dur} s per realization, {_sigmin=:.2e}, {_sigmax=:.2e}, {_sigstart=:.2e}") - real_dur = now + print(f"{rr=}, {(now-real_dur)/100} s per realization, {_sigmin=:.2e}, {_sigmax=:.2e}, {_sigstart=:.2e}") + real_dur = now # get calibrated psrs psrs, red_amp, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], hc_ss[:,rr,:], fobs_cents, npsrs, tol=tol, maxbads=maxbads, From 1d9583008156995c115a9d80069f2553a79687c2 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 17 Jul 2023 14:24:16 -0500 Subject: [PATCH 278/291] Clean up snr3 notebooks --- ecg-notebooks/paper_plots/snr3_kale_bg.ipynb | 565 +------------------ 1 file changed, 12 insertions(+), 553 deletions(-) diff --git a/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb b/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb index 4ac05ef6..8e47280b 100644 --- a/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb +++ b/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb @@ -136,555 +136,6 @@ " return data, params, dsdat" ] }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Get Edges" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# # get edges\n", - "# NBINS = 40\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[25:-15]/MSOL\n", - "# dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Get Hist Data" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# TARGET = 'hard_time'\n", - "# var = None\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=0, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", - "# print(params)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# TARGET = 'hard_time'\n", - "# hist_mt = []\n", - "# hist_dc = []\n", - "# bghist_mt = []\n", - "# bghist_dc = []\n", - "\n", - "# for var in [0,-1]:\n", - "# data, params, dsdat = get_var_data(target=TARGET, var=var, nskies=NSKIES, nvars=NVARS,\n", - "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", - "\n", - "# sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - "# bgpar = data['bgpar']\n", - "\n", - "# # total mass\n", - "# _ssmtt = sspar[0]/MSOL\n", - "# _ssmtt = np.repeat(_ssmtt, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssmtt = np.swapaxes(_ssmtt, -2, -1)\n", - "\n", - "# _bgmtt = bgpar[0]/MSOL # F,R\n", - "# print(f\"{_bgmtt.shape=}\")\n", - "\n", - "# # comoving distance\n", - "# _ssdcm = sspar[4]/MPC\n", - "# _ssdcm = np.repeat(_ssdcm, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# _ssdcm = np.swapaxes(_ssdcm, -2, -1)\n", - "\n", - "# _bgdcm = bgpar[4]/MPC\n", - "\n", - "# # snr\n", - "# _snssi = dsdat['snr_ss']\n", - "# _snrbg = dsdat['snr_bg']\n", - "# _snrbg = np.repeat(_snrbg, NFREQS).reshape(NREALS, NFREQS)\n", - "# _snrbg = np.swapaxes(_snrbg, 0, 1)\n", - " \n", - "\n", - "# # get total mass histograms\n", - "# _hist_mt, sne, mte, = np.histogram2d(\n", - "# _snssi.flatten(), _ssmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# hist_mt.append(_hist_mt)\n", - "\n", - "# _bghist_mt, sne, mte, = np.histogram2d(\n", - "# _snrbg.flatten(), _bgmtt.flatten(), bins=(sn_edges, mt_edges))\n", - "# bghist_mt.append(_bghist_mt)\n", - "\n", - "# # get comoving distance histograms\n", - "# _hist_dc, sne, dce, = np.histogram2d(\n", - "# _snssi.flatten(), _ssdcm.flatten(), bins=(sn_edges, dc_edges))\n", - "# hist_dc.append(_hist_dc)\n", - "\n", - "# _bghist_dc, sne, dce = np.histogram2d(\n", - "# _snrbg.flatten(), _bgdcm.flatten(), bins=(sn_edges, dc_edges))\n", - "# bghist_dc.append(_bghist_dc)\n" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Try AGAIN" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# # get edges\n", - "# NBINS = 20\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[25:-15]/MSOL\n", - "# dc_edges = np.geomspace(1e1, 1e4, NBINS)\n", - "# sn_edges = np.geomspace(2.e-6,515, NBINS)\n", - "\n", - "# dcgrid, mtgrid, = np.meshgrid(dc_edges, mt_edges, )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# snr = dsdat['snr_ss']\n", - "# sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", - "# mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# mtt = np.swapaxes(mtt, -1, -2)\n", - "# dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", - "# dcm = np.swapaxes(dcm, -1, -2)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# snr_grid = np.zeros((len(mt_edges)-1, len(dc_edges)-1))\n", - "# sum_grid = np.zeros_like(snr_grid)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# print(snr_grid.shape)\n", - "# print(mtt.shape, dcm.shape, snr.shape)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# for mm in range(len(mt_edges)-1):\n", - "# # inmass = np.where(np.logical_and(mtt>mt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcmmt_edges[0], mttmt_edges[mm], mttdc_edges[dd], dcm Date: Mon, 17 Jul 2023 15:11:28 -0500 Subject: [PATCH 279/291] Make ssn optional with ss_noise flag. --- holodeck/detstats.py | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/holodeck/detstats.py b/holodeck/detstats.py index 0eacbe70..78e40543 100644 --- a/holodeck/detstats.py +++ b/holodeck/detstats.py @@ -489,7 +489,7 @@ def detect_bg(thetas, phis, sigmas, fobs, cad, hc_bg, alpha_0=0.001, ret = False def detect_bg_pta(pulsars, fobs, hc_bg, hc_ss, alpha_0=0.001, ret_snr = False, - red_amp=None, red_gamma=None, ): + red_amp=None, red_gamma=None, ss_noise=True): """ Calculate the background detection probability, and all the intermediary steps from a list of hasasia.Pulsar objects. @@ -547,7 +547,9 @@ def detect_bg_pta(pulsars, fobs, hc_bg, hc_ss, alpha_0=0.001, ret_snr = False, noise = noise + red_noise # (P,F,) # add single source noise - noise = noise[:,:,np.newaxis] + _Sh_ss_noise(hc_ss, fobs) # (P, F, R) + noise = noise[:,:,np.newaxis] + if ss_noise: + noise = noise + _Sh_ss_noise(hc_ss, fobs) # (P, F, R) mu_1B = _mean1_Bstatistic(noise, Gamma, Sh_bg, Sh0_bg) @@ -1774,7 +1776,7 @@ def detect_lib(hdf_name, output_dir, npsrs, sigma, nskies, thresh=DEF_THRESH, def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, plot=True, debug=False, grid_path=GAMMA_RHO_GRID_PATH, - snr_cython = True, save_ssi=False, ret_dict=False): + snr_cython = True, save_ssi=False, ret_dict=False, ss_noise=True): """ Calculate detection statistics for an ss library output. Parameters @@ -1801,6 +1803,8 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, Whether to use cython interpolation for ss snr calculation. save_ssi : Bool Whether to store gamma_ssi in npz arrays + ss_noise : Bool + Whether or not to use all but loudest SS as BG noise sources. Returns ------- @@ -1899,7 +1903,7 @@ def detect_lib_clbrt_pta(hdf_name, output_dir, npsrs, nskies, thresh=DEF_THRESH, # use sigmin and sigmax from previous realization, # unless it's the first realization of the sample psrs, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[nn,:,rr], fobs, npsrs, tol=tol, maxbads=maxbads, - sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True) + sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, ss_noise=ss_noise) _sigmin /= 2 _sigmax *= 2 @@ -2276,7 +2280,7 @@ def detect_pspace_model(fobs_cents, hc_ss, hc_bg, def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, tol=0.01, maxbads=5, thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, - red_amp=None, red_gamma=None, red2white = None): + red_amp=None, red_gamma=None, red2white=None, ss_noise=True): """ Detect pspace model using individual sigma calibration for each realization Parameters @@ -2319,7 +2323,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, # get calibrated psrs psrs, red_amp, _sigstart, _sigmin, _sigmax = calibrate_one_pta(hc_bg[:,rr], hc_ss[:,rr,:], fobs_cents, npsrs, tol=tol, maxbads=maxbads, sigstart=_sigstart, sigmin=_sigmin, sigmax=_sigmax, debug=debug, ret_sig=True, - red_amp=red_amp, red_gamma=red_gamma, red2white=red2white) + red_amp=red_amp, red_gamma=red_gamma, red2white=red2white, ss_noise=ss_noise) _sigmin /= 2 _sigmax *= 2 + 2e-20 # >1e-20 to make sure it doesnt immediately fail the 0 check @@ -2358,7 +2362,7 @@ def detect_pspace_model_clbrt_pta(fobs_cents, hc_ss, hc_bg, npsrs, nskies, def detect_pspace_model_clbrt_ramp(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigma, rampstart=1e-16, rampmin=1e-20, rampmax=1e-13, tol=0.01, maxbads=5, thresh=DEF_THRESH, debug=False, save_snr_ss=False, save_gamma_ssi=True, - red_amp=None, red_gamma=None): + red_amp=None, red_gamma=None, ss_noise=True): """ Detect pspace model using individual red noise amplitude calibration for each realization NOTE: Not supported, not updated for including single sources as noise for BG. @@ -2402,7 +2406,7 @@ def detect_pspace_model_clbrt_ramp(fobs_cents, hc_ss, hc_bg, npsrs, nskies, sigm ramp, _rampmin, _rampmax = calibrate_one_ramp(hc_bg[:,rr], fobs_cents, psrs, tol=tol, maxbads=maxbads, rampstart=_rampstart, rampmin=_rampmin, rampmax=_rampmax, debug=debug, - rgam=red_gamma,) + rgam=red_gamma, ss_noise=ss_noise) _rampstart = ramp _rampmin /= 2 _rampmax *= 2 + 2e-50 # >1e-20 to make sure it doesnt immediately fail the 0 check @@ -2535,7 +2539,7 @@ def _get_dpbg(hc_bg, npsrs, sigma, trials, fobs, dur, cad,): return avg_dp, std_dp def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, - sig_start = 1e-6, sig_min=1e-9, sig_max=1e-4, debug=False): + sig_start=1e-6, sig_min=1e-9, sig_max=1e-4, debug=False): """ Calibrate the PTA independently for each background realizations Parameters @@ -2570,7 +2574,8 @@ def calibrate_all_sigma(hc_bg, fobs, npsrs, maxtrials, def calibrate_one_pta(hc_bg, hc_ss, fobs, npsrs, sigstart=1e-6, sigmin=1e-9, sigmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None, ret_sig = False, red_amp=None, red_gamma=None, red2white=None): + phis=None, thetas=None, ret_sig = False, red_amp=None, red_gamma=None, red2white=None, + ss_noise=True): """ Calibrate the specific PTA for a given realization, and return that PTA Parameters @@ -2611,7 +2616,7 @@ def calibrate_one_pta(hc_bg, hc_ss, fobs, npsrs, psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], - red_amp=red_amp, red_gamma=red_gamma)[0] + red_amp=red_amp, red_gamma=red_gamma, ss_noise=ss_noise)[0] nclose=0 # number of attempts close to 0.5, could be stuck close nfar=0 # number of attempts far from 0.5, could be stuck far @@ -2624,7 +2629,7 @@ def calibrate_one_pta(hc_bg, hc_ss, fobs, npsrs, psrs = hsim.sim_pta(timespan=dur/YR, cad=1/(cad/YR), sigma=sigma, phi=phis, theta=thetas) dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], - red_amp=red_amp, red_gamma=red_gamma)[0] + red_amp=red_amp, red_gamma=red_gamma, ss_noise=ss_noise)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): @@ -2675,7 +2680,7 @@ def calibrate_one_pta(hc_bg, hc_ss, fobs, npsrs, def calibrate_one_ramp(hc_bg, hc_ss, fobs, psrs, rampstart=1e-6, rampmin=1e-9, rampmax=1e-4, debug=False, maxbads=20, tol=0.03, - phis=None, thetas=None, rgam=-1.5): + phis=None, thetas=None, rgam=-1.5, ss_noise=True): """ Calibrate the red noise amplitude, for a given realization, and return that PTA Parameters @@ -2709,7 +2714,7 @@ def calibrate_one_ramp(hc_bg, hc_ss, fobs, psrs, # randomize pulsar positions ramp = rampstart dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], - red_amp=rgam, red_gamma=ramp)[0] + red_amp=rgam, red_gamma=ramp, ss_noise=ss_noise)[0] nclose=0 # number of attempts close to 0.5, could be stuck close nfar=0 # number of attempts far from 0.5, could be stuck far @@ -2718,7 +2723,7 @@ def calibrate_one_ramp(hc_bg, hc_ss, fobs, psrs, while np.abs(dp_bg-0.50)>tol: ramp = np.mean([rampmin, rampmax]) # a weighted average would be better dp_bg = detect_bg_pta(psrs, fobs, hc_bg=hc_bg[:,np.newaxis], hc_ss=hc_ss[:,np.newaxis,:], - red_amp=ramp, red_gamma=rgam)[0] + red_amp=ramp, red_gamma=rgam, ss_noise=ss_noise)[0] # if debug: print(f"{dp_bg=}") if (dp_bg < (0.5-tol)) or (dp_bg > (0.5+tol)): From ebbc1fe15517e56dd5ffd4b046b4c148a3b88dac Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 17 Jul 2023 20:55:30 -0500 Subject: [PATCH 280/291] update detect_model to have option of no ssn. --- .../parameter_investigation/detect_model_clbrt_pta.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py index c03c019e..d70c8582 100644 --- a/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py +++ b/ecg-notebooks/parameter_investigation/detect_model_clbrt_pta.py @@ -64,6 +64,8 @@ def _setup_argparse(): help='Red noise gamma') parser.add_argument('--red2white', action='store', dest='red2white', type=float, default=DEF_RED2WHITE, help='Red noise amplitude to white noise amplitude ratio.') + parser.add_argument('--ssn', action='store_true', dest='ss_noise', default=False, + help='Whether or not to use single sources as a noise source in background calculations.') # I AM WORKING ON ADDING SSN OPTION # pta calibration settings parser.add_argument('--sigstart', action='store', dest='sigstart', type=float, default=1e-7, @@ -174,7 +176,8 @@ def main(): else: save_data_to_file = args.save_file - save_dets_to_file = output_path+f'/detstats_s{args.nskies}_ssn' + save_dets_to_file = output_path+f'/detstats_s{args.nskies}' + if args.ss_noise: save_dets_to_file = save_dets_to_file+'_ssn' if args.red2white is not None and args.red_gamma is not None: save_dets_to_file = save_dets_to_file+f'_r2w{args.red2white:.1f}_rg{args.red_gamma:.1f}' elif args.red_amp is not None and args.red_gamma is not None: @@ -216,7 +219,8 @@ def main(): _dsdat = detstats.detect_pspace_model_clbrt_pta( fobs_cents, hc_ss, hc_bg, args.npsrs, args.nskies, sigstart=args.sigstart, sigmin=args.sigmin, sigmax=args.sigmax, tol=args.tol, maxbads=args.maxbads, - thresh=args.thresh, debug=args.debug, red_amp=args.red_amp, red_gamma=args.red_gamma, red2white=args.red2white) + thresh=args.thresh, debug=args.debug, ss_noise=args.ss_noise, + red_amp=args.red_amp, red_gamma=args.red_gamma, red2white=args.red2white) dsdat.append(_dsdat) np.savez(save_dets_to_file+'.npz', dsdat=dsdat, red_amp=args.red_amp, red_gamma=args.red_gamma, npsrs=args.npsrs, red2white=args.red2white) # overwrite else: From bf1fad1d29fbc1d3c44e1410f0282a8cae4874c7 Mon Sep 17 00:00:00 2001 From: Emiko Date: Mon, 17 Jul 2023 20:56:12 -0500 Subject: [PATCH 281/291] Look at hard_gamma_inner snr histogram with ssn. --- ecg-notebooks/paper_plots/snr3_kale_bg.ipynb | 273 +++++++++++-------- 1 file changed, 165 insertions(+), 108 deletions(-) diff --git a/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb b/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb index 8e47280b..ac21f25f 100644 --- a/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb +++ b/ecg-notebooks/paper_plots/snr3_kale_bg.ipynb @@ -136,6 +136,167 @@ " return data, params, dsdat" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# hard_gamma_inner" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner'\n", + "VAR=-1\n", + "data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + "par_max = params[TARGET]\n", + "\n", + "# single sources\n", + "snr = dsdat['snr_ss']\n", + "sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "mtt = np.swapaxes(mtt, -1, -2)\n", + "dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "dcm = np.swapaxes(dcm, -1, -2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(snr), snr.shape)\n", + "print(holo.utils.stats(mtt), mtt.shape)\n", + "print(holo.utils.stats(dcm), dcm.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, axs = plot.figax(sharey=True, ncols=2\n", + ")\n", + "ax = axs[0]\n", + "ax.set_xlabel('Mass')\n", + "ax.set_ylabel('SNR')\n", + "ax.scatter(mtt, snr, s=1, alpha=0.5)\n", + "\n", + "ax = axs[1]\n", + "ax.set_xlabel('Distance')\n", + "ax.scatter(dcm, snr, s=1, alpha=0.5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='mass (msun)', ylabel='distance (Mpc)')\n", + "im = ax.scatter(mtt.flatten(), dcm.flatten(), c=snr, s=1, alpha=0.5)\n", + "cbar = plt.colorbar(im, ax=ax)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel = 'SNR')\n", + "ax.scatter(snr.flatten(), mtt.flatten(), color='tab:blue', alpha=0.5, s=1)\n", + "ax.set_ylabel('Mass', color='tab:blue')\n", + "\n", + "ax2 = ax.twinx()\n", + "ax2.scatter(snr.flatten(), dcm.flatten(), color='tab:orange', alpha=0.5, s=1)\n", + "ax2.set_ylabel('Distance', color='tab:orange')\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NBINS = 40\n", + "TAKE = 6 # take 5: ssn\n", + "MT_IDX_MIN=30 \n", + "MT_IDX_MAX=-1\n", + "DC_EDGE_MIN=3e1\n", + "DC_EDGE_MAX=1e4\n", + "\n", + "\n", + "# get edges\n", + "sam = holo.sams.Semi_Analytic_Model()\n", + "mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", + "dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hist_min, dc_ed, mt_ed = np.histogram2d(dcm.flatten(), mtt.flatten(), \n", + " bins=(dc_edges, mt_edges), weights=snr.flatten())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(holo.utils.stats(hist_min))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "var=-2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "TARGET = 'hard_gamma_inner'\n", + "VAR=-2\n", + "data, params, dsdat = get_var_data(target=TARGET, var=VAR, nskies=NSKIES, nvars=NVARS,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' )\n", + "par_max = params[TARGET]\n", + "\n", + "# single sources\n", + "snr = dsdat['snr_ss']\n", + "sspar = sings.all_sspars(data['fobs_cents'], data['sspar'])\n", + "mtt = np.repeat(sspar[0]/MSOL, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "mtt = np.swapaxes(mtt, -1, -2)\n", + "dcm = np.repeat(sspar[4]/MPC, NSKIES).reshape(NFREQS, NREALS, NLOUDEST, NSKIES)\n", + "dcm = np.swapaxes(dcm, -1, -2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='mass (msun)', ylabel='distance (Mpc)')\n", + "im = ax.scatter(mtt.flatten(), dcm.flatten(), c=snr, s=1, alpha=0.5)\n", + "cbar = plt.colorbar(im, ax=ax)" + ] + }, { "attachments": {}, "cell_type": "markdown", @@ -315,8 +476,8 @@ "\n", "\n", "targets = [\n", - " # 'gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", - " # 'hard_time', \n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', \n", " 'hard_gamma_inner'\n", " ]\n", "if BUILD_ARRAYS:\n", @@ -399,76 +560,6 @@ "print(f\"{sam.mtot[35]/MSOL:.2e}\")" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# TAKE = 3\n", - "# MT_IDX_MIN=30 \n", - "# MT_IDX_MAX=-8\n", - "# DC_EDGE_MIN=3e1\n", - "# DC_EDGE_MAX=1e4\n", - "\n", - "# # get edges\n", - "# sam = holo.sams.Semi_Analytic_Model()\n", - "# mt_edges = sam.mtot[MT_IDX_MIN:MT_IDX_MAX]/MSOL\n", - "# dc_edges = np.geomspace(DC_EDGE_MIN, DC_EDGE_MAX, NBINS)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# target = 'hard_time'\n", - "\n", - "# green_colors = ['#98d594', '#2e984e', '#00441b']\n", - "# blue_colors = ['#94c4df', '#2e7ebc', '#09306b']\n", - "# orange_colors = ['#fda762', '#e2540a', '#7f2704']\n", - "\n", - "# filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata'\n", - "# load_from = filename+f'/mt_dc_hist_tk{TAKE}_{target}_{NBINS}bins.npz'\n", - "\n", - "# rv = np.load(load_from)\n", - "# hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", - "# par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", - "# rv.close()\n", - "\n", - "# mt_cents = holo.utils.midpoints(mt_edges)\n", - "# dc_cents= holo.utils.midpoints(dc_edges)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# fig, ax = plot.figax(xlabel='Mass [M$_\\odot$]', ylabel='Distance [Mpc]')\n", - "# cmap_idx = [0.4, 0.7, 1.0]\n", - "# for ii, hist in enumerate([hist_min, hist_med, hist_max]):\n", - "# cmap = truncate_colormap('Blues', cmap_idx[ii], cmap_idx[ii])\n", - "# kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", - "# np.swapaxes(hist,0,1), cmap=cmap, outline=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# fig, ax = plot.figax(xlabel='Mass [M$_\\odot$]', ylabel='Distance [Mpc]')\n", - "# cmap_idx = [0.4, 0.7, 1.0]\n", - "# for ii, hist in enumerate([hist_min, hist_med, hist_max]):\n", - "# cmap = truncate_colormap('Blues', cmap_idx[ii], cmap_idx[ii])\n", - "# kale.plot.draw_contour2d(ax, [mt_edges, dc_edges], \n", - "# np.swapaxes(hist,0,1), cmap=cmap, outline=True)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -478,46 +569,11 @@ "quantiles, sigmas = kale.plot._default_quantiles(sigmas=[0.5,1.0,1.5])" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# sigmas = [1.0, 2.0]\n", - "# quantiles = 1.0 - np.exp(-0.5 * np.square(sigmas))\n", - "# print(quantiles)\n", - "\n", - "# fig = plot_all_targets_catcolors(targets, NBINS=NBINS,\n", - "# MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", - "# DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", - "# smooth=True)\n", - "# savepath = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots/snr_contours'\n", - "# savename = f\"{savepath}/snr_smooth_contours.png\"\n", - "# fig.savefig(savename, dpi=300)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# sigmas = [1.0, 2.0]\n", - "# quantiles = 1.0 - np.exp(-0.5 * np.square(sigmas))\n", - "# print(quantiles)\n", - "\n", - "# fig = plot_all_targets_catcolors(targets, NBINS=NBINS,\n", - "# MT_IDX_MIN=MT_IDX_MIN, MT_IDX_MAX=MT_IDX_MAX,\n", - "# DC_EDGE_MIN=DC_EDGE_MIN, DC_EDGE_MAX=DC_EDGE_MAX,\n", - "# quantiles=quantiles)" - ] - }, { "cell_type": "markdown", "metadata": {}, "source": [ - "# Single" + "### Single Column" ] }, { @@ -575,6 +631,7 @@ " hist_min, hist_med, hist_max = rv['hist_min'], rv['hist_med'], rv['hist_max']\n", " bghist_min, bghist_med, bghist_max = rv['bghist_min'], rv['bghist_med'], rv['bghist_max']\n", " par_min, par_med, par_max = rv['par_min'], rv['par_med'], rv['par_max']\n", + " mt_edges, dc_edges = rv['mt_edges'], rv['dc_edges']\n", " rv.close()\n", "\n", " # plot histogram\n", From 43ff664d9043964bfb7d567f799d1af86c4a6186 Mon Sep 17 00:00:00 2001 From: Emiko Date: Wed, 19 Jul 2023 18:31:27 -0500 Subject: [PATCH 282/291] Notebook checking npz data file for Peter. --- .../anisotropy/healpix/data_for_peter.ipynb | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 ecg-notebooks/anisotropy/healpix/data_for_peter.ipynb diff --git a/ecg-notebooks/anisotropy/healpix/data_for_peter.ipynb b/ecg-notebooks/anisotropy/healpix/data_for_peter.ipynb new file mode 100644 index 00000000..6acf75b0 --- /dev/null +++ b/ecg-notebooks/anisotropy/healpix/data_for_peter.ipynb @@ -0,0 +1,71 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import holodeck as holo\n", + "from holodeck import single_sources, utils, plot, detstats\n", + "from holodeck.constants import YR\n", + "\n", + "import numpy as np\n", + "import healpy as hp\n", + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss60_anis09B_2023-06-16_uniform-09b_n1000_r50_f40_l2000/anisotropy/sph_harm_hc2dOm_lmax6_ns08_r50_b00-99.npz')\n", + "print(file.files)\n", + "nsort = file['nsort']\n", + "print(nsort[:10])\n", + "file.close()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "file = np.load('/Users/emigardiner/GWs/holodeck/output/brc_output/ss60_anis09B_2023-06-16_uniform-09b_n1000_r50_f40_l2000/sam-lib__p000615.npz')\n", + "print(file.files)\n", + "hc_ss = file['hc_ss'] # shape nfreqs, nreals, nloudest=2000\n", + "hc_bg = file['hc_bg'] # shape nfreqs, nreals\n", + "nfreqs, nreals, nloudest, = [*hc_ss.shape]\n", + "print(f\"{nfreqs=}, {nreals=}, {nloudest=}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 791dca38cedeba557eb742265745482b39c90293 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 20 Jul 2023 11:24:22 -0500 Subject: [PATCH 283/291] Add LABEL_EVSS. --- holodeck/plot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/holodeck/plot.py b/holodeck/plot.py index 423f9795..f80287df 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -58,6 +58,7 @@ } LABEL_DPRATIO = r"$\langle N_\mathrm{SS} \rangle / \mathrm{DP}_\mathrm{BG}$" +LABEL_EVSS = f"$\langle N_\mathrm{SS} \rangle" COLORS_MPL = plt.rcParams['axes.prop_cycle'].by_key()['color'] From 5a93ab3115175ffeb3e6acf8659330ad46c35ddf Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 20 Jul 2023 11:46:25 -0500 Subject: [PATCH 284/291] Plot N_SS instead of ratio. --- ecg-notebooks/paper_plots/evss1.ipynb | 808 ++++++++++++++++++++++++++ 1 file changed, 808 insertions(+) create mode 100644 ecg-notebooks/paper_plots/evss1.ipynb diff --git a/ecg-notebooks/paper_plots/evss1.ipynb b/ecg-notebooks/paper_plots/evss1.ipynb new file mode 100644 index 00000000..5122f2a0 --- /dev/null +++ b/ecg-notebooks/paper_plots/evss1.ipynb @@ -0,0 +1,808 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import matplotlib as mpl\n", + "from tqdm import tqdm\n", + "\n", + "\n", + "from holodeck import plot, detstats\n", + "import holodeck.single_sources as sings\n", + "from holodeck.constants import YR, MSOL, MPC\n", + "import holodeck as holo\n", + "\n", + "import hasasia.sim as hsim\n", + "import os\n" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Set up" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "# NREALS = 20\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "BUILD_ARRAYS = False\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "NVARS = 21\n", + "# NVARS = 6\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "# NSKIES = 15\n", + "\n", + "SHOW_GW=True" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get param names" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "pspace = holo.param_spaces.PS_Uniform_09B(holo.log, nsamples=1, sam_shape=SHAPE, seed=None)\n", + "param_names = pspace.param_names" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Get data and dets file functions" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/mmb_mamp_log10_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-1.5.npz'\n", + "file = np.load(filename, allow_pickle=True)\n", + "print(file.files)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", + "):\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", + "\n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + " print(target, \"got data\")\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " print(target, \"loaded dets\")\n", + " print(file.files)\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat\n", + "\n", + "def get_ratio_arrays(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, debug=False,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata',\n", + " red=True, \n", + " ):\n", + " filename = path+f'/ratio_arrays_{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz'\n", + " file = np.load(filename)\n", + " if debug: print(f\"{filename}\\n{file.files}\")\n", + " xx = file['xx_params']\n", + " y0p0 = file['yy_ratio']\n", + " if red:\n", + " y1p5 = file['y1p5_ratio']\n", + " y3p0 = file['y3p0_ratio']\n", + " file.close()\n", + " if red:\n", + " return xx, y0p0, y1p5, y3p0, #y1p5, y3p0\n", + " else:\n", + " return xx, y0p0, " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata'\n", + "for target in ['gsmf_phi0', 'gsmf_mchar0_log10', 'mmb_mamp_log10', 'mmb_scatter_dex']:\n", + " filename = path+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " file = np.load(filename)\n", + " print(f\"{filename}\\n{file.files}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# if True:\n", + "if BUILD_ARRAYS:\n", + " # targets = [\n", + " # 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " # 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " targets = [\n", + " # 'gsmf_phi0',\n", + " # 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', \n", + " # 'mmb_scatter_dex',\n", + " ]\n", + " # path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW' \n", + " # figpath = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", + " for target in tqdm(targets):\n", + " print(target)\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target, path=path)\n", + " xx=[]\n", + " yy=[]\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " yy.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -1.5\n", + " data, params, dsdat = get_data(target, red_gamma=-1.5, red2white=1.0, path=path)\n", + " y1p5=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y1p5.append(dp_ss/dp_bg)\n", + "\n", + " # red_gamma = -3.0\n", + " data, params, dsdat = get_data(target, red_gamma=-3.0, red2white=1, path=path)\n", + " y3p0=[]\n", + " for pp, par in enumerate(params):\n", + " dp_bg = np.repeat(dsdat[pp]['dp_bg'], NSKIES).reshape(NREALS, NSKIES)\n", + " dp_ss = dsdat[pp]['ev_ss']\n", + " y3p0.append(dp_ss/dp_bg)\n", + "\n", + " \n", + " np.savez(figpath+f'/ratio_arrays_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", + " xx_params = xx, yy_ratio = yy, y1p5_ratio = y1p5, y3p0_ratio=y3p0)\n", + " # xx_params = xx, yy_ratio = yy, y3p0_ratio=y3p0)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "filename = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/mmb_mamp_log10_v21_r500_shapeNone/detstats_s100_r2w1.0_rg-3.0.npz'\n", + "file = np.load(filename)\n", + "print(file.files)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Red Noise" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = plot.LABEL_DPRATIO\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#e67739', '#35b6e0',\n", + " '#4da169', '#e67739', '#35b6e0',\n", + "]\n", + "col3p0 = [\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + " '#8fcf91', '#fda363', '#38cbff',\n", + "]\n", + "\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", + " if SHOW_GW:\n", + " if ii%3 != 2:\n", + " xx_gw, yy_gw, y1p5_gw, y3p3_gw = get_ratio_arrays(targets[ii], red=True,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " \n", + " col=col0p0[ii]\n", + " # for pp in [50, 95]:\n", + " for pp in [68]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii], linestyle='-')\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", + " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle=':')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + "\n", + "handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + " mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "\n", + "plt.subplots_adjust(wspace=0)\n", + "\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " if SHOW_GW:\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_pp50.png'\n", + " else:\n", + " savename = savename+f'/ratio_vs_var{NVARS}_r2w_gw.png'\n", + " # savename = savename+'/ratio_vs_var6_wn_pp5095.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# White noise with GW-Only" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = plot.LABEL_DPRATIO\n", + "targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', 'hard_time', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#9e5c41', '#2d839f',\n", + " '#336948', '#9e5c41', '#2d839f',\n", + "]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# ]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 0 or ii == 3:\n", + " ax.set_ylabel(ylabel)\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", + "\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if ii%3 != 2:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + " \n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/ratio_vs_var{NVARS}_wn_gw.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = plot.LABEL_EVSS\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "# col1p5 = [\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# '#4da169', '#e67739', '#35b6e0',\n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# '#8fcf91', '#fda363', '#38cbff',\n", + "# ]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii == 2:\n", + " ax.set_ylabel(ylabel)\n", + "\n", + " ax.yaxis.set_major_locator(mpl.ticker.LogLocator(numticks=999))\n", + " ax.yaxis.set_minor_locator(mpl.ticker.LogLocator(numticks=999, subs=(.2, .4, .6, .8)))\n", + "\n", + " xx, yy0p0, = get_ratio_arrays(targets[ii], red=False)\n", + " yy0p0 *= 0.5\n", + "\n", + " col=col0p0[ii]\n", + " for pp in [50, 95]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if ii<4:\n", + " xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " yy_gw *= 0.5\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + " else:\n", + " xx_gw = xx\n", + " yy_gw = yy_gw[int(NVARS/2)]\n", + " yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + " for pp in [50]:\n", + " med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + " print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + " \n", + "\n", + " # med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col1p5[ii])\n", + " # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + "\n", + " # med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " # ax.plot(xx, med, alpha=0.9, color=col3p0[ii])\n", + " # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/evss_vs_var{NVARS}_wn_gw_single.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# ylabel = '$\\langle N \\\\rangle _\\mathrm{SS} / \\gamma_\\mathrm{BG}$'\n", + "# targets = [\n", + "# 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + "# 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + "# 'hard_time', 'hard_gamma_inner']\n", + "# col0p0 = [\n", + "# '#336948', '#336948', \n", + "# '#9e5c41', '#9e5c41', \n", + "# '#2d839f', '#2d839f',\n", + "# ]\n", + "# col1p5 = [\n", + "# '#4da169', '#4da169',\n", + "# '#e67739', '#e67739',\n", + "# '#35b6e0', '#35b6e0',\n", + " \n", + "# ]\n", + "# col3p0 = [\n", + "# '#8fcf91', '#8fcf91',\n", + "# '#fda363', '#fda363',\n", + "# '#38cbff', '#38cbff',\n", + "# ]\n", + "# col_gw = [\n", + "# 'k', 'k', 'k',\n", + "# 'k', 'k', 'k'\n", + "# ]\n", + "\n", + "# SHOW_GW = True\n", + "# SHOW_REDLINES = True\n", + "\n", + "# fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + "# height=7)\n", + "# for ii, ax in enumerate(axs.flatten()):\n", + "# ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + "# if ii ==2:\n", + "# ax.set_ylabel(ylabel)\n", + "# xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", + "# yy0p0 *= 0.5\n", + "# yy1p5 *= 0.5\n", + "# yy3p0 *= 0.5\n", + "# col=col0p0[ii]\n", + "# for pp in [50, 95]:\n", + "# # for pp in [50]: \n", + "# med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + "# ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + "# if ii<4 and SHOW_GW:\n", + "# xx_gw, yy_gw = get_ratio_arrays(targets[ii], red=False,\n", + "# path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + "# yy_gw *= 0.5\n", + "# for pp in [50]:\n", + "# med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + "# ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + "# elif SHOW_GW:\n", + "# xx_gw = xx\n", + "# yy_gw = yy_gw[int(NVARS/2)]\n", + "# yy_gw = np.repeat(yy_gw, 21).reshape(NREALS*NSKIES, NVARS)\n", + "# yy_gw = np.swapaxes(yy_gw, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + "# # print(f\"{ii=}, {yy_gw.shape}\")\n", + "\n", + "# for pp in [50]:\n", + "# med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + "# ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + "# # print(f\"{ii=}, yy_gw.shape\")\n", + "\n", + "# if SHOW_REDLINES:\n", + "# for pp in [50,]:\n", + "# # Red Noise Models\n", + "# med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", + "# # ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + " \n", + "# med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", + "# # ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + "\n", + "# if SHOW_GW:\n", + "# med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# # ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + "# # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + "# med, *conf = np.percentile(yy_gw, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + "# # ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle=':')\n", + " \n", + "\n", + "# # handles = [mpl.lines.Line2D([0], [0], label='0.0', color = col0p0[0], linestyle='-'),\n", + "# # mpl.lines.Line2D([0], [0], label='-1.5', color = col1p5[0], linestyle='--'),\n", + "# # mpl.lines.Line2D([0], [0], label='-3.0', color = col3p0[0], linestyle=':')]\n", + "# # leg = fig.legend(handles=handles, bbox_to_anchor=(0.5,0.05), loc = 'center',\n", + "# # title='$\\gamma_\\mathrm{RN}$', ncols=4, \n", + "# # fontsize=10, title_fontsize=12, handletextpad=0.1, labelspacing=0.2)\n", + "# # leg.get_title().set_position((-50,-10))\n", + "# plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "# # fig.tight_layout()\n", + "\n", + "# if SAVEFIG:\n", + "# savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "# # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + "# savename = savename+f'/evss_var{NVARS}_gw_single_rnlines.png'\n", + "# fig.savefig(savename, dpi=100, bbox_inches='tight')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Red Noise, GW, Single" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def repeat_mid_yy(yy):\n", + " yy = yy[int(NVARS/2)]\n", + " yy = np.repeat(yy, NVARS).reshape(NREALS*NSKIES, NVARS)\n", + " yy = np.swapaxes(yy, 0, 1).reshape(NVARS, NREALS, NSKIES,)\n", + " return yy" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "ylabel = plot.LABEL_EVSS\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "col0p0 = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "col1p5 = [\n", + " '#4da169', '#4da169',\n", + " '#e67739', '#e67739',\n", + " '#35b6e0', '#35b6e0',\n", + " \n", + "]\n", + "col3p0 = [\n", + " '#8fcf91', '#8fcf91',\n", + " '#fda363', '#fda363',\n", + " '#38cbff', '#38cbff',\n", + "]\n", + "col_gw = [\n", + " 'k', 'k', 'k',\n", + " 'k', 'k', 'k'\n", + "]\n", + "\n", + "SHOW_GW = True\n", + "\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " if ii ==2:\n", + " ax.set_ylabel(ylabel)\n", + " ax.tick_params(axis='y', which='both', right=True, left=True, direction='in')\n", + " ax.tick_params(axis='x', which='both', top=True, direction='in')\n", + " \n", + " ax.yaxis.set_major_locator(mpl.ticker.LogLocator(numticks=999))\n", + " ax.yaxis.set_minor_locator(mpl.ticker.LogLocator(numticks=999, subs=(.2, .4, .6, .8)))\n", + "\n", + "\n", + "\n", + " xx, yy0p0, yy1p5, yy3p0 = get_ratio_arrays(targets[ii], red=True)\n", + " yy0p0 *= 0.5\n", + " yy1p5 *= 0.5\n", + " yy3p0 *= 0.5\n", + " col=col0p0[ii]\n", + " for pp in [68,]:\n", + " # for pp in [50]: \n", + " med, *conf = np.percentile(yy0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col0p0[ii])\n", + " ax.fill_between(xx, *conf, color=col0p0[ii], alpha=0.25)\n", + "\n", + " if SHOW_GW:\n", + " if ii<4:\n", + " xx_gw, gw_0p0, gw_1p5, gw_3p0 = get_ratio_arrays(targets[ii], red=True,\n", + " path='/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata')\n", + " gw_0p0 *= 0.5\n", + " gw_1p5 *= 0.5\n", + " gw_3p0 *= 0.5\n", + " for pp in [68,]:\n", + " med, *conf = np.percentile(gw_0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + " else:\n", + " xx_gw = xx\n", + " gw_0p0 = repeat_mid_yy(gw_0p0)\n", + " gw_1p5 = repeat_mid_yy(gw_1p5)\n", + " gw_3p0 = repeat_mid_yy(gw_3p0)\n", + "\n", + "\n", + " for pp in [68,]:\n", + " med, *conf = np.percentile(gw_0p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='-')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='-')\n", + "\n", + " med, *conf = np.percentile(gw_1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle='--')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle='--')\n", + "\n", + " med, *conf = np.percentile(gw_3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx_gw, med, alpha=0.5, color=col_gw[ii], linestyle=':')\n", + " # ax.fill_between(xx, *conf, color=col_gw[ii], alpha=0.2, linestyle=':')\n", + "\n", + "\n", + " for pp in [50,]:\n", + " # Red Noise Models\n", + " med, *conf = np.percentile(yy1p5, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col1p5[ii], linestyle='--')\n", + " ax.fill_between(xx, *conf, color=col1p5[ii], alpha=0.25)\n", + " \n", + " med, *conf = np.percentile(yy3p0, [50, 50-pp/2, 50+pp/2], axis=(1,2))\n", + " ax.plot(xx, med, alpha=0.9, color=col3p0[ii], linestyle=':')\n", + " ax.fill_between(xx, *conf, color=col3p0[ii], alpha=0.25)\n", + "\n", + " \n", + "\n", + "# handles = [mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=0.0$', color = col0p0[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-1.5$', color = col1p5[0]),\n", + "# mpl.lines.Line2D([0], [0], label='$\\gamma_\\mathrm{red}=-3.0$', color = col3p0[0])]\n", + "# axs[0,0].legend(handles=handles, loc='upper left', ncol=2)\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "# fig.tight_layout()\n", + "\n", + "if SAVEFIG:\n", + " savename = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + " # savename = savename+'/ratio_vs_var6_r2w_pp50.png'\n", + " savename = savename+f'/evss_vs_var{NVARS}_rn_gw_single_68ci.png'\n", + " fig.savefig(savename, dpi=100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From b4b9c85f5b41a7724527ee8d048a067008d79eb9 Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 20 Jul 2023 13:40:44 -0500 Subject: [PATCH 285/291] add GW only to frequency plot --- .../favg1_frequency_of_detection.ipynb | 142 +++++++++++++++++- 1 file changed, 135 insertions(+), 7 deletions(-) diff --git a/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb b/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb index 08c55588..7db93904 100644 --- a/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb +++ b/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb @@ -91,12 +91,10 @@ " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz' \n", "):\n", - " if path == '/Users/emigardiner/GWs/holodeck/output/anatomy_redz':\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", - " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", - " else:\n", - " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}.npz' \n", - " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_s{nskies}_shape{str(shape)}_ds' \n", + "\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}' \n", + " \n", " if red_gamma is not None and red2white is not None:\n", " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", " else:\n", @@ -145,6 +143,15 @@ "print(f\"{dpssi.shape=}, {freqs.shape=}\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='frequency /yr', ylabel='dp_ss')" + ] + }, { "cell_type": "code", "execution_count": null, @@ -225,6 +232,12 @@ "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", " \n", "\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner'\n", + " ]\n", + "\n", "ylabel = 'Frequency [yr$^{-1}$]'\n", "ylabel_nHz = 'Frequency [nHz]'\n", "\n", @@ -293,13 +306,128 @@ " # ax.tick_params(axis='x', labelrotation=45)\n", "\n", "fig.text(0.08, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", - "fig.text(1.04, 0.5, ylabel_nHz, ha='right', va='center', rotation=270)\n", + "fig.text(1.04, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", "savename = saveloc+'/frequencies_single.png'\n", "fig.savefig(savename, dpi=100)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Add GW only" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if BUILD_ARRAYS:\n", + " targets = [\n", + " 'gsmf_phi0', 'mmb_mamp_log10', \n", + " 'gsmf_mchar0_log10', 'mmb_scatter_dex', ]\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " for target in tqdm(targets):\n", + " print(target)\n", + " xx = [] # param\n", + " yy = [] # frequency means\n", + "\n", + " # white noise only\n", + " data, params, dsdat = get_data(target, path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW')\n", + " freqs = data[var]['fobs_cents']\n", + " freqs = np.repeat(freqs, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", + "\n", + " for pp, par in enumerate(params):\n", + " xx.append(params[pp][target])\n", + " dpssi = dsdat[pp]['gamma_ssi']\n", + " freq_mean = np.average(freqs, weights=dpssi, axis=(0,-1))\n", + " yy.append(freq_mean)\n", + "\n", + " np.savez(path+f'/freq_means_gw_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", + " xx_params = xx, yy_fmeans = yy)\n", + "# else:\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", + "# file = np.load(path+f'/freq_means_gw_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + "# xx_gw = file['xx_params']\n", + "# yy_gw = file['yy_fmeans']\n", + "# file.close()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "targets = [\n", + " 'gsmf_phi0', 'gsmf_mchar0_log10', \n", + " 'mmb_mamp_log10', 'mmb_scatter_dex',\n", + " 'hard_time', 'hard_gamma_inner']\n", + "colors = [\n", + " '#336948', '#336948', \n", + " '#9e5c41', '#9e5c41', \n", + " '#2d839f', '#2d839f',\n", + "]\n", + "path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + " \n", + "\n", + "ylabel = 'Frequency [yr$^{-1}$]'\n", + "ylabel_nHz = 'Frequency [nHz]'\n", + "fig, axs = plot.figax_single(nrows=3, ncols=2, \n", + " sharey=True, sharex=False, xscale='linear',\n", + " height=7)\n", + "\n", + "\n", + "for ii, ax in enumerate(axs.flatten()):\n", + " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", + " # if ii == 0 or ii == 3:\n", + " # ax.set_ylabel(ylabel)\n", + " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " xx = file['xx_params']\n", + " yy = file['yy_fmeans'].reshape(NVARS, NREALS*NSKIES)*YR\n", + " print(f\"{yy.shape=}\")\n", + "\n", + " ax.plot(xx, np.median(yy, axis=-1), color=colors[ii], alpha=0.9)\n", + " for pp in [50,95]:\n", + " percs = [50-pp/2, 50+pp/2]\n", + " ax.fill_between(xx, *np.percentile(yy, percs, axis=-1), color=colors[ii], alpha=0.25)\n", + " # plot.draw_med_conf_color(ax, xx, yy.reshape(NVARS, NREALS*NSKIES), color=colors[ii])\n", + " if ii%2 == 1:\n", + " _twiny_hz(ax, label=False)\n", + "\n", + " print(f\"{yy.shape=}\")\n", + "\n", + " if ii<4:\n", + " file = np.load(path+f'/freq_means_gw_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " xx_gw = file['xx_params']\n", + " yy_gw = file['yy_fmeans'].reshape(NVARS, NREALS*NSKIES)*YR\n", + " elif ii==4: # hard_time, get mean, hard_gamma_inner uses same\n", + " yy_gw = np.repeat(yy_gw[10,:], NVARS).reshape(NREALS*NSKIES, NVARS)\n", + " yy_gw = np.swapaxes(yy_gw, 0, 1)\n", + "\n", + " ax.plot(xx, np.median(yy_gw, axis=-1), color='k', alpha=0.75, linestyle='--')\n", + " for pp in [50,]:\n", + " percs = [50-pp/2, 50+pp/2]\n", + " ax.fill_between(xx, *np.percentile(yy_gw, percs, axis=-1), color='k', alpha=0.15, linestyle='--')\n", + " \n", + " if ii%2 == 1:\n", + " _twiny_hz(ax, label=False)\n", + "# fig.tight_layout()\n", + " # ax.tick_params(axis='x', labelrotation=45)\n", + "\n", + "fig.text(0.08, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "fig.text(1.04, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", + "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", + "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "savename = saveloc+'/frequencies_gw_single.png'\n", + "fig.savefig(savename, dpi=100)" + ] + }, { "cell_type": "code", "execution_count": null, From acde1b1f5f1164f1e005210450ebe418fa36668b Mon Sep 17 00:00:00 2001 From: Emiko Date: Thu, 20 Jul 2023 13:41:11 -0500 Subject: [PATCH 286/291] Correct LABEL_EVSS --- holodeck/plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holodeck/plot.py b/holodeck/plot.py index f80287df..252db98a 100644 --- a/holodeck/plot.py +++ b/holodeck/plot.py @@ -58,7 +58,7 @@ } LABEL_DPRATIO = r"$\langle N_\mathrm{SS} \rangle / \mathrm{DP}_\mathrm{BG}$" -LABEL_EVSS = f"$\langle N_\mathrm{SS} \rangle" +LABEL_EVSS = r"$\langle N_\mathrm{SS} \rangle" COLORS_MPL = plt.rcParams['axes.prop_cycle'].by_key()['color'] From a3f659eef562c6447f7b633df84e20dd96acaf01 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 22 Jul 2023 14:51:01 -0500 Subject: [PATCH 287/291] Test different favg calculation methods --- .../ds12_dpvsfreq_noise.ipynb | 342 ++++++++++++++++++ 1 file changed, 342 insertions(+) create mode 100644 ecg-notebooks/detstats_functions/ds12_dpvsfreq_noise.ipynb diff --git a/ecg-notebooks/detstats_functions/ds12_dpvsfreq_noise.ipynb b/ecg-notebooks/detstats_functions/ds12_dpvsfreq_noise.ipynb new file mode 100644 index 00000000..f7da7192 --- /dev/null +++ b/ecg-notebooks/detstats_functions/ds12_dpvsfreq_noise.ipynb @@ -0,0 +1,342 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.cm as cm\n", + "import h5py\n", + "import os\n", + "\n", + "from holodeck import plot, detstats, utils\n", + "from holodeck.constants import YR, MSOL, MPC, GYR\n", + "import holodeck as holo" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SHAPE = None\n", + "NREALS = 500\n", + "NFREQS = 40\n", + "NLOUDEST = 10\n", + "\n", + "CONSTRUCT = False\n", + "JUST_DETSTATS = False\n", + "SAVEFIG = True\n", + "TOL=0.01\n", + "MAXBADS=5\n", + "\n", + "RED_GAMMA = None\n", + "RED_AMP = None\n", + "\n", + "NVARS = 21\n", + "\n", + "NPSRS = 40\n", + "NSKIES = 100\n", + "TARGET = 'mmb_scatter_dex' # EDIT AS NEEDED\n", + "TITLE = plot.PARAM_KEYS[TARGET] # EDIT AS NEEDED" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def get_data(\n", + " target, nvars=NVARS, nreals=NREALS, nskies=NSKIES, shape=SHAPE, red_gamma = None, red2white=None,\n", + " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz', ssn='_ssn', \n", + "):\n", + " load_data_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/data_params.npz' \n", + " load_dets_from_file = path+f'/{target}_v{nvars}_r{nreals}_shape{str(shape)}/detstats_s{nskies}{ssn}' \n", + "\n", + " if red_gamma is not None and red2white is not None:\n", + " load_dets_from_file = load_dets_from_file+f'_r2w{red2white:.1f}_rg{red_gamma:.1f}'\n", + " else:\n", + " load_dets_from_file = load_dets_from_file+f'_white'\n", + " load_dets_from_file = load_dets_from_file+'.npz'\n", + "\n", + " if os.path.exists(load_data_from_file) is False:\n", + " err = f\"load data file '{load_data_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " if os.path.exists(load_dets_from_file) is False:\n", + " err = f\"load dets file '{load_dets_from_file}' does not exist, you need to construct it.\"\n", + " raise Exception(err)\n", + " file = np.load(load_data_from_file, allow_pickle=True)\n", + " data = file['data']\n", + " params = file['params']\n", + " file.close()\n", + " print(target, \"got data\")\n", + " file = np.load(load_dets_from_file, allow_pickle=True)\n", + " print(target, \"loaded dets\")\n", + " print(file.files)\n", + " dsdat = file['dsdat']\n", + " file.close()\n", + "\n", + " return data, params, dsdat" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "data, params, dsdat = get_data('mmb_scatter_dex')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def plot_dp(fobs_cents, dp_ss, dp_bg, gamma_ssi, ax_avg=(0,3)):\n", + " fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel='Detection Probability')\n", + "\n", + " xx = fobs_cents*YR\n", + " y1 = dp_bg[0] # 1\n", + " y2 = gamma_ssi[:,:,:,:].reshape(NFREQS, NREALS*NSKIES*NLOUDEST) # F, R*S*L\n", + " y3 = dp_ss[0] # S\n", + " favg = np.average(\n", + " np.repeat(xx, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST),\n", + " weights=gamma_ssi.reshape(NFREQS, NREALS, NSKIES, NLOUDEST), axis=ax_avg)\n", + " \n", + " label1 = 'BG Detprob'\n", + " label2 = 'Individual SS Detprob'\n", + " label3 = 'Overall SS Detprob'\n", + " label4 = 'dp-weighted $\\langle f \\\\rangle$'\n", + "\n", + "\n", + " h1 = ax.axhline(y1)\n", + " h2 = plot.draw_med_conf_color(ax, xx, y2, color='orange')\n", + " for ss in range(NSKIES):\n", + " h3 = ax.axhline(y3[ss], color='tab:red', alpha=0.2)\n", + " h4 = ax.axvline(np.median(favg), color='g')\n", + "\n", + " ax.legend(handles=[h1,h2,h3,h4], labels=[label1, label2, label3, label4], loc='upper right')\n", + " ax.text(1.0,0., f\"{RED_AMP=}, {RED_GAMMA=}\", horizontalalignment='right', verticalalignment='bottom',\n", + " transform=ax.transAxes)\n", + " \n", + " return fig" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# average over all realizations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for pp in [0, 5, 10, 15, 20]:\n", + " fobs_cents = data[pp]['fobs_cents']\n", + " dp_ss = dsdat[pp]['dp_ss']\n", + " dp_bg = dsdat[pp]['dp_bg']\n", + " gamma_ssi = dsdat[pp]['gamma_ssi']\n", + "\n", + " fig = plot_dp(fobs_cents, dp_ss, dp_bg, gamma_ssi, ax_avg=(0,1,2,3))\n", + " fig.text(0,0, f\"{TARGET}={params[pp][TARGET]}\", ha='left', va='bottom')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# average over all skies, median of strains" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for pp in [0, 5, 10, 15, 20]:\n", + " fobs_cents = data[pp]['fobs_cents']\n", + " dp_ss = dsdat[pp]['dp_ss']\n", + " dp_bg = dsdat[pp]['dp_bg']\n", + " gamma_ssi = dsdat[pp]['gamma_ssi']\n", + "\n", + " fig = plot_dp(fobs_cents, dp_ss, dp_bg, gamma_ssi, ax_avg=(0,2,3))\n", + " fig.text(0,0, f\"{TARGET}={params[pp][TARGET]}\", ha='left', va='bottom')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# average only over freqs and loudest, median of realizations" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for pp in [0, 5, 10, 15, 20]:\n", + " fobs_cents = data[pp]['fobs_cents']\n", + " dp_ss = dsdat[pp]['dp_ss']\n", + " dp_bg = dsdat[pp]['dp_bg']\n", + " gamma_ssi = dsdat[pp]['gamma_ssi']\n", + "\n", + " fig = plot_dp(fobs_cents, dp_ss, dp_bg, gamma_ssi, ax_avg=(0,3))\n", + " fig.text(0,0, f\"{TARGET}={params[pp][TARGET]}\", ha='left', va='bottom')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for pp in [0, 5, 10, 15, 20]:\n", + " fobs_cents = data[pp]['fobs_cents']\n", + " dp_ss = dsdat[pp]['dp_ss']\n", + " dp_bg = dsdat[pp]['dp_bg']\n", + " gamma_ssi = dsdat[pp]['gamma_ssi']\n", + "\n", + " fig = plot_dp(fobs_cents, dp_ss, dp_bg, gamma_ssi, ax_avg=(0,1,2,3))\n", + " fig.text(0,0, f\"{TARGET}={params[pp][TARGET]}\", ha='left', va='bottom')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(fobs_cents.shape)\n", + "print(gamma_ssi.shape)\n", + "xx = np.repeat(fobs_cents, NREALS*NSKIES*NLOUDEST)*YR\n", + "yy = gamma_ssi.flatten()\n", + "favg = np.average(xx.reshape(NFREQS, NREALS, NSKIES, NLOUDEST),\n", + " weights=yy.reshape(NFREQS, NREALS, NSKIES, NLOUDEST), axis=(0,-1))\n", + "# print(f\"{fmean:.2e}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(favg.shape)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "fig, ax = plot.figax(xlabel='freq', ylabel='dpssi')\n", + "ax.scatter(xx, yy, s=4, alpha=0.1)\n", + "plot.draw_med_conf(ax, fobs_cents*YR, gamma_ssi.reshape(NFREQS, NREALS*NSKIES*NLOUDEST))\n", + "ax.axvline(np.median(favg), color='green')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for ii in range(300):\n", + " rr = int(np.random.uniform(0,500))\n", + " ss = int(np.random.uniform(0,100))\n", + " ax.axvline(favg[rr,ss], linestyle='dashed', color='green', alpha=0.5)\n", + "fig" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "_, fobs_edges = holo.utils.pta_freqs()\n", + "dp_edges = np.geomspace(10**-6, 10**0, num=20)\n", + "hist, dpe, ffe, = np.histogram2d(yy.flatten(),xx.flatten(), bins=(dp_edges, fobs_edges, ))\n", + "plt.pcolormesh(fobs_edges, (dp_edges), np.log10(hist),)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "weights = np.array([2,3,2,1,0.05,0.01,0,0,0,0])\n", + "arr = np.linspace(1,10,len(weights))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "weights = (np.repeat(weights, 5) + np.random.uniform(-0.1,0.1,50)).reshape(10,5) # 5 realizations\n", + "arr = np.repeat(arr, 5).reshape(10,5)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(np.average(arr, weights=weights))\n", + "print(np.average(arr, weights=weights, axis=0))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From 815593c05f044eb3542262fff99491bcff45c93e Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 22 Jul 2023 14:56:49 -0500 Subject: [PATCH 288/291] Plot favg using average over everything --- .../favg1_frequency_of_detection.ipynb | 154 ++++++++---------- 1 file changed, 66 insertions(+), 88 deletions(-) diff --git a/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb b/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb index 7db93904..b7cbe2fd 100644 --- a/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb +++ b/ecg-notebooks/paper_plots/favg1_frequency_of_detection.ipynb @@ -42,7 +42,7 @@ "NFREQS = 40\n", "NLOUDEST = 10\n", "\n", - "BUILD_ARRAYS = False\n", + "BUILD_ARRAYS = True\n", "SAVEFIG = True\n", "TOL=0.01\n", "MAXBADS=5\n", @@ -52,7 +52,10 @@ "\n", "NPSRS = 40\n", "NSKIES = 100\n", - "# NSKIES = 15" + "# NSKIES = 15\n", + "\n", + "MEDIAN=False\n", + "AVG=True" ] }, { @@ -119,49 +122,6 @@ " return data, params, dsdat" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "target='hard_time'\n", - "\n", - "data, params, dsdat = get_data(target)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "var=10\n", - "dpssi = dsdat[var]['gamma_ssi']\n", - "freqs = data[var]['fobs_cents']\n", - "freqs = np.repeat(freqs, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", - "print(f\"{dpssi.shape=}, {freqs.shape=}\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig, ax = plot.figax(xlabel='frequency /yr', ylabel='dp_ss')" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "freq_mean = np.average(freqs, weights=dpssi)\n", - "print(freq_mean*YR)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -182,6 +142,13 @@ " return tw" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Build arrays" + ] + }, { "cell_type": "code", "execution_count": null, @@ -200,23 +167,28 @@ "\n", " # white noise only\n", " data, params, dsdat = get_data(target)\n", - " freqs = data[var]['fobs_cents']\n", + " freqs = data[0]['fobs_cents']\n", " freqs = np.repeat(freqs, NREALS*NSKIES*NLOUDEST).reshape(NFREQS, NREALS, NSKIES, NLOUDEST)\n", "\n", " for pp, par in enumerate(params):\n", " xx.append(params[pp][target])\n", " dpssi = dsdat[pp]['gamma_ssi']\n", - " freq_mean = np.average(freqs, weights=dpssi, axis=(0,-1))\n", + " if MEDIAN:\n", + " freq_mean = np.average(freqs, weights=dpssi, axis=(0,-1))\n", + " elif AVG:\n", + " freq_mean = np.average(freqs, weights=dpssi)\n", " yy.append(freq_mean)\n", - "\n", - " np.savez(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", - " xx_params = xx, yy_fmeans = yy)\n", - "else:\n", - " path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", - " file = np.load(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", - " xx = file['xx_params']\n", - " yy = file['yy_fmeans']\n", - " file.close()\n" + " if MEDIAN:\n", + " saveloc = path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " elif AVG:\n", + " saveloc = path+f'/freq_avg_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " np.savez(saveloc, xx_params = xx, yy_fmeans = yy)\n", + "# else:\n", + "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_redz/figdata' \n", + "# file = np.load(path+f'/freq_means_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + "# xx = file['xx_params']\n", + "# yy = file['yy_fmeans']\n", + "# file.close()\n" ] }, { @@ -245,24 +217,25 @@ "fig, axs = plot.figax_double(nrows=2, ncols=3, sharey=True, sharex=False, xscale='linear')\n", "\n", "fig.text(0.06, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", - "fig.text(1.02, 0.5, ylabel_nHz, ha='right', va='center', rotation=270)\n", + "fig.text(1.02, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", "plt.subplots_adjust(wspace=0)\n", "for ii, ax in enumerate(axs.flatten()):\n", " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " # if ii == 0 or ii == 3:\n", " # ax.set_ylabel(ylabel)\n", - " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " file = np.load(path+f'/freq_avg_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", " xx = file['xx_params']\n", " yy = file['yy_fmeans']*YR\n", - " print(f\"{yy.shape=}\")\n", - " plot.draw_med_conf_color(ax, xx, yy.reshape(NVARS, NREALS*NSKIES), color=colors[ii])\n", + " # print(xx.shape, yy.shape)\n", + " # print(f\"{yy.shape=}\")\n", + " ax.plot(xx, yy, color=colors[ii])\n", " if ii==2 or ii==5:\n", " _twiny_hz(ax, label=False, nano=True)\n", " \n", "\n", - "# saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - "# savename = saveloc+'/frequencies_double.png'\n", - "# fig.savefig(savename, dpi=100)" + "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", + "savename = saveloc+'/favg_double.png'\n", + "fig.savefig(savename, dpi=100)" ] }, { @@ -295,21 +268,21 @@ " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " # if ii == 0 or ii == 3:\n", " # ax.set_ylabel(ylabel)\n", - " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " file = np.load(path+f'/freq_avg_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", " xx = file['xx_params']\n", " yy = file['yy_fmeans']*YR\n", " print(f\"{yy.shape=}\")\n", - " plot.draw_med_conf_color(ax, xx, yy.reshape(NVARS, NREALS*NSKIES), color=colors[ii])\n", + " ax.plot(xx, yy, color=colors[ii])\n", " if ii%2 == 1:\n", " _twiny_hz(ax, label=False)\n", "# fig.tight_layout()\n", " # ax.tick_params(axis='x', labelrotation=45)\n", "\n", - "fig.text(0.08, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", - "fig.text(1.04, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", + "fig.text(0.02, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "fig.text(1.12, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - "savename = saveloc+'/frequencies_single.png'\n", + "savename = saveloc+'/favg_single.png'\n", "fig.savefig(savename, dpi=100)" ] }, @@ -344,11 +317,17 @@ " for pp, par in enumerate(params):\n", " xx.append(params[pp][target])\n", " dpssi = dsdat[pp]['gamma_ssi']\n", - " freq_mean = np.average(freqs, weights=dpssi, axis=(0,-1))\n", + " if MEDIAN:\n", + " freq_mean = np.average(freqs, weights=dpssi, axis=(0,-1))\n", + " elif AVG:\n", + " freq_mean = np.average(freqs, weights=dpssi)\n", " yy.append(freq_mean)\n", + " if MEDIAN:\n", + " saveloc = path+f'/freq_means_gw_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", + " elif AVG:\n", + " saveloc = path+f'/freq_avg_gw_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz'\n", "\n", - " np.savez(path+f'/freq_means_gw_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz', \n", - " xx_params = xx, yy_fmeans = yy)\n", + " np.savez(saveloc, xx_params = xx, yy_fmeans = yy)\n", "# else:\n", "# path = '/Users/emigardiner/GWs/holodeck/output/anatomy_7GW/figdata' \n", "# file = np.load(path+f'/freq_means_gw_{target}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", @@ -387,15 +366,15 @@ " ax.set_xlabel(plot.PARAM_KEYS[targets[ii]])\n", " # if ii == 0 or ii == 3:\n", " # ax.set_ylabel(ylabel)\n", - " file = np.load(path+f'/freq_means_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " file = np.load(path+f'/freq_avg_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", " xx = file['xx_params']\n", - " yy = file['yy_fmeans'].reshape(NVARS, NREALS*NSKIES)*YR\n", + " yy = file['yy_fmeans']*YR\n", " print(f\"{yy.shape=}\")\n", "\n", - " ax.plot(xx, np.median(yy, axis=-1), color=colors[ii], alpha=0.9)\n", - " for pp in [50,95]:\n", - " percs = [50-pp/2, 50+pp/2]\n", - " ax.fill_between(xx, *np.percentile(yy, percs, axis=-1), color=colors[ii], alpha=0.25)\n", + " ax.plot(xx, yy, color=colors[ii], alpha=0.9)\n", + " # for pp in [50,95]:\n", + " # percs = [50-pp/2, 50+pp/2]\n", + " # ax.fill_between(xx, *np.percentile(yy, percs, axis=-1), color=colors[ii], alpha=0.25)\n", " # plot.draw_med_conf_color(ax, xx, yy.reshape(NVARS, NREALS*NSKIES), color=colors[ii])\n", " if ii%2 == 1:\n", " _twiny_hz(ax, label=False)\n", @@ -403,28 +382,27 @@ " print(f\"{yy.shape=}\")\n", "\n", " if ii<4:\n", - " file = np.load(path+f'/freq_means_gw_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", + " file = np.load(path+f'/freq_avg_gw_{targets[ii]}_v{NVARS}_r{NREALS}_s{NSKIES}_shape{str(SHAPE)}.npz')\n", " xx_gw = file['xx_params']\n", - " yy_gw = file['yy_fmeans'].reshape(NVARS, NREALS*NSKIES)*YR\n", + " yy_gw = file['yy_fmeans']*YR\n", " elif ii==4: # hard_time, get mean, hard_gamma_inner uses same\n", - " yy_gw = np.repeat(yy_gw[10,:], NVARS).reshape(NREALS*NSKIES, NVARS)\n", - " yy_gw = np.swapaxes(yy_gw, 0, 1)\n", + " yy_gw = np.repeat(yy_gw[10], NVARS)\n", "\n", - " ax.plot(xx, np.median(yy_gw, axis=-1), color='k', alpha=0.75, linestyle='--')\n", - " for pp in [50,]:\n", - " percs = [50-pp/2, 50+pp/2]\n", - " ax.fill_between(xx, *np.percentile(yy_gw, percs, axis=-1), color='k', alpha=0.15, linestyle='--')\n", + " ax.plot(xx, yy_gw, color='k', alpha=0.75, linestyle='--')\n", + " # for pp in [50,]:\n", + " # percs = [50-pp/2, 50+pp/2]\n", + " # ax.fill_between(xx, *np.percentile(yy_gw, percs, axis=-1), color='k', alpha=0.15, linestyle='--')\n", " \n", " if ii%2 == 1:\n", " _twiny_hz(ax, label=False)\n", "# fig.tight_layout()\n", " # ax.tick_params(axis='x', labelrotation=45)\n", "\n", - "fig.text(0.08, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", - "fig.text(1.04, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", + "fig.text(0.04, 0.5, ylabel, ha='right', va='center', rotation='vertical')\n", + "fig.text(1.11, 0.5, ylabel_nHz, ha='right', va='center', rotation='vertical')\n", "plt.subplots_adjust(wspace=0.05, hspace=0.35)\n", "saveloc = '/Users/emigardiner/GWs/holodeck/output/figures/bigplots'\n", - "savename = saveloc+'/frequencies_gw_single.png'\n", + "savename = saveloc+'/favg_gw_single.png'\n", "fig.savefig(savename, dpi=100)" ] }, From bd95f0c7c097a192bc00834d3c56468324ed7158 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 22 Jul 2023 15:33:19 -0500 Subject: [PATCH 289/291] Add single source demo to notebooks. --- notebooks/ss_demo.ipynb | 193 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 notebooks/ss_demo.ipynb diff --git a/notebooks/ss_demo.ipynb b/notebooks/ss_demo.ipynb new file mode 100644 index 00000000..ceaed68b --- /dev/null +++ b/notebooks/ss_demo.ipynb @@ -0,0 +1,193 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %load ../init.ipy\n", + "%reload_ext autoreload\n", + "%autoreload 2\n", + "from importlib import reload\n", + "\n", + "import numpy as np\n", + "import matplotlib.cm as cm\n", + "\n", + "import holodeck as holo\n", + "from holodeck import plot, utils\n", + "from holodeck.constants import YR" + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Build Semi-Analytic Model, sam\n", + "Select a shape (smaller for speed, larger for accuracy, best with None) and use defaults for all other parameters (GSMF, GMT, MMbulge) in sam" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# SHAPE = None # default shape, if None, is 91,81,101.\n", + "SHAPE = 40 # make this smaller to run faster, for debugging\n", + "\n", + "# get PTA frequencies\n", + "fobs_gw_cents, fobs_gw_edges = utils.pta_freqs()\n", + "\n", + "# build Semi-Analytic Model\n", + "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE) " + ] + }, + { + "attachments": {}, + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Calculate SS and GWB strain with sam.gwb()\n", + "This function calls single_sources.ss_gws_redz().\n", + "\n", + "### Choose a hardening model" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# uncomment one of the following hardening models\n", + "\n", + "# # GW only hardening\n", + "hard=holo.hardening.Hard_GW()\n", + "\n", + "# # Fixed Time (phenomenological) hardening\n", + "# hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", + "\n", + "assert isinstance(hard, (holo.hardening.Fixed_Time_2PL_SAM, holo.hardening.Hard_GW))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Set the number of realizations and loudest sources" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "NREALS = 30 # Set the number of strain realizations\n", + "NLOUDEST = 10 # set the number of loudest single sources to distinguish at each frequency" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Calculate the characteristic strain of the single sources and background\n", + "* hc_ss is shape [F,R,L] = [nfrequencies, nreals, nloudest], and gives the characteristic strain of each individual loudest source\n", + "* hc_bg is shape [F,R] and gives the sum of the char strain from all other sources at each frequency" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "hc_ss, hc_bg, = sam.gwb(fobs_gw_edges, hard=hard, \n", + " realize = NREALS, loudest = NLOUDEST)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "nsamp = 5\n", + "\n", + "fig, ax = plot.figax(xlabel=plot.LABEL_GW_FREQUENCY_YR, ylabel = plot.LABEL_CHARACTERISTIC_STRAIN)\n", + "\n", + "xx = fobs_gw_cents*YR\n", + "yy = 1e-15 * np.power(xx, -2.0/3.0)\n", + "\n", + "# plot power law, for comparison\n", + "ax.plot(xx, yy, 'k--', alpha=0.5, lw=2.0)\n", + "\n", + "# plot background median and confidence intervals\n", + "ax.plot(xx, np.median(hc_bg, axis=-1), color='tab:blue', alpha = 0.9)\n", + "for pp in [50, 95]:\n", + " percs = [50-pp/2, 50+pp/2]\n", + " ax.fill_between(xx, *np.percentile(hc_bg, percs, axis=-1), alpha=0.25, color='tab:blue')\n", + "\n", + "# plot random realizations\n", + "nsamp = np.min([nsamp, NREALS])\n", + "colors = cm.rainbow(np.linspace(0,1,nsamp))\n", + "idx = np.random.choice(NREALS, nsamp, replace=False)\n", + "\n", + "ci = 0\n", + "for ii in idx:\n", + " # background\n", + " ax.plot(xx, hc_bg[:,ii], ':', color=colors[ci], alpha=0.75)\n", + "\n", + " # single sources\n", + " ax.scatter(np.repeat(xx, NLOUDEST), hc_ss[:,ii,:].flatten(), alpha=0.25, color=colors[ci])\n", + " ci += 1\n", + "\n", + "# Add nHz axis\n", + "plot._twin_hz(ax, nano=True)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "holo310", + "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.10" + }, + "vscode": { + "interpreter": { + "hash": "b691867a38f678e88325b7be712686862775b0bc37454cc33917ba725d804d99" + } + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From fa2a56012b44128b62f83c529347f750cb1eac53 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 22 Jul 2023 15:33:35 -0500 Subject: [PATCH 290/291] Move ss demo from ecg to notebooks. --- ecg-notebooks/single_sources/ss_demo.ipynb | 152 --------------------- 1 file changed, 152 deletions(-) delete mode 100644 ecg-notebooks/single_sources/ss_demo.ipynb diff --git a/ecg-notebooks/single_sources/ss_demo.ipynb b/ecg-notebooks/single_sources/ss_demo.ipynb deleted file mode 100644 index 9accbb1d..00000000 --- a/ecg-notebooks/single_sources/ss_demo.ipynb +++ /dev/null @@ -1,152 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# %load ../init.ipy\n", - "%reload_ext autoreload\n", - "%autoreload 2\n", - "from importlib import reload\n", - "\n", - "import numpy as np\n", - "import holodeck as holo\n", - "from holodeck import plot, utils" - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Build Semi-Analytic Model, sam\n", - "Select a shape (smaller for speed, larger for accuracy, best with None) and use defaults for all other parameters (GSMF, GMT, MMbulge) in sam" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# SHAPE = None # default shape, if None, is 91,81,101.\n", - "SHAPE = 40 # make this smaller to run faster, for debugging\n", - "\n", - "# get PTA frequencies\n", - "fobs_gw_cents, fobs_gw_edges = utils.pta_freqs()\n", - "\n", - "# build Semi-Analytic Model\n", - "sam = holo.sams.Semi_Analytic_Model(shape=SHAPE) " - ] - }, - { - "attachments": {}, - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Calculate SS and GWB strain with sam.gwb()\n", - "This function calls single_sources.ss_gws_redz().\n", - "\n", - "### Choose a hardening model" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# uncomment one of the following hardening models\n", - "\n", - "# # GW only hardening\n", - "hard=holo.hardening.Hard_GW()\n", - "\n", - "# # Fixed Time (phenomenological) hardening\n", - "# hard = holo.hardening.Fixed_Time_2PL_SAM(sam, 3*GYR)\n", - "\n", - "assert isinstance(hard, (holo.hardening.Fixed_Time_2PL_SAM, holo.hardening.Hard_GW))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Set the number of realizations and loudest sources" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "NREALS = 30 # Set the number of strain realizations\n", - "NLOUDEST = 1000 # set the number of loudest single sources to distinguish at each frequency" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Calculate the characteristic strain of the single sources and background\n", - "* hc_ss is shape [F,R,L] = [nfrequencies, nreals, nloudest], and gives the characteristic strain of each individual loudest source\n", - "* hc_bg is shape [F,R] and gives the sum of the char strain from all other sources at each frequency" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "hc_ss, hc_bg, = sam.gwb(fobs_gw_edges, hard=hard, \n", - " realize = NREALS, loudest = NLOUDEST)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Plot" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "fig = plot.plot_bg_ss(fobs_gw_cents, hc_bg, hc_ss[:,:,:100]) # just plot 100 loudest" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "holo310", - "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.10" - }, - "vscode": { - "interpreter": { - "hash": "b691867a38f678e88325b7be712686862775b0bc37454cc33917ba725d804d99" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} From 81528b7d0e6e14044684434c1fef83aa15409e85 Mon Sep 17 00:00:00 2001 From: Emiko Date: Sat, 22 Jul 2023 15:33:57 -0500 Subject: [PATCH 291/291] Clean up debugging print statements in cyutils." " --- holodeck/cyutils.pyx | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/holodeck/cyutils.pyx b/holodeck/cyutils.pyx index 87d785ce..08f3dc08 100644 --- a/holodeck/cyutils.pyx +++ b/holodeck/cyutils.pyx @@ -926,7 +926,6 @@ def ss_bg_hc(number, h2fdf, nreals, normal_threshold=1e10): cdef np.ndarray[np.longlong_t, ndim=3] ssidx = np.zeros((3,F,R), dtype=int) _ss_bg_hc(shape, h2fdf, number, nreals, normal_threshold, hc2ss, hc2bg, ssidx) - # print(hc2ss, hc2bg, ssidx) return hc2ss, hc2bg, ssidx @cython.boundscheck(False) @@ -1010,8 +1009,6 @@ cdef void _ss_bg_hc(long[:] shape, double[:,:,:,:] h2fdf, double[:,:,:,:] number ssidx[0,ff,rr] = m_max ssidx[1,ff,rr] = q_max ssidx[2,ff,rr] = z_max - if (max==0): - print('No sources found at %dth frequency' % ff) # could warn # still need to sqrt and sum! (or do this back in python) return @@ -1062,7 +1059,6 @@ def ss_bg_hc_and_par(number, h2fdf, nreals, mt, mr, rz, normal_threshold=1e10): _ss_bg_hc_and_par(shape, h2fdf, number, nreals, normal_threshold, mt, mr, rz, hc2ss, hc2bg, ssidx, bgpar, sspar) - # print(hc2ss, hc2bg, ssidx) return hc2ss, hc2bg, ssidx, bgpar, sspar @cython.boundscheck(True) @@ -1181,22 +1177,6 @@ cdef void _ss_bg_hc_and_par(long[:] shape, double[:,:,:,:] h2fdf, double[:,:,:,: return - -def test_sort(): - _test_sort() - return None - -cdef void _test_sort(): - cdef double test[4] - test[:] = [1.0, -2.3, 7.8, 0.0] - cdef (int *)indices = malloc(4 * sizeof(int)) - print(test) - - argsort(test, 4, &indices) - print(test) - print(test[indices[0]], test[indices[1]], test[indices[2]], test[indices[3]]) - return - def sort_h2fdf(h2fdf): """ Get indices of sorted h2fdf. Parameters @@ -1786,14 +1766,6 @@ cdef void _loudest_hc_and_par_from_sorted_redz(long[:] shape, double[:,:,:,:] h2 bgpar[5,ff,rr] = sepa_bg/sum_bg # bg avg binary separation after hardening bgpar[6,ff,rr] = angs_bg/sum_bg # bg avg binary angular separation after hardening - # for ff in range(len(sspar[3])): - # for rr in range(len(sspar[3,0])): - # for ll in range(len(sspar[3,0,0])): - # if (sspar[3,ff,rr,ll]<0 and sspar[3,ff,rr,ll] !=-1): - # err = f"sspar[3,{ff},{rr},{ll}] = {sspar[3,ff,rr,ll]} < 0" - # raise ValueError(err) - print("skipped sspar[3] check in _loudest_hc_and_par_from_sorted_redz") -