From ea673b7e1a4f94c9251f0a636b67f434297ffe6d Mon Sep 17 00:00:00 2001 From: Vitor Shen <17490173+shenvitor@users.noreply.github.com> Date: Tue, 27 Aug 2024 14:59:38 +0200 Subject: [PATCH 01/17] initial commit l intslider --- docs/eta-pi-p/manual.ipynb | 26 ++++++++++++++++++++++---- pyproject.toml | 1 + 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index cd4b6c0..987a47a 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -626,13 +626,30 @@ "### Dalitz Plot" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "w.IntSlider(\n", + " value=7,\n", + " min=0,\n", + " max=2,\n", + " step=1,\n", + " description=\"ℓ\",\n", + " disabled=False,\n", + " continuous_update=False,\n", + " orientation=\"horizontal\",\n", + " readout=True,\n", + " readout_format=\"d\",\n", + ")" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "tags": [ "hide-input", "scroll-input" @@ -720,7 +737,8 @@ " w.VBox(categorized_cphi_pair[i]),\n", " ])\n", " tab_contents.append(tab_content)\n", - "UI = w.Tab(tab_contents, titles=resonances_name)" + "UI = w.Tab(tab_contents, titles=resonances_name)\n", + "UI" ] }, { diff --git a/pyproject.toml b/pyproject.toml index 00c3b80..db7ad2a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,6 +119,7 @@ split-on-trailing-comma = false "PLC2701", "PLR2004", "PLW0603", + "RUF001", "S101", "T201", "TCH", From 6e571f6a37e37f74ebefc3f7da5e56e93988a0a3 Mon Sep 17 00:00:00 2001 From: Vitor Shen <17490173+shenvitor@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:21:43 +0200 Subject: [PATCH 02/17] put l_slider above UI --- docs/eta-pi-p/manual.ipynb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 987a47a..294ae3c 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -632,7 +632,7 @@ "metadata": {}, "outputs": [], "source": [ - "w.IntSlider(\n", + "l_slider = w.IntSlider(\n", " value=7,\n", " min=0,\n", " max=2,\n", @@ -737,7 +737,8 @@ " w.VBox(categorized_cphi_pair[i]),\n", " ])\n", " tab_contents.append(tab_content)\n", - "UI = w.Tab(tab_contents, titles=resonances_name)\n", + "UI_1 = w.Tab(tab_contents, titles=resonances_name)\n", + "UI = w.VBox([l_slider, UI_1])\n", "UI" ] }, From bcbed776f05c120ed4ae682c82dab2a22111813d Mon Sep 17 00:00:00 2001 From: Vitor Shen <17490173+shenvitor@users.noreply.github.com> Date: Tue, 27 Aug 2024 15:36:49 +0200 Subject: [PATCH 03/17] l12 l23 l32 sliders --- docs/eta-pi-p/manual.ipynb | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 294ae3c..a63844c 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -632,18 +632,43 @@ "metadata": {}, "outputs": [], "source": [ - "l_slider = w.IntSlider(\n", - " value=7,\n", + "l12_slider = w.IntSlider(\n", + " value=2,\n", " min=0,\n", " max=2,\n", " step=1,\n", - " description=\"ℓ\",\n", + " description=\"ℓ₁₂\",\n", " disabled=False,\n", " continuous_update=False,\n", " orientation=\"horizontal\",\n", " readout=True,\n", " readout_format=\"d\",\n", - ")" + ")\n", + "l23_slider = w.IntSlider(\n", + " value=1,\n", + " min=0,\n", + " max=2,\n", + " step=1,\n", + " description=\"ℓ₂₃\",\n", + " disabled=False,\n", + " continuous_update=False,\n", + " orientation=\"horizontal\",\n", + " readout=True,\n", + " readout_format=\"d\",\n", + ")\n", + "l31_slider = w.IntSlider(\n", + " value=0,\n", + " min=0,\n", + " max=2,\n", + " step=1,\n", + " description=\"ℓ₃₁\",\n", + " disabled=False,\n", + " continuous_update=False,\n", + " orientation=\"horizontal\",\n", + " readout=True,\n", + " readout_format=\"d\",\n", + ")\n", + "UI_lsliders = w.HBox([l31_slider, l23_slider, l12_slider])" ] }, { @@ -730,7 +755,7 @@ " raise NotImplementedError(symbol.name)\n", "\n", "tab_contents = []\n", - "resonances_name = [\"N*\", \"Δ⁺\", \"a₂\"]\n", + "resonances_name = [\"N* [pη (31)]\", \"Δ⁺ [π⁰p(23)]\", \"a₂ [ηπ⁰(12)]\"]\n", "for i in range(len(resonances_name)):\n", " tab_content = w.VBox([\n", " w.HBox(categorized_sliders_m[i] + categorized_sliders_gamma[i]),\n", @@ -738,7 +763,7 @@ " ])\n", " tab_contents.append(tab_content)\n", "UI_1 = w.Tab(tab_contents, titles=resonances_name)\n", - "UI = w.VBox([l_slider, UI_1])\n", + "UI = w.VBox([UI_lsliders, UI_1])\n", "UI" ] }, From dede7e0968ca10bb53f101019ee830b7f89af0e0 Mon Sep 17 00:00:00 2001 From: Vitor Shen <17490173+shenvitor@users.noreply.github.com> Date: Tue, 27 Aug 2024 18:06:29 +0200 Subject: [PATCH 04/17] add symbolic A12_l A23_l A31_l --- docs/eta-pi-p/manual.ipynb | 203 ++++++++++++++++++++++++++++++++----- 1 file changed, 180 insertions(+), 23 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index a63844c..665b233 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -103,6 +103,15 @@ "## Model implementation" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "l_max = 2" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -126,6 +135,35 @@ "A12" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s12, m_a2, gamma_a2, l12 = sp.symbols(r\"s_{12} m_{a_2} \\Gamma_{a_2} l_{12}\")\n", + "theta1, phi1 = sp.symbols(\"theta_1 phi_1\")\n", + "a = sp.IndexedBase(\"a\")\n", + "m = sp.symbols(\"m\", cls=sp.Idx)\n", + "A12_l = sp.Sum(a[m] * sp.Ynm(l12, m, theta1, phi1), (m, -l_max, l_max)) / (\n", + " s12 - m_a2**2 + sp.I * m_a2 * gamma_a2\n", + ")\n", + "A12_l" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "tags": [ + "hide-cell" + ] + }, + "outputs": [], + "source": [ + "A12.expand(func=True)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -174,6 +212,19 @@ "A12_func" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "A12_l_func = sp.lambdify(\n", + " [s12, a[-2], a[-1], a[0], a[1], a[2], l12, m_a2, gamma_a2, theta1, phi1],\n", + " A12_l.doit().expand(func=True),\n", + ")\n", + "A12_l_func" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -197,6 +248,24 @@ "A23" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "s23, m_delta, gamma_delta, l23 = sp.symbols(\n", + " r\"s_{23} m_{\\Delta^+} \\Gamma_{\\Delta^+} l_{23}\"\n", + ")\n", + "b = sp.IndexedBase(\"b\")\n", + "m = sp.symbols(\"m\", cls=sp.Idx)\n", + "theta2, phi2 = sp.symbols(\"theta_2 phi_2\")\n", + "A23_l = sp.Sum(b[m] * sp.Ynm(l23, m, theta2, phi2), (m, -l_max, l_max)) / (\n", + " s23 - m_delta**2 + sp.I * m_delta * gamma_delta\n", + ")\n", + "A23_l" + ] + }, { "cell_type": "code", "execution_count": null, @@ -206,7 +275,21 @@ "A23_func = sp.lambdify(\n", " [s23, b[-1], b[0], b[1], m_delta, gamma_delta, theta2, phi2],\n", " A23.doit().expand(func=True),\n", - ")" + ")\n", + "A23_func" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "A23_l_func = sp.lambdify(\n", + " [s23, b[-2], b[-1], b[0], b[1], b[2], l23, m_delta, gamma_delta, theta2, phi2],\n", + " A23_l.doit().expand(func=True),\n", + ")\n", + "A23_l_func" ] }, { @@ -247,7 +330,7 @@ }, "outputs": [], "source": [ - "theta3, phi3 = sp.symbols(\"theta_3 phi_3\")\n", + "theta3, phi3, l31 = sp.symbols(\"theta_3 phi_3 l_{31}\")\n", "sp.Sum(c[m] * sp.Ynm(0, m, theta3, phi3), (m, 0, 0)) / (\n", " s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", ")" @@ -259,7 +342,36 @@ "metadata": {}, "outputs": [], "source": [ - "A31_func = sp.lambdify([s31, c[0], m_nstar, gamma_nstar], A31)" + "A31_l = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l_max, l_max)) / (\n", + " s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", + ")\n", + "A31_l" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "A31_func = sp.lambdify(\n", + " [s31, c[0], m_nstar, gamma_nstar],\n", + " A31.doit().expand(func=True),\n", + ")\n", + "A31_func" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "A31_l_func = sp.lambdify(\n", + " [s31, c[-2], c[-1], c[0], c[1], c[2], l31, m_nstar, gamma_nstar, theta3, phi3],\n", + " A31_l.doit().expand(func=True),\n", + ")\n", + "A31_l_func" ] }, { @@ -443,47 +555,68 @@ "### Parameters" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range(-2, 3):\n", + " print(i)" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ + "# ruff: noqa: ERA001\n", "a_vals = [0, 0.5, 3.5, 4, 2.5]\n", - "b_vals = [-1.5, 4, 0.5]\n", - "c0_val = 2.5\n", + "b_vals = [0, -1.5, 4, 0.5, 0]\n", + "c_vals = [0, 0, 2.5, 0, 0]\n", "m_a2_val = 1.32\n", "m_delta_val = 1.54\n", "m_nstar_val = 1.87\n", "gamma_a2_val = 0.1\n", "gamma_delta_val = 0.1\n", "gamma_nstar_val = 0.1\n", + "l12_val = 2\n", + "l23_val = 1\n", + "l31_val = 0\n", "\n", "parameters_default = {\n", - " a[-2]: a_vals[0],\n", - " a[-1]: a_vals[1],\n", - " a[0]: a_vals[2],\n", - " a[1]: a_vals[3],\n", - " a[2]: a_vals[4],\n", - " b[-1]: b_vals[0],\n", - " b[0]: b_vals[1],\n", - " b[1]: b_vals[2],\n", - " c[0]: c0_val,\n", + " # a[-2]: a_vals[0],\n", + " # a[-1]: a_vals[1],\n", + " # a[0]: a_vals[2],\n", + " # a[1]: a_vals[3],\n", + " # a[2]: a_vals[4],\n", + " # b[-1]: b_vals[0],\n", + " # b[0]: b_vals[1],\n", + " # b[1]: b_vals[2],\n", + " # c[0]: c0_val,\n", " m_a2: m_a2_val,\n", " m_delta: m_delta_val,\n", " m_nstar: m_nstar_val,\n", " gamma_a2: gamma_a2_val,\n", " gamma_delta: gamma_delta_val,\n", " gamma_nstar: gamma_nstar_val,\n", + " l12: l12_val,\n", + " l23: l23_val,\n", + " l31: l31_val,\n", "}\n", "\n", + "a_dict = {a[i]: a_vals[i + l_max] for i in range(-l_max, l_max + 1)}\n", + "b_dict = {b[i]: b_vals[i + l_max] for i in range(-l_max, l_max + 1)}\n", + "c_dict = {c[i]: c_vals[i + l_max] for i in range(-l_max, l_max + 1)}\n", + "parameters_default.update(a_dict)\n", + "parameters_default.update(b_dict)\n", + "parameters_default.update(c_dict)\n", + "\n", "Latex(aslatex(parameters_default))" ] }, @@ -505,11 +638,29 @@ }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "jp-MarkdownHeadingCollapsed": true + }, "source": [ "### Model components" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# ruff: noqa: ERA001\n", + "\n", + "phi = np.pi / 4\n", + "theta = np.pi / 4\n", + "s_values = np.linspace(0, 5, num=500)\n", + "A12_values = A12_func(s_values, *a_vals, m_a2_val, gamma_a2_val, theta, phi)\n", + "A23_values = A23_func(s_values, *b_vals[1:4], m_delta_val, gamma_delta_val, theta, phi)\n", + "A31_values = A31_func(s_values, c_vals[2], m_nstar_val, gamma_nstar_val)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -520,8 +671,8 @@ "theta = np.pi / 4\n", "s_values = np.linspace(0, 5, num=500)\n", "A12_values = A12_func(s_values, *a_vals, m_a2_val, gamma_a2_val, theta, phi)\n", - "A23_values = A23_func(s_values, *b_vals, m_delta_val, gamma_delta_val, theta, phi)\n", - "A31_values = A31_func(s_values, c0_val, m_nstar_val, gamma_nstar_val)" + "A23_values = A23_func(s_values, *b_vals[1:4], m_delta_val, gamma_delta_val, theta, phi)\n", + "A31_values = A31_func(s_values, c_vals[2], m_nstar_val, gamma_nstar_val)" ] }, { @@ -629,7 +780,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + } + }, "outputs": [], "source": [ "l12_slider = w.IntSlider(\n", @@ -682,6 +837,7 @@ }, "outputs": [], "source": [ + "# ruff: noqa: ERA001\n", "sliders = {}\n", "categorized_sliders_m = defaultdict(list)\n", "categorized_sliders_gamma = defaultdict(list)\n", @@ -722,7 +878,7 @@ " elif symbol.name.startswith(\"m_{a\"):\n", " categorized_sliders_m[2].append(slider)\n", "\n", - " else:\n", + " elif isinstance(symbol, sp.Indexed):\n", " c_latex = sp.latex(symbol)\n", " phi_latex = Rf\"\\phi_{{{c_latex}}}\"\n", " slider_c = w.FloatSlider(\n", @@ -753,7 +909,8 @@ " categorized_cphi_pair[0].append(cphi_hbox)\n", " else:\n", " raise NotImplementedError(symbol.name)\n", - "\n", + " # else:\n", + " # raise NotImplementedError(symbol.name)\n", "tab_contents = []\n", "resonances_name = [\"N* [pη (31)]\", \"Δ⁺ [π⁰p(23)]\", \"a₂ [ηπ⁰(12)]\"]\n", "for i in range(len(resonances_name)):\n", From 7bced3e60cd866e38183abd9304abc1769ea91b3 Mon Sep 17 00:00:00 2001 From: Vitor Shen <17490173+shenvitor@users.noreply.github.com> Date: Fri, 30 Aug 2024 12:03:46 +0200 Subject: [PATCH 05/17] draft v2 --- docs/eta-pi-p/manual.ipynb | 214 +++++++++++++++++++++++++++++++++---- 1 file changed, 196 insertions(+), 18 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 665b233..363fb19 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -41,9 +41,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "mystnb": { "code_prompt_show": "Import Python libraries" }, @@ -151,6 +148,22 @@ "A12_l" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# s12, m_a2, gamma_a2, l12 = sp.symbols(r\"s_{12} m_{a_2} \\Gamma_{a_2} l_{12}\")\n", + "# theta1, phi1 = sp.symbols(\"theta_1 phi_1\")\n", + "# a = sp.IndexedBase(\"a\")\n", + "# m = sp.symbols(\"m\", cls=sp.Idx)\n", + "# A12_l = sp.Sum(a[m] * sp.Ynm(l12, m, theta1, phi1), (m, -l12, l12)) / (\n", + "# s12 - m_a2**2 + sp.I * m_a2 * gamma_a2\n", + "# )\n", + "# A12_l" + ] + }, { "cell_type": "code", "execution_count": null, @@ -221,6 +234,7 @@ "A12_l_func = sp.lambdify(\n", " [s12, a[-2], a[-1], a[0], a[1], a[2], l12, m_a2, gamma_a2, theta1, phi1],\n", " A12_l.doit().expand(func=True),\n", + " modules=[\"scipy\"],\n", ")\n", "A12_l_func" ] @@ -266,6 +280,24 @@ "A23_l" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# s23, m_delta, gamma_delta, l23 = sp.symbols(\n", + "# r\"s_{23} m_{\\Delta^+} \\Gamma_{\\Delta^+} l_{23}\"\n", + "# )\n", + "# b = sp.IndexedBase(\"b\")\n", + "# m = sp.symbols(\"m\", cls=sp.Idx)\n", + "# theta2, phi2 = sp.symbols(\"theta_2 phi_2\")\n", + "# A23_l = sp.Sum(b[m] * sp.Ynm(l23, m, theta2, phi2), (m, -l23, l23)) / (\n", + "# s23 - m_delta**2 + sp.I * m_delta * gamma_delta\n", + "# )\n", + "# A23_l" + ] + }, { "cell_type": "code", "execution_count": null, @@ -288,6 +320,7 @@ "A23_l_func = sp.lambdify(\n", " [s23, b[-2], b[-1], b[0], b[1], b[2], l23, m_delta, gamma_delta, theta2, phi2],\n", " A23_l.doit().expand(func=True),\n", + " modules=[\"scipy\"],\n", ")\n", "A23_l_func" ] @@ -348,6 +381,18 @@ "A31_l" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# A31_l = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l31, l31)) / (\n", + "# s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", + "# )\n", + "# A31_l" + ] + }, { "cell_type": "code", "execution_count": null, @@ -370,6 +415,7 @@ "A31_l_func = sp.lambdify(\n", " [s31, c[-2], c[-1], c[0], c[1], c[2], l31, m_nstar, gamma_nstar, theta3, phi3],\n", " A31_l.doit().expand(func=True),\n", + " modules=[\"scipy\"],\n", ")\n", "A31_l_func" ] @@ -391,6 +437,16 @@ "intensity_expr" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "intensity_expr_l = sp.Abs(A12_l + A23_l + A31_l) ** 2\n", + "intensity_expr_l" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -555,16 +611,6 @@ "### Parameters" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for i in range(-2, 3):\n", - " print(i)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -781,9 +827,10 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - } + "tags": [ + "hide-input", + "scroll-input" + ] }, "outputs": [], "source": [ @@ -842,6 +889,7 @@ "categorized_sliders_m = defaultdict(list)\n", "categorized_sliders_gamma = defaultdict(list)\n", "categorized_cphi_pair = defaultdict(list)\n", + "categorized_sliders_l = defaultdict(list)\n", "\n", "for symbol, value in parameters_default.items():\n", " if symbol.name.startswith(R\"\\Gamma_{\"):\n", @@ -909,8 +957,54 @@ " categorized_cphi_pair[0].append(cphi_hbox)\n", " else:\n", " raise NotImplementedError(symbol.name)\n", - " # else:\n", - " # raise NotImplementedError(symbol.name)\n", + "\n", + " elif symbol.name.startswith(\"l_{12}\"):\n", + " slider = w.IntSlider(\n", + " value=2,\n", + " min=0,\n", + " max=2,\n", + " step=1,\n", + " description=\"ℓ₁₂\",\n", + " disabled=False,\n", + " continuous_update=False,\n", + " orientation=\"horizontal\",\n", + " readout=True,\n", + " readout_format=\"d\",\n", + " )\n", + " sliders[symbol.name] = slider\n", + " categorized_sliders_l[2].append(slider)\n", + " elif symbol.name.startswith(\"l_{23}\"):\n", + " slider = w.IntSlider(\n", + " value=1,\n", + " min=0,\n", + " max=2,\n", + " step=1,\n", + " description=\"ℓ₂₃\",\n", + " disabled=False,\n", + " continuous_update=False,\n", + " orientation=\"horizontal\",\n", + " readout=True,\n", + " readout_format=\"d\",\n", + " )\n", + " sliders[symbol.name] = slider\n", + " categorized_sliders_l[1].append(slider)\n", + " elif symbol.name.startswith(\"l_{31}\"):\n", + " slider = w.IntSlider(\n", + " value=0,\n", + " min=0,\n", + " max=2,\n", + " step=1,\n", + " description=\"ℓ₃₁\",\n", + " disabled=False,\n", + " continuous_update=False,\n", + " orientation=\"horizontal\",\n", + " readout=True,\n", + " readout_format=\"d\",\n", + " )\n", + " sliders[symbol.name] = slider\n", + " categorized_sliders_l[0].append(slider)\n", + " else:\n", + " raise NotImplementedError(symbol.name)\n", "tab_contents = []\n", "resonances_name = [\"N* [pη (31)]\", \"Δ⁺ [π⁰p(23)]\", \"a₂ [ηπ⁰(12)]\"]\n", "for i in range(len(resonances_name)):\n", @@ -919,6 +1013,11 @@ " w.VBox(categorized_cphi_pair[i]),\n", " ])\n", " tab_contents.append(tab_content)\n", + "UI_lsliders = w.HBox([\n", + " *categorized_sliders_l[0],\n", + " *categorized_sliders_l[1],\n", + " *categorized_sliders_l[2],\n", + "])\n", "UI_1 = w.Tab(tab_contents, titles=resonances_name)\n", "UI = w.VBox([UI_lsliders, UI_1])\n", "UI" @@ -947,6 +1046,29 @@ "intensities = intensity_func(phsp)" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "unfolded_expression_l = intensity_expr_l.doit().expand(func=True)\n", + "intensity_func_l = create_parametrized_function(\n", + " expression=unfolded_expression,\n", + " parameters=parameters_default,\n", + " backend=\"jax\",\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "intensities_l = intensity_func_l(phsp)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -975,6 +1097,62 @@ " return updated_parameters" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# intensity_func_l\n", + "%matplotlib widget\n", + "%config InlineBackend.figure_formats = ['png']\n", + "fig_2d, ax_2d = plt.subplots(dpi=200)\n", + "ax_2d.set_title(\"Model-weighted Phase space Dalitz Plot\")\n", + "ax_2d.set_xlabel(R\"$m^2(\\eta \\pi^0)\\;\\left[\\mathrm{GeV}^2\\right]$\")\n", + "ax_2d.set_ylabel(R\"$m^2(\\pi^0 p)\\;\\left[\\mathrm{GeV}^2\\right]$\")\n", + "\n", + "mesh = None\n", + "\n", + "\n", + "def update_histogram(**parameters):\n", + " global mesh\n", + "\n", + " parameters = insert_phi(parameters)\n", + "\n", + " intensity_func_l.update_parameters(parameters)\n", + " intensity_weights = intensity_func_l(phsp)\n", + " bin_values, xedges, yedges = jnp.histogram2d(\n", + " phsp[\"s_{12}\"],\n", + " phsp[\"s_{23}\"],\n", + " bins=200,\n", + " weights=intensity_weights,\n", + " density=True,\n", + " )\n", + " bin_values = jnp.where(bin_values < 1e-6, jnp.nan, bin_values)\n", + " x, y = jnp.meshgrid(xedges[:-1], yedges[:-1])\n", + " if mesh is None:\n", + " mesh = ax_2d.pcolormesh(x, y, bin_values.T, cmap=\"jet\", vmax=0.15)\n", + " else:\n", + " mesh.set_array(bin_values.T)\n", + " fig_2d.canvas.draw_idle()\n", + "\n", + "\n", + "interactive_plot = w.interactive_output(\n", + " update_histogram,\n", + " {**sliders},\n", + ")\n", + "fig_2d.tight_layout()\n", + "fig_2d.colorbar(mesh, ax=ax_2d)\n", + "\n", + "if STATIC_PAGE:\n", + " filename = \"dalitz-plot-man.png\"\n", + " fig_2d.savefig(filename)\n", + " plt.close(fig_2d)\n", + " display(UI, Image(filename))\n", + "else:\n", + " display(UI, interactive_plot)" + ] + }, { "cell_type": "code", "execution_count": null, From 39c5cc66ea2f77d2de6ccac2c5c044a8c8488d0c Mon Sep 17 00:00:00 2001 From: Vitor Shen <17490173+shenvitor@users.noreply.github.com> Date: Fri, 30 Aug 2024 15:10:09 +0200 Subject: [PATCH 06/17] make interactive plots for Ylm --- docs/eta-pi-p/manual.ipynb | 439 ++++++++----------------------------- 1 file changed, 94 insertions(+), 345 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 363fb19..e8418f5 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -41,6 +41,9 @@ "cell_type": "code", "execution_count": null, "metadata": { + "jupyter": { + "source_hidden": true + }, "mystnb": { "code_prompt_show": "Import Python libraries" }, @@ -116,22 +119,6 @@ "### $A^{12}$" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s12, m_a2, gamma_a2 = sp.symbols(r\"s_{12} m_{a_2} \\Gamma_{a_2}\")\n", - "theta1, phi1 = sp.symbols(\"theta_1 phi_1\")\n", - "a = sp.IndexedBase(\"a\")\n", - "m = sp.symbols(\"m\", cls=sp.Idx)\n", - "A12 = sp.Sum(a[m] * sp.Ynm(2, m, theta1, phi1), (m, -2, 2)) / (\n", - " s12 - m_a2**2 + sp.I * m_a2 * gamma_a2\n", - ")\n", - "A12" - ] - }, { "cell_type": "code", "execution_count": null, @@ -142,26 +129,10 @@ "theta1, phi1 = sp.symbols(\"theta_1 phi_1\")\n", "a = sp.IndexedBase(\"a\")\n", "m = sp.symbols(\"m\", cls=sp.Idx)\n", - "A12_l = sp.Sum(a[m] * sp.Ynm(l12, m, theta1, phi1), (m, -l_max, l_max)) / (\n", + "A12 = sp.Sum(a[m] * sp.Ynm(l12, m, theta1, phi1), (m, -l12, l12)) / (\n", " s12 - m_a2**2 + sp.I * m_a2 * gamma_a2\n", ")\n", - "A12_l" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# s12, m_a2, gamma_a2, l12 = sp.symbols(r\"s_{12} m_{a_2} \\Gamma_{a_2} l_{12}\")\n", - "# theta1, phi1 = sp.symbols(\"theta_1 phi_1\")\n", - "# a = sp.IndexedBase(\"a\")\n", - "# m = sp.symbols(\"m\", cls=sp.Idx)\n", - "# A12_l = sp.Sum(a[m] * sp.Ynm(l12, m, theta1, phi1), (m, -l12, l12)) / (\n", - "# s12 - m_a2**2 + sp.I * m_a2 * gamma_a2\n", - "# )\n", - "# A12_l" + "A12" ] }, { @@ -187,20 +158,7 @@ }, "outputs": [], "source": [ - "sp.Ynm(2, 1, 1, 1).expand(func=False)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [ - "hide-cell" - ] - }, - "outputs": [], - "source": [ - "sp.Ynm(2, 1, 1, 1).expand(func=True)" + "A12.expand(func=False)" ] }, { @@ -218,25 +176,14 @@ "metadata": {}, "outputs": [], "source": [ - "A12_func = sp.lambdify(\n", - " [s12, a[-2], a[-1], a[0], a[1], a[2], m_a2, gamma_a2, theta1, phi1],\n", - " A12.doit().expand(func=True),\n", - ")\n", - "A12_func" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A12_l_func = sp.lambdify(\n", - " [s12, a[-2], a[-1], a[0], a[1], a[2], l12, m_a2, gamma_a2, theta1, phi1],\n", - " A12_l.doit().expand(func=True),\n", - " modules=[\"scipy\"],\n", - ")\n", - "A12_l_func" + "A12_funcs = [\n", + " sp.lambdify(\n", + " [s12, *(a[j] for j in range(-l_max, l_max + 1)), m_a2, gamma_a2, theta1, phi1],\n", + " expr=A12.subs(l12, i).doit().expand(func=True),\n", + " )\n", + " for i in range(l_max + 1)\n", + "]\n", + "A12_funcs" ] }, { @@ -246,22 +193,6 @@ "### $A^{23}$" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "s23, m_delta, gamma_delta = sp.symbols(r\"s_{23} m_{\\Delta^+} \\Gamma_{\\Delta^+}\")\n", - "b = sp.IndexedBase(\"b\")\n", - "m = sp.symbols(\"m\", cls=sp.Idx)\n", - "theta2, phi2 = sp.symbols(\"theta_2 phi_2\")\n", - "A23 = sp.Sum(b[m] * sp.Ynm(1, m, theta2, phi2), (m, -1, 1)) / (\n", - " s23 - m_delta**2 + sp.I * m_delta * gamma_delta\n", - ")\n", - "A23" - ] - }, { "cell_type": "code", "execution_count": null, @@ -274,41 +205,10 @@ "b = sp.IndexedBase(\"b\")\n", "m = sp.symbols(\"m\", cls=sp.Idx)\n", "theta2, phi2 = sp.symbols(\"theta_2 phi_2\")\n", - "A23_l = sp.Sum(b[m] * sp.Ynm(l23, m, theta2, phi2), (m, -l_max, l_max)) / (\n", + "A23 = sp.Sum(b[m] * sp.Ynm(l23, m, theta2, phi2), (m, -l23, l23)) / (\n", " s23 - m_delta**2 + sp.I * m_delta * gamma_delta\n", ")\n", - "A23_l" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# s23, m_delta, gamma_delta, l23 = sp.symbols(\n", - "# r\"s_{23} m_{\\Delta^+} \\Gamma_{\\Delta^+} l_{23}\"\n", - "# )\n", - "# b = sp.IndexedBase(\"b\")\n", - "# m = sp.symbols(\"m\", cls=sp.Idx)\n", - "# theta2, phi2 = sp.symbols(\"theta_2 phi_2\")\n", - "# A23_l = sp.Sum(b[m] * sp.Ynm(l23, m, theta2, phi2), (m, -l23, l23)) / (\n", - "# s23 - m_delta**2 + sp.I * m_delta * gamma_delta\n", - "# )\n", - "# A23_l" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A23_func = sp.lambdify(\n", - " [s23, b[-1], b[0], b[1], m_delta, gamma_delta, theta2, phi2],\n", - " A23.doit().expand(func=True),\n", - ")\n", - "A23_func" + "A23" ] }, { @@ -317,12 +217,21 @@ "metadata": {}, "outputs": [], "source": [ - "A23_l_func = sp.lambdify(\n", - " [s23, b[-2], b[-1], b[0], b[1], b[2], l23, m_delta, gamma_delta, theta2, phi2],\n", - " A23_l.doit().expand(func=True),\n", - " modules=[\"scipy\"],\n", - ")\n", - "A23_l_func" + "A23_funcs = [\n", + " sp.lambdify(\n", + " [\n", + " s23,\n", + " *(b[j] for j in range(-l_max, l_max + 1)),\n", + " m_delta,\n", + " gamma_delta,\n", + " theta2,\n", + " phi2,\n", + " ],\n", + " A23.subs(l23, i).doit().expand(func=True),\n", + " )\n", + " for i in range(l_max + 1)\n", + "]\n", + "A23_funcs" ] }, { @@ -375,35 +284,10 @@ "metadata": {}, "outputs": [], "source": [ - "A31_l = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l_max, l_max)) / (\n", + "A31 = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l31, l31)) / (\n", " s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", ")\n", - "A31_l" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# A31_l = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l31, l31)) / (\n", - "# s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", - "# )\n", - "# A31_l" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "A31_func = sp.lambdify(\n", - " [s31, c[0], m_nstar, gamma_nstar],\n", - " A31.doit().expand(func=True),\n", - ")\n", - "A31_func" + "A31" ] }, { @@ -412,12 +296,21 @@ "metadata": {}, "outputs": [], "source": [ - "A31_l_func = sp.lambdify(\n", - " [s31, c[-2], c[-1], c[0], c[1], c[2], l31, m_nstar, gamma_nstar, theta3, phi3],\n", - " A31_l.doit().expand(func=True),\n", - " modules=[\"scipy\"],\n", - ")\n", - "A31_l_func" + "A31_funcs = [\n", + " sp.lambdify(\n", + " [\n", + " s31,\n", + " *(c[j] for j in range(-l_max, l_max + 1)),\n", + " m_nstar,\n", + " gamma_nstar,\n", + " theta3,\n", + " phi3,\n", + " ],\n", + " A31.subs(l31, i).doit().expand(func=True),\n", + " )\n", + " for i in range(l_max + 1)\n", + "]\n", + "A31_funcs" ] }, { @@ -437,16 +330,6 @@ "intensity_expr" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "intensity_expr_l = sp.Abs(A12_l + A23_l + A31_l) ** 2\n", - "intensity_expr_l" - ] - }, { "cell_type": "markdown", "metadata": {}, @@ -615,13 +498,15 @@ "cell_type": "code", "execution_count": null, "metadata": { + "jupyter": { + "source_hidden": true + }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ - "# ruff: noqa: ERA001\n", "a_vals = [0, 0.5, 3.5, 4, 2.5]\n", "b_vals = [0, -1.5, 4, 0.5, 0]\n", "c_vals = [0, 0, 2.5, 0, 0]\n", @@ -636,15 +521,6 @@ "l31_val = 0\n", "\n", "parameters_default = {\n", - " # a[-2]: a_vals[0],\n", - " # a[-1]: a_vals[1],\n", - " # a[0]: a_vals[2],\n", - " # a[1]: a_vals[3],\n", - " # a[2]: a_vals[4],\n", - " # b[-1]: b_vals[0],\n", - " # b[0]: b_vals[1],\n", - " # b[1]: b_vals[2],\n", - " # c[0]: c0_val,\n", " m_a2: m_a2_val,\n", " m_delta: m_delta_val,\n", " m_nstar: m_nstar_val,\n", @@ -691,22 +567,6 @@ "### Model components" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# ruff: noqa: ERA001\n", - "\n", - "phi = np.pi / 4\n", - "theta = np.pi / 4\n", - "s_values = np.linspace(0, 5, num=500)\n", - "A12_values = A12_func(s_values, *a_vals, m_a2_val, gamma_a2_val, theta, phi)\n", - "A23_values = A23_func(s_values, *b_vals[1:4], m_delta_val, gamma_delta_val, theta, phi)\n", - "A31_values = A31_func(s_values, c_vals[2], m_nstar_val, gamma_nstar_val)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -716,9 +576,9 @@ "phi = np.pi / 4\n", "theta = np.pi / 4\n", "s_values = np.linspace(0, 5, num=500)\n", - "A12_values = A12_func(s_values, *a_vals, m_a2_val, gamma_a2_val, theta, phi)\n", - "A23_values = A23_func(s_values, *b_vals[1:4], m_delta_val, gamma_delta_val, theta, phi)\n", - "A31_values = A31_func(s_values, c_vals[2], m_nstar_val, gamma_nstar_val)" + "A12_values = A12_funcs[2](s_values, *a_vals, m_a2_val, gamma_a2_val, theta, phi)\n", + "A23_values = A23_funcs[1](s_values, *b_vals, m_delta_val, gamma_delta_val, theta, phi)\n", + "A31_values = A31_funcs[0](s_values, *c_vals, m_nstar_val, gamma_nstar_val, theta, phi)" ] }, { @@ -827,6 +687,9 @@ "cell_type": "code", "execution_count": null, "metadata": { + "jupyter": { + "source_hidden": true + }, "tags": [ "hide-input", "scroll-input" @@ -834,57 +697,6 @@ }, "outputs": [], "source": [ - "l12_slider = w.IntSlider(\n", - " value=2,\n", - " min=0,\n", - " max=2,\n", - " step=1,\n", - " description=\"ℓ₁₂\",\n", - " disabled=False,\n", - " continuous_update=False,\n", - " orientation=\"horizontal\",\n", - " readout=True,\n", - " readout_format=\"d\",\n", - ")\n", - "l23_slider = w.IntSlider(\n", - " value=1,\n", - " min=0,\n", - " max=2,\n", - " step=1,\n", - " description=\"ℓ₂₃\",\n", - " disabled=False,\n", - " continuous_update=False,\n", - " orientation=\"horizontal\",\n", - " readout=True,\n", - " readout_format=\"d\",\n", - ")\n", - "l31_slider = w.IntSlider(\n", - " value=0,\n", - " min=0,\n", - " max=2,\n", - " step=1,\n", - " description=\"ℓ₃₁\",\n", - " disabled=False,\n", - " continuous_update=False,\n", - " orientation=\"horizontal\",\n", - " readout=True,\n", - " readout_format=\"d\",\n", - ")\n", - "UI_lsliders = w.HBox([l31_slider, l23_slider, l12_slider])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [ - "hide-input", - "scroll-input" - ] - }, - "outputs": [], - "source": [ - "# ruff: noqa: ERA001\n", "sliders = {}\n", "categorized_sliders_m = defaultdict(list)\n", "categorized_sliders_gamma = defaultdict(list)\n", @@ -1019,31 +831,7 @@ " *categorized_sliders_l[2],\n", "])\n", "UI_1 = w.Tab(tab_contents, titles=resonances_name)\n", - "UI = w.VBox([UI_lsliders, UI_1])\n", - "UI" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "unfolded_expression = intensity_expr.doit().expand(func=True)\n", - "intensity_func = create_parametrized_function(\n", - " expression=unfolded_expression,\n", - " parameters=parameters_default,\n", - " backend=\"jax\",\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "intensities = intensity_func(phsp)" + "UI = w.VBox([UI_lsliders, UI_1])" ] }, { @@ -1052,21 +840,23 @@ "metadata": {}, "outputs": [], "source": [ - "unfolded_expression_l = intensity_expr_l.doit().expand(func=True)\n", - "intensity_func_l = create_parametrized_function(\n", - " expression=unfolded_expression,\n", - " parameters=parameters_default,\n", - " backend=\"jax\",\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "intensities_l = intensity_func_l(phsp)" + "intensity_funcs = np.array([\n", + " [\n", + " [\n", + " create_parametrized_function(\n", + " expression=intensity_expr.xreplace({l12: i, l23: j, l31: k})\n", + " .doit()\n", + " .expand(func=True),\n", + " parameters=parameters_default,\n", + " backend=\"jax\",\n", + " )\n", + " for i in range(l_max + 1)\n", + " ]\n", + " for j in range(l_max + 1)\n", + " ]\n", + " for k in range(l_max + 1)\n", + "])\n", + "intensity_funcs.shape" ] }, { @@ -1097,62 +887,6 @@ " return updated_parameters" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# intensity_func_l\n", - "%matplotlib widget\n", - "%config InlineBackend.figure_formats = ['png']\n", - "fig_2d, ax_2d = plt.subplots(dpi=200)\n", - "ax_2d.set_title(\"Model-weighted Phase space Dalitz Plot\")\n", - "ax_2d.set_xlabel(R\"$m^2(\\eta \\pi^0)\\;\\left[\\mathrm{GeV}^2\\right]$\")\n", - "ax_2d.set_ylabel(R\"$m^2(\\pi^0 p)\\;\\left[\\mathrm{GeV}^2\\right]$\")\n", - "\n", - "mesh = None\n", - "\n", - "\n", - "def update_histogram(**parameters):\n", - " global mesh\n", - "\n", - " parameters = insert_phi(parameters)\n", - "\n", - " intensity_func_l.update_parameters(parameters)\n", - " intensity_weights = intensity_func_l(phsp)\n", - " bin_values, xedges, yedges = jnp.histogram2d(\n", - " phsp[\"s_{12}\"],\n", - " phsp[\"s_{23}\"],\n", - " bins=200,\n", - " weights=intensity_weights,\n", - " density=True,\n", - " )\n", - " bin_values = jnp.where(bin_values < 1e-6, jnp.nan, bin_values)\n", - " x, y = jnp.meshgrid(xedges[:-1], yedges[:-1])\n", - " if mesh is None:\n", - " mesh = ax_2d.pcolormesh(x, y, bin_values.T, cmap=\"jet\", vmax=0.15)\n", - " else:\n", - " mesh.set_array(bin_values.T)\n", - " fig_2d.canvas.draw_idle()\n", - "\n", - "\n", - "interactive_plot = w.interactive_output(\n", - " update_histogram,\n", - " {**sliders},\n", - ")\n", - "fig_2d.tight_layout()\n", - "fig_2d.colorbar(mesh, ax=ax_2d)\n", - "\n", - "if STATIC_PAGE:\n", - " filename = \"dalitz-plot-man.png\"\n", - " fig_2d.savefig(filename)\n", - " plt.close(fig_2d)\n", - " display(UI, Image(filename))\n", - "else:\n", - " display(UI, interactive_plot)" - ] - }, { "cell_type": "code", "execution_count": null, @@ -1162,7 +896,8 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "scroll-input" ] }, "outputs": [], @@ -1179,7 +914,13 @@ "\n", "def update_histogram(**parameters):\n", " global mesh\n", + "\n", + " l12para = parameters[\"l_{12}\"]\n", + " l23para = parameters[\"l_{23}\"]\n", + " l31para = parameters[\"l_{31}\"]\n", + " intensity_func = intensity_funcs[l12para, l23para, l31para]\n", " parameters = insert_phi(parameters)\n", + "\n", " intensity_func.update_parameters(parameters)\n", " intensity_weights = intensity_func(phsp)\n", " bin_values, xedges, yedges = jnp.histogram2d(\n", @@ -1189,7 +930,7 @@ " weights=intensity_weights,\n", " density=True,\n", " )\n", - " bin_values = jnp.where(bin_values < 1e-6, jnp.nan, bin_values)\n", + " bin_values = jnp.where(bin_values < 1e-10, jnp.nan, bin_values)\n", " x, y = jnp.meshgrid(xedges[:-1], yedges[:-1])\n", " if mesh is None:\n", " mesh = ax_2d.pcolormesh(x, y, bin_values.T, cmap=\"jet\", vmax=0.15)\n", @@ -1198,7 +939,10 @@ " fig_2d.canvas.draw_idle()\n", "\n", "\n", - "interactive_plot = w.interactive_output(update_histogram, sliders)\n", + "interactive_plot = w.interactive_output(\n", + " update_histogram,\n", + " {**sliders},\n", + ")\n", "fig_2d.tight_layout()\n", "fig_2d.colorbar(mesh, ax=ax_2d)\n", "\n", @@ -1227,7 +971,8 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "scroll-input" ] }, "outputs": [], @@ -1277,6 +1022,10 @@ "\n", "\n", "def update_plot(**parameters): # noqa: C901, PLR0912, PLR0914\n", + " l12para = parameters[\"l_{12}\"]\n", + " l23para = parameters[\"l_{23}\"]\n", + " l31para = parameters[\"l_{31}\"]\n", + " intensity_func = intensity_funcs[l12para, l23para, l31para]\n", " parameters = insert_phi(parameters)\n", " intensity_func.update_parameters(parameters)\n", " intensities = intensity_func(phsp)\n", From f0d191ce84130ccad9ce076f5ba29a8e689dd068 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:23:28 +0200 Subject: [PATCH 07/17] DOC: add text to hidden input code cells --- docs/eta-pi-p/manual.ipynb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index e8418f5..9343a30 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -390,6 +390,9 @@ "jupyter": { "source_hidden": true }, + "mystnb": { + "code_prompt_show": "Helper functions for formulating symbolic kinematics" + }, "tags": [ "hide-cell" ] @@ -690,6 +693,9 @@ "jupyter": { "source_hidden": true }, + "mystnb": { + "code_prompt_show": "Slider definitions" + }, "tags": [ "hide-input", "scroll-input" @@ -866,6 +872,9 @@ "jupyter": { "source_hidden": true }, + "mystnb": { + "code_prompt_show": "Function for making merging sliders into complex values" + }, "tags": [ "hide-input" ] From 5e9c48f63e3e2a83b0ef168c1beb087986992813 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:23:28 +0200 Subject: [PATCH 08/17] DX: remove repetition of chapter title The title is automatically imported from cited document --- docs/eta-pi-p/manual.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 9343a30..2a86799 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This section is a follow-up of previous chapter:[Reaction and Models](reaction-model.md), to formulate the amplitude model for the $\\gamma p \\to \\eta\\pi^0 p$ channel example symbolically. See **[TR‑033](https://compwa.github.io/report/033)** for a purely numerical tutorial.\n", + "This section is a follow-up of the previous chapter, [](reaction-model.md), to formulate the amplitude model for the $\\gamma p \\to \\eta\\pi^0 p$ channel example symbolically. See **[TR‑033](https://compwa.github.io/report/033)** for a purely numerical tutorial.\n", "\n", "The model we want to implement is" ] From e004766897d73f4731fdd52dd6affd60dfd7bac4 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:23:29 +0200 Subject: [PATCH 09/17] DOC: remove try cells from Sphinx build --- docs/eta-pi-p/manual.ipynb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 2a86799..5d1c7bb 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -140,7 +140,7 @@ "execution_count": null, "metadata": { "tags": [ - "hide-cell" + "remove-cell" ] }, "outputs": [], @@ -153,7 +153,7 @@ "execution_count": null, "metadata": { "tags": [ - "hide-cell" + "remove-cell" ] }, "outputs": [], @@ -164,7 +164,11 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "tags": [ + "remove-cell" + ] + }, "outputs": [], "source": [ "A12.free_symbols" From 67a3fae6dc3a7407f3645a1364335f83c5b4cdd9 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:23:30 +0200 Subject: [PATCH 10/17] DOC: do not show lambdified functions --- docs/eta-pi-p/manual.ipynb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 5d1c7bb..219e679 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -186,8 +186,7 @@ " expr=A12.subs(l12, i).doit().expand(func=True),\n", " )\n", " for i in range(l_max + 1)\n", - "]\n", - "A12_funcs" + "]" ] }, { @@ -234,8 +233,7 @@ " A23.subs(l23, i).doit().expand(func=True),\n", " )\n", " for i in range(l_max + 1)\n", - "]\n", - "A23_funcs" + "]" ] }, { @@ -313,8 +311,7 @@ " A31.subs(l31, i).doit().expand(func=True),\n", " )\n", " for i in range(l_max + 1)\n", - "]\n", - "A31_funcs" + "]" ] }, { From 5a5f6e25fc15ff7c703f79c7c3ffc8e01cee414a Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:23:31 +0200 Subject: [PATCH 11/17] DOC: merge A31 formulation cells --- docs/eta-pi-p/manual.ipynb | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 219e679..b83da0b 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -249,43 +249,9 @@ "metadata": {}, "outputs": [], "source": [ - "s31, m_nstar, gamma_nstar = sp.symbols(r\"s_{31} m_{N^*} \\Gamma_{N^*}\")\n", "c = sp.IndexedBase(\"c\")\n", - "A31 = c[0] / (s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar)\n", - "A31" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - ":::{tip}\n", - "The expression above is originally deduced from $Y_l^m (\\Omega_3)$ when $l=0$ as shown below, so that the numerator is absorbed and becomes $c_0$.\n", - ":::" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "tags": [ - "hide-input" - ] - }, - "outputs": [], - "source": [ + "s31, m_nstar, gamma_nstar = sp.symbols(r\"s_{31} m_{N^*} \\Gamma_{N^*}\")\n", "theta3, phi3, l31 = sp.symbols(\"theta_3 phi_3 l_{31}\")\n", - "sp.Sum(c[m] * sp.Ynm(0, m, theta3, phi3), (m, 0, 0)) / (\n", - " s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ "A31 = sp.Sum(c[m] * sp.Ynm(l31, m, theta3, phi3), (m, -l31, l31)) / (\n", " s31 - m_nstar**2 + sp.I * m_nstar * gamma_nstar\n", ")\n", From e4d4ee513b7f514309196f54e06edce4d28960aa Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:25:06 +0200 Subject: [PATCH 12/17] FIX: remove redundant dict unpacking --- docs/eta-pi-p/manual.ipynb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index b83da0b..6507d7a 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -915,10 +915,7 @@ " fig_2d.canvas.draw_idle()\n", "\n", "\n", - "interactive_plot = w.interactive_output(\n", - " update_histogram,\n", - " {**sliders},\n", - ")\n", + "interactive_plot = w.interactive_output(update_histogram, sliders)\n", "fig_2d.tight_layout()\n", "fig_2d.colorbar(mesh, ax=ax_2d)\n", "\n", From 2ae0318095bd99387317534192e89355b81d630e Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:25:32 +0200 Subject: [PATCH 13/17] MAINT: remove redundant newlines --- docs/eta-pi-p/manual.ipynb | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 6507d7a..890bbf3 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -890,13 +890,11 @@ "\n", "def update_histogram(**parameters):\n", " global mesh\n", - "\n", " l12para = parameters[\"l_{12}\"]\n", " l23para = parameters[\"l_{23}\"]\n", " l31para = parameters[\"l_{31}\"]\n", " intensity_func = intensity_funcs[l12para, l23para, l31para]\n", " parameters = insert_phi(parameters)\n", - "\n", " intensity_func.update_parameters(parameters)\n", " intensity_weights = intensity_func(phsp)\n", " bin_values, xedges, yedges = jnp.histogram2d(\n", From aa5eba4919d26c63b7c64ede061c2405f0a5087e Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:25:56 +0200 Subject: [PATCH 14/17] MAINT: remove `para` from variable names --- docs/eta-pi-p/manual.ipynb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 890bbf3..ba415c5 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -890,10 +890,10 @@ "\n", "def update_histogram(**parameters):\n", " global mesh\n", - " l12para = parameters[\"l_{12}\"]\n", - " l23para = parameters[\"l_{23}\"]\n", - " l31para = parameters[\"l_{31}\"]\n", - " intensity_func = intensity_funcs[l12para, l23para, l31para]\n", + " l12 = parameters[\"l_{12}\"]\n", + " l23 = parameters[\"l_{23}\"]\n", + " l31 = parameters[\"l_{31}\"]\n", + " intensity_func = intensity_funcs[l12, l23, l31]\n", " parameters = insert_phi(parameters)\n", " intensity_func.update_parameters(parameters)\n", " intensity_weights = intensity_func(phsp)\n", @@ -993,10 +993,10 @@ "\n", "\n", "def update_plot(**parameters): # noqa: C901, PLR0912, PLR0914\n", - " l12para = parameters[\"l_{12}\"]\n", - " l23para = parameters[\"l_{23}\"]\n", - " l31para = parameters[\"l_{31}\"]\n", - " intensity_func = intensity_funcs[l12para, l23para, l31para]\n", + " l12 = parameters[\"l_{12}\"]\n", + " l23 = parameters[\"l_{23}\"]\n", + " l31 = parameters[\"l_{31}\"]\n", + " intensity_func = intensity_funcs[l12, l23, l31]\n", " parameters = insert_phi(parameters)\n", " intensity_func.update_parameters(parameters)\n", " intensities = intensity_func(phsp)\n", From 4ecf64e80b3c49ba21c61b1388097fe567b183d7 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:28:08 +0200 Subject: [PATCH 15/17] DOC: hide parameter values --- docs/eta-pi-p/manual.ipynb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index ba415c5..81bf3b4 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -472,7 +472,9 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "hide-output", + "scroll-output" ] }, "outputs": [], From 41448438cd08a50d7d3e81f42158229d392f7ec6 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:29:40 +0200 Subject: [PATCH 16/17] MAINT: reduce diff --- docs/eta-pi-p/manual.ipynb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 81bf3b4..8c739fd 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -532,9 +532,7 @@ }, { "cell_type": "markdown", - "metadata": { - "jp-MarkdownHeadingCollapsed": true - }, + "metadata": {}, "source": [ "### Model components" ] From dca7c42a65e687664636ba844838671c60ddd2c6 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Mon, 2 Sep 2024 09:41:18 +0200 Subject: [PATCH 17/17] =?UTF-8?q?DX:=20simplify=20=E2=84=93=20slider=20cre?= =?UTF-8?q?ation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/eta-pi-p/manual.ipynb | 72 +++++++++++++------------------------- 1 file changed, 25 insertions(+), 47 deletions(-) diff --git a/docs/eta-pi-p/manual.ipynb b/docs/eta-pi-p/manual.ipynb index 8c739fd..5e4cce5 100644 --- a/docs/eta-pi-p/manual.ipynb +++ b/docs/eta-pi-p/manual.ipynb @@ -670,11 +670,25 @@ }, "outputs": [], "source": [ + "def format_l_as_unicode(name: str) -> str:\n", + " replacements = {\n", + " \"l\": \"ℓ\",\n", + " \"1\": \"₁\",\n", + " \"2\": \"₂\",\n", + " \"3\": \"₃\",\n", + " \"_{\": \"\",\n", + " \"}\": \"\",\n", + " }\n", + " for old, new in replacements.items():\n", + " name = name.replace(old, new)\n", + " return name\n", + "\n", + "\n", "sliders = {}\n", "categorized_sliders_m = defaultdict(list)\n", "categorized_sliders_gamma = defaultdict(list)\n", "categorized_cphi_pair = defaultdict(list)\n", - "categorized_sliders_l = defaultdict(list)\n", + "categorized_sliders_l = []\n", "\n", "for symbol, value in parameters_default.items():\n", " if symbol.name.startswith(R\"\\Gamma_{\"):\n", @@ -743,68 +757,32 @@ " else:\n", " raise NotImplementedError(symbol.name)\n", "\n", - " elif symbol.name.startswith(\"l_{12}\"):\n", - " slider = w.IntSlider(\n", - " value=2,\n", - " min=0,\n", - " max=2,\n", - " step=1,\n", - " description=\"ℓ₁₂\",\n", - " disabled=False,\n", - " continuous_update=False,\n", - " orientation=\"horizontal\",\n", - " readout=True,\n", - " readout_format=\"d\",\n", - " )\n", - " sliders[symbol.name] = slider\n", - " categorized_sliders_l[2].append(slider)\n", - " elif symbol.name.startswith(\"l_{23}\"):\n", + " elif symbol.name.startswith(\"l_{\"):\n", " slider = w.IntSlider(\n", " value=1,\n", " min=0,\n", " max=2,\n", - " step=1,\n", - " description=\"ℓ₂₃\",\n", - " disabled=False,\n", + " description=format_l_as_unicode(symbol.name),\n", " continuous_update=False,\n", - " orientation=\"horizontal\",\n", - " readout=True,\n", - " readout_format=\"d\",\n", " )\n", " sliders[symbol.name] = slider\n", - " categorized_sliders_l[1].append(slider)\n", - " elif symbol.name.startswith(\"l_{31}\"):\n", - " slider = w.IntSlider(\n", - " value=0,\n", - " min=0,\n", - " max=2,\n", - " step=1,\n", - " description=\"ℓ₃₁\",\n", - " disabled=False,\n", - " continuous_update=False,\n", - " orientation=\"horizontal\",\n", - " readout=True,\n", - " readout_format=\"d\",\n", - " )\n", - " sliders[symbol.name] = slider\n", - " categorized_sliders_l[0].append(slider)\n", + " categorized_sliders_l.append(slider)\n", + "\n", " else:\n", " raise NotImplementedError(symbol.name)\n", + "\n", "tab_contents = []\n", - "resonances_name = [\"N* [pη (31)]\", \"Δ⁺ [π⁰p(23)]\", \"a₂ [ηπ⁰(12)]\"]\n", + "resonances_name = [\"N* [pη (31)]\", \"Δ⁺ [π⁰p(23)]\", \"a₂ [ηπ⁰(12)]\"]\n", "for i in range(len(resonances_name)):\n", " tab_content = w.VBox([\n", " w.HBox(categorized_sliders_m[i] + categorized_sliders_gamma[i]),\n", " w.VBox(categorized_cphi_pair[i]),\n", " ])\n", " tab_contents.append(tab_content)\n", - "UI_lsliders = w.HBox([\n", - " *categorized_sliders_l[0],\n", - " *categorized_sliders_l[1],\n", - " *categorized_sliders_l[2],\n", - "])\n", - "UI_1 = w.Tab(tab_contents, titles=resonances_name)\n", - "UI = w.VBox([UI_lsliders, UI_1])" + "UI = w.VBox([\n", + " w.HBox(categorized_sliders_l),\n", + " w.Tab(tab_contents, titles=resonances_name),\n", + "])" ] }, {