diff --git a/.cspell.json b/.cspell.json index 59fe84f..ca9b221 100644 --- a/.cspell.json +++ b/.cspell.json @@ -109,6 +109,7 @@ "ignoreWords": [ "Kutschke", "Marangotto", + "PINF", "PYTHONHASHSEED", "Richman", "absl", @@ -205,6 +206,7 @@ "maxsize", "meshgrid", "migrad", + "mkpath", "mmikhasenko", "mname", "msigma", diff --git a/.gitignore b/.gitignore index 52b2784..555f993 100644 --- a/.gitignore +++ b/.gitignore @@ -35,9 +35,10 @@ oryx-build-commands.txt prof/ # Virtual environments -*venv/ .pixi/ .tox/ +*venv/ +pixi.lock pyvenv*/ # Settings diff --git a/.pre-commit/pin_nb_requirements.py b/.pre-commit/pin_nb_requirements.py index 0c4d572..48ce1ee 100644 --- a/.pre-commit/pin_nb_requirements.py +++ b/.pre-commit/pin_nb_requirements.py @@ -168,7 +168,8 @@ def _format_pip_requirements( git_requirements = {r for r in requirements if r.startswith("git+")} pip_requirements = set(requirements) - git_requirements pip_requirements = {r.lower().replace("_", "-") for r in pip_requirements} - sorted_requirements = sorted(pip_requirements) + sorted(git_requirements) + pip_requirements = [__wrap_quotation_marks(r) for r in pip_requirements] + sorted_requirements = sorted(pip_requirements, key=__key) + sorted(git_requirements) expected = f"{__EXPECTED_PIP_INSTALL_LINE} {' '.join(sorted_requirements)}" if install_statement != expected: notebook["cells"][cell_id]["source"] = expected @@ -177,6 +178,16 @@ def _format_pip_requirements( raise PrecommitError(msg) +def __wrap_quotation_marks(requirement: str) -> str: + if "[" in requirement and not requirement.startswith("'"): + return f"'{requirement}'" + return requirement + + +def __key(requirement: str) -> str: + return requirement.replace("'", "", 1).lower() + + def _update_metadata(filename: str, metadata: dict, notebook: NotebookNode) -> None: updated_metadata = False jupyter_metadata = metadata.get("jupyter") diff --git a/.vscode/extensions.json b/.vscode/extensions.json index c1ac5a7..3cd3f4d 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -16,6 +16,7 @@ "ms-vscode.live-server", "ms-vsliveshare.vsliveshare", "redhat.vscode-yaml", + "simonsiefke.svg-preview", "soulcode.vscode-unwanted-extensions", "stkb.rewrap", "streetsidesoftware.code-spell-checker", diff --git a/.vscode/settings.json b/.vscode/settings.json index cefaa9f..c31fb3d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -51,7 +51,8 @@ "notebook.gotoSymbols.showAllSymbols": true, "python.analysis.autoImportCompletions": false, "python.terminal.activateEnvironment": false, - "python.testing.pytestEnabled": false, + "python.testing.pytestEnabled": true, + "python.testing.unittestEnabled": false, "redhat.telemetry.enabled": false, "rewrap.wrappingColumn": 88, "ruff.enable": true, diff --git a/docs/001.ipynb b/docs/001.ipynb index 3c92366..4515d33 100644 --- a/docs/001.ipynb +++ b/docs/001.ipynb @@ -46,7 +46,7 @@ }, "outputs": [], "source": [ - "%pip install -q black==21.5b2 jax==0.4.28 jaxlib==0.4.28 matplotlib==3.4.2 numpy==1.26.4 sympy==1.8" + "%pip install -q black==21.5b2 jax==0.4.28 jaxlib==0.4.28 numpy~=1.26.4 sympy==1.8" ] }, { diff --git a/docs/002.ipynb b/docs/002.ipynb index 065abf3..bc38790 100644 --- a/docs/002.ipynb +++ b/docs/002.ipynb @@ -52,7 +52,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.9.1 numpy==1.19.5 pandas==1.2.4 qrules==0.8.2 sympy==1.8 tensorwaves[jax]==0.2.9 git+https://github.com/zfit/phasespace@7131fbd" + "%pip install -q ampform==0.9.1 numpy==1.19.5 pandas==1.2.4 qrules==0.8.2 sympy==1.8 'tensorwaves[jax]==0.2.9' git+https://github.com/zfit/phasespace@7131fbd" ] }, { @@ -77,6 +77,7 @@ "import timeit\n", "import warnings\n", "from collections.abc import Generator, Sequence\n", + "from pathlib import Path\n", "from typing import Callable\n", "\n", "import ampform\n", @@ -156,7 +157,9 @@ }, "outputs": [], "source": [ - "graphviz.Source(dot).render(\"002-f0(980)-graph\", format=\"svg\");" + "output_file = Path(\"002/f0(980)-graph\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graphviz.Source(dot).render(output_file, format=\"svg\");" ] }, { @@ -373,7 +376,9 @@ }, "outputs": [], "source": [ - "graphviz.Source(dot).render(\"002-collapsed-expression-tree\", format=\"svg\");" + "output_file = Path(\"002/collapsed-expression-tree\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graphviz.Source(dot).render(output_file, format=\"svg\");" ] }, { @@ -438,7 +443,9 @@ }, "outputs": [], "source": [ - "graphviz.Source(dot).render(\"002-simple-expression-tree\", format=\"svg\");" + "output_file = Path(\"002/simple-expression-tree\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graphviz.Source(dot).render(output_file, format=\"svg\");" ] }, { @@ -850,7 +857,9 @@ }, "outputs": [], "source": [ - "fig.savefig(\"002-histogram-m12.svg\");" + "output_file = Path(\"002/histogram-m12.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file);" ] }, { @@ -1381,7 +1390,9 @@ }, "outputs": [], "source": [ - "fig.savefig(\"002-runtime-vs-operations.svg\");" + "output_file = Path(\"002/runtime-vs-operations.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file);" ] }, { @@ -1856,7 +1867,9 @@ }, "outputs": [], "source": [ - "graphviz.Source(dot).render(\"002-f0-graph\", format=\"svg\");" + "output_file = Path(\"002/f0-graph\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graphviz.Source(dot).render(output_file, format=\"svg\");" ] }, { diff --git a/docs/003.ipynb b/docs/003.ipynb index 4cf6edd..39a1812 100644 --- a/docs/003.ipynb +++ b/docs/003.ipynb @@ -45,7 +45,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.14.10 black==23.12.1 mpl-interactions==0.24.1 scipy==1.12.0" + "%pip install -q ampform==0.14.10 black==23.12.1 mpl-interactions~=0.24.2 scipy==1.12.0" ] }, { @@ -77,6 +77,7 @@ "import os\n", "import warnings\n", "from functools import partial\n", + "from pathlib import Path\n", "from typing import Any\n", "\n", "import black\n", @@ -94,15 +95,14 @@ "from ampform.io import aslatex\n", "from ampform.sympy import unevaluated\n", "from ampform.sympy.math import ComplexSqrt\n", - "from IPython.display import SVG, Markdown, Math, display\n", + "from IPython.display import Markdown, Math\n", "from ipywidgets import FloatSlider\n", "from scipy.integrate import quad_vec\n", "from sympy.printing.pycode import _unpack_integral_limits\n", "from tqdm.auto import tqdm\n", "\n", "warnings.filterwarnings(\"ignore\")\n", - "PDG = qrules.load_pdg()\n", - "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" + "PDG = qrules.load_pdg()" ] }, { @@ -166,10 +166,27 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\sqrt[\\mathrm{c}]{z} &=& \\begin{cases} i \\sqrt{- z} & \\text{for}\\: z < 0 \\\\\\sqrt{z} & \\text{otherwise} \\end{cases} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "z = sp.Symbol(\"z\")\n", "sqrt_expr = ComplexSqrt(z)\n", @@ -186,10 +203,28 @@ "tags": [ "hide-input", "scroll-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\Sigma\\left(s\\right) &=& \\frac{1}{16 \\pi^{2}} \\left(\\frac{2 q_a\\left(s\\right)}{\\sqrt{s}} \\log{\\left(\\frac{m_{1}^{2} + m_{2}^{2} + 2 \\sqrt{s} q_a\\left(s\\right) - s}{2 m_{1} m_{2}} \\right)} - \\left(m_{1}^{2} - m_{2}^{2}\\right) \\left(- \\frac{1}{\\left(m_{1} + m_{2}\\right)^{2}} + \\frac{1}{s}\\right) \\log{\\left(\\frac{m_{1}}{m_{2}} \\right)}\\right) \\\\\n", + " q_a\\left(s\\right) &=& \\sqrt[\\mathrm{c}]{q^2\\left(s\\right)} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "@unevaluated\n", "class BreakupMomentum(sp.Expr):\n", @@ -246,10 +281,25 @@ "execution_count": null, "metadata": { "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle s \\to s^{\\prime} + 10^{- \\epsilon} i$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "s_prime = sp.Symbol(R\"s^{\\prime}\", real=True)\n", "epsilon = sp.Symbol(\"epsilon\", positive=True)\n", @@ -276,10 +326,27 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\rho^\\mathrm{c}\\left(s\\right) &=& \\frac{\\sqrt[\\mathrm{c}]{q^2\\left(s\\right)}}{8 \\pi \\sqrt{s}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "rho_expr = PhaseSpaceFactorComplex(s, m1, m2)\n", "Math(aslatex({rho_expr: rho_expr.doit(deep=False)}))" @@ -451,28 +518,20 @@ "ax2.set_ylabel(R\"$16\\pi \\; \\Sigma(s)$\")\n", "ax1.set_title(R\"Complex phase space factor $\\rho$\")\n", "ax2.set_title(\"Chew-Mandelstam $S$-wave ($L=0$)\")\n", + "\n", + "output_file = Path(\"003/chew-mandelstam-s-wave.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.show()" ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "remove-input", - "full-width" - ] - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "if STATIC_WEB_PAGE:\n", - " filename = \"003/chew-mandelstam-s-wave.svg\"\n", - " os.makedirs(os.path.dirname(filename), exist_ok=True)\n", - " fig.savefig(filename)\n", - " display(*sliders.values(), SVG(filename))" + "```{figure} https://github.com/user-attachments/assets/3454e711-8b7e-4ee4-90a6-d6c30bb9d3f8\n", + ":class: full-width\n", + "```" ] }, { @@ -527,10 +586,28 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " n_a^2\\left(s\\right) &=& B_{L}^2\\left(\\frac{q^2\\left(s\\right)}{q_{0}^{2}}\\right) \\\\\n", + " B_{L}^2\\left(z\\right) &=& \\begin{cases} \\frac{2 z}{z + 1} & \\text{for}\\: L = 1 \\\\\\frac{13 z^{2}}{9 z + \\left(z - 3\\right)^{2}} & \\text{for}\\: L = 2 \\\\\\frac{277 z^{3}}{z \\left(z - 15\\right)^{2} + \\left(2 z - 5\\right) \\left(18 z - 45\\right)} & \\text{for}\\: L = 3 \\\\\\frac{12746 z^{4}}{25 z \\left(2 z - 21\\right)^{2} + \\left(z^{2} - 45 z + 105\\right)^{2}} & \\text{for}\\: L = 4 \\\\\\frac{998881 z^{5}}{z^{5} + 15 z^{4} + 315 z^{3} + 6300 z^{2} + 99225 z + 893025} & \\text{for}\\: L = 5 \\\\\\frac{118394977 z^{6}}{z^{6} + 21 z^{5} + 630 z^{4} + 18900 z^{3} + 496125 z^{2} + 9823275 z + 108056025} & \\text{for}\\: L = 6 \\\\\\frac{19727003738 z^{7}}{z^{7} + 28 z^{6} + 1134 z^{5} + 47250 z^{4} + 1819125 z^{3} + 58939650 z^{2} + 1404728325 z + 18261468225} & \\text{for}\\: L = 7 \\\\\\frac{4392846440677 z^{8}}{z^{8} + 36 z^{7} + 1890 z^{6} + 103950 z^{5} + 5457375 z^{4} + 255405150 z^{3} + 9833098275 z^{2} + 273922023375 z + 4108830350625} & \\text{for}\\: L = 8 \\end{cases} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "@unevaluated\n", "class FormFactor(sp.Expr):\n", @@ -572,10 +649,27 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\rho^\\mathrm{c}\\left(s\\right) &=& \\frac{\\sqrt[\\mathrm{c}]{q^2\\left(s\\right)}}{8 \\pi \\sqrt{s}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "Math(aslatex({rho_expr: rho_expr.doit(deep=False)}))" ] @@ -590,8 +684,26 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{n_a^2\\left(s^{\\prime}\\right) \\rho\\left(s^{\\prime}\\right)}{\\left(s^{\\prime} - \\left(m_{1} + m_{2}\\right)^{2}\\right) \\left(- i \\epsilon - s + s^{\\prime}\\right)}$" + ], + "text/plain": [ + "FormFactor(s^{\\prime}, m1, m2, L, q0)*PhaseSpaceFactor(s^{\\prime}, m1, m2)/((s^{\\prime} - (m1 + m2)**2)*(-I*epsilon - s + s^{\\prime}))" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "s_thr = (m1 + m2) ** 2\n", "integrand = (PhaseSpaceFactor(s_prime, m1, m2) * FormFactor(s_prime, m1, m2, L, q0)) / (\n", @@ -728,27 +840,19 @@ " ax.set_ylabel(R\"$16\\pi \\; \\Sigma(s)$\")\n", "axes[-1].set_xlabel(\"$s$ (GeV$^2$)\")\n", "axes[0].legend()\n", + "\n", + "\n", + "output_file = Path(\"003/chew-mandelstam-l-non-zero.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.show()" ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "remove-input" - ] - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "if STATIC_WEB_PAGE:\n", - " filename = \"003/chew-mandelstam-l-non-zero.svg\"\n", - " os.makedirs(os.path.dirname(filename), exist_ok=True)\n", - " fig.savefig(filename)\n", - " display(SVG(filename))" + "![](https://github.com/user-attachments/assets/e03b695c-bf39-4184-a6f4-63f868634c8c)" ] }, { @@ -821,10 +925,25 @@ "code_prompt_show": "Definition of the symbolic dispersion integral" }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{s - \\left(m_{1} + m_{2}\\right)^{2}}{\\pi} \\int\\limits_{\\left(m_{1} + m_{2}\\right)^{2}}^{\\infty} \\frac{B_{L}^2\\left(q^2\\left(s^{\\prime}\\right)\\right) \\rho\\left(s^{\\prime}\\right)}{\\left(s^{\\prime} - \\left(m_{1} + m_{2}\\right)^{2}\\right) \\left(- i \\epsilon - s + s^{\\prime}\\right)}\\, ds^{\\prime}$" + ], + "text/plain": [ + "((s - (m1 + m2)**2)/pi)*Integral(BlattWeisskopfSquared(BreakupMomentumSquared(s^{\\prime}, m1, m2), L)*PhaseSpaceFactor(s^{\\prime}, m1, m2)/((s^{\\prime} - (m1 + m2)**2)*(-I*epsilon - s + s^{\\prime})), (s^{\\prime}, (m1 + m2)**2, oo))" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def dispersion_integral(\n", " s,\n", @@ -902,10 +1021,45 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "```python\n", + "def _lambdifygenerated(s, m1, m2, epsilon):\n", + " x0 = pi ** (-1.0)\n", + " x1 = (m1 + m2) ** 2\n", + " x2 = -x1\n", + " return (\n", + " x0\n", + " * (s + x2)\n", + " * quad_vec(\n", + " lambda _Dummy_46: (1 / 16)\n", + " * x0\n", + " * sqrt((_Dummy_46 + x2) * (_Dummy_46 - (m1 - m2) ** 2) / _Dummy_46)\n", + " / (sqrt(_Dummy_46) * (_Dummy_46 + x2) * (_Dummy_46 - 1j * epsilon - s)),\n", + " x1,\n", + " PINF,\n", + " epsabs=0.0001,\n", + " epsrel=0.0001,\n", + " limit=50,\n", + " )[0]\n", + " )\n", + "```" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "src = inspect.getsource(integral_s_wave_func.pyfunc)\n", "src = f\"\"\"```python\n", @@ -925,8 +1079,23 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU times: user 751 ms, sys: 201 μs, total: 751 ms\n", + "Wall time: 752 ms\n", + "CPU times: user 266 ms, sys: 0 ns, total: 266 ms\n", + "Wall time: 266 ms\n" + ] + } + ], "source": [ "s_values = np.linspace(-0.15, 1.4, num=200)\n", "%time s_wave_values = integral_s_wave_func(s_values, m1_val, m2_val, epsilon=1e-5)\n", @@ -978,27 +1147,18 @@ "\n", "ax1.legend()\n", "fig.tight_layout()\n", + "\n", + "output_file = Path(\"003/symbolic-chew-mandelstam.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.show()" ] }, { - "cell_type": "code", - "execution_count": null, - "metadata": { - "jupyter": { - "source_hidden": true - }, - "tags": [ - "remove-input" - ] - }, - "outputs": [], + "cell_type": "markdown", + "metadata": {}, "source": [ - "if STATIC_WEB_PAGE:\n", - " filename = \"003/symbolic-chew-mandelstam.svg\"\n", - " os.makedirs(os.path.dirname(filename), exist_ok=True)\n", - " fig.savefig(filename)\n", - " display(SVG(filename))" + "![](https://github.com/user-attachments/assets/8db468a6-430f-4a8d-a741-384d1bd2f2a9)" ] } ], diff --git a/docs/004.ipynb b/docs/004.ipynb index 6617b32..bb53f85 100644 --- a/docs/004.ipynb +++ b/docs/004.ipynb @@ -55,7 +55,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.14.10 sympy==1.12" + "%pip install -q ampform==0.14.10 mpl-interactions~=0.24.2 sympy==1.12" ] }, { @@ -85,7 +85,6 @@ ")\n", "from IPython.display import Math, display\n", "from ipywidgets import widgets\n", - "from matplotlib import cm\n", "from mpl_interactions import heatmap_slicer\n", "\n", "warnings.filterwarnings(\"ignore\")\n", @@ -242,7 +241,7 @@ " X,\n", " Y,\n", " Z,\n", - " facecolors=cm.bwr(colors),\n", + " facecolors=plt.cm.bwr(colors),\n", " linewidth=0,\n", ")\n", "ax.set_xlabel(\"Re($s$)\")\n", diff --git a/docs/005.ipynb b/docs/005.ipynb index d88262c..69d217d 100644 --- a/docs/005.ipynb +++ b/docs/005.ipynb @@ -66,7 +66,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.11.* matplotlib==3.5.1" + "%pip install -q ampform==0.11.* mpl-interactions~=0.24.2" ] }, { @@ -85,6 +85,7 @@ "from __future__ import annotations\n", "\n", "import warnings\n", + "from pathlib import Path\n", "\n", "import graphviz\n", "import matplotlib.pyplot as plt\n", @@ -94,7 +95,6 @@ "import sympy as sp\n", "from IPython.display import Math, display\n", "from ipywidgets import widgets as ipywidgets\n", - "from matplotlib import cm\n", "from mpl_interactions.controller import Controls\n", "\n", "warnings.filterwarnings(\"ignore\")" @@ -202,7 +202,9 @@ }, "outputs": [], "source": [ - "graph.render(\"005-two-body-scattering\", format=\"svg\");" + "output_file = Path(\"005/two-body-scattering\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graph.render(output_file, format=\"svg\");" ] }, { @@ -914,7 +916,7 @@ " ax_3d.set_title(f\"{ax_title}, channel {i}\")\n", "\n", " if color_mesh is None:\n", - " color_mesh = ax_3d.pcolormesh(X, Y, Z_values, cmap=cm.coolwarm)\n", + " color_mesh = ax_3d.pcolormesh(X, Y, Z_values, cmap=plt.cm.coolwarm)\n", " else:\n", " color_mesh.set_array(Z_values)\n", " color_mesh.set_clim(vmin=-z_cutoff, vmax=+z_cutoff)\n", diff --git a/docs/006.ipynb b/docs/006.ipynb index 4bb4c72..3ab3060 100644 --- a/docs/006.ipynb +++ b/docs/006.ipynb @@ -72,7 +72,6 @@ "import sympy as sp\n", "from IPython.display import display\n", "from ipywidgets import widgets as ipywidgets\n", - "from matplotlib import cm\n", "from matplotlib import widgets as mpl_widgets\n", "\n", "STATIC_WEB_PAGE = {\"EXECUTE_NB\", \"READTHEDOCS\"}.intersection(os.environ)" @@ -275,7 +274,7 @@ " Z,\n", " rstride=3,\n", " cstride=1,\n", - " cmap=cm.coolwarm,\n", + " cmap=plt.cm.coolwarm,\n", " antialiased=False,\n", " )\n", " ax1.set_xlabel(f\"${sp.latex(x)}$\")\n", @@ -356,7 +355,7 @@ " Z,\n", " rstride=3,\n", " cstride=1,\n", - " cmap=cm.coolwarm,\n", + " cmap=plt.cm.coolwarm,\n", " antialiased=False,\n", " )\n", " ax2.set_xlabel(f\"${sp.latex(x)}$\")\n", @@ -419,7 +418,7 @@ " Z,\n", " rstride=3,\n", " cstride=1,\n", - " cmap=cm.coolwarm,\n", + " cmap=plt.cm.coolwarm,\n", " antialiased=False,\n", " )\n", " ax3.set_xlabel(f\"${sp.latex(x)}$\")\n", diff --git a/docs/009.ipynb b/docs/009.ipynb index 48ae66d..8702e39 100644 --- a/docs/009.ipynb +++ b/docs/009.ipynb @@ -47,7 +47,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.10.5 sympy==1.8" + "%pip install -q ampform==0.10.5 mpl-interactions~=0.24.2 sympy==1.8" ] }, { @@ -146,7 +146,6 @@ ")\n", "from IPython.display import Math, display\n", "from ipywidgets import widgets as ipywidgets\n", - "from matplotlib import cm\n", "from mpl_interactions.controller import Controls\n", "\n", "if TYPE_CHECKING:\n", @@ -831,7 +830,7 @@ " axes[-1].set_title(f\"{ax_title}, channel {i}\")\n", "\n", " if color_mesh is None:\n", - " color_mesh = ax_3d.pcolormesh(X, Y, Z_values, cmap=cm.coolwarm)\n", + " color_mesh = ax_3d.pcolormesh(X, Y, Z_values, cmap=plt.cm.coolwarm)\n", " else:\n", " color_mesh.set_array(Z_values)\n", " color_mesh.set_clim(vmin=-z_cutoff, vmax=+z_cutoff)\n", @@ -887,7 +886,7 @@ " text_thr.set_x(s_thr)\n", " text_diff.set_x(m_diff - x_offset)\n", " else:\n", - " colors = cm.plasma(np.linspace(0, 1, n_channels))\n", + " colors = plt.cm.plasma(np.linspace(0, 1, n_channels))\n", " for i, color in enumerate(colors):\n", " m_a = kwargs[f\"m_a{i}\"]\n", " m_b = kwargs[f\"m_b{i}\"]\n", diff --git a/docs/010.ipynb b/docs/010.ipynb index 6940d65..15640cf 100644 --- a/docs/010.ipynb +++ b/docs/010.ipynb @@ -47,7 +47,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.10.5 sympy==1.8" + "%pip install -q ampform==0.10.5 mpl-interactions~=0.24.2 sympy==1.8" ] }, { @@ -88,7 +88,6 @@ ")\n", "from IPython.display import display\n", "from ipywidgets import widgets as ipywidgets\n", - "from matplotlib import cm\n", "from mpl_interactions.controller import Controls\n", "\n", "if TYPE_CHECKING:\n", @@ -590,7 +589,7 @@ " for ax in axes[1:]:\n", " ax.clear()\n", " axes[-1].pcolormesh(\n", - " X, Y, Z_values, cmap=cm.coolwarm, vmin=-z_cutoff, vmax=+z_cutoff\n", + " X, Y, Z_values, cmap=plt.cm.coolwarm, vmin=-z_cutoff, vmax=+z_cutoff\n", " )\n", " i = kwargs[\"i\"]\n", " if n_channels == 1:\n", @@ -617,7 +616,7 @@ " mass = kwargs[f\"m{R}\"]\n", " ax.axvline(mass, **mass_line_style)\n", " if \"m_a0\" in kwargs:\n", - " colors = cm.plasma(np.linspace(0, 1, n_channels))\n", + " colors = plt.cm.plasma(np.linspace(0, 1, n_channels))\n", " for i, color in enumerate(colors):\n", " m_a = kwargs[f\"m_a{i}\"]\n", " m_b = kwargs[f\"m_b{i}\"]\n", diff --git a/docs/011.ipynb b/docs/011.ipynb index 1173075..75004b0 100644 --- a/docs/011.ipynb +++ b/docs/011.ipynb @@ -64,6 +64,7 @@ "from __future__ import annotations\n", "\n", "import inspect\n", + "from pathlib import Path\n", "from typing import TYPE_CHECKING\n", "\n", "import black\n", @@ -155,7 +156,9 @@ }, "outputs": [], "source": [ - "graphviz.Source(dot).render(\"011-topology\", format=\"svg\");" + "output_file = Path(\"011/topology\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graphviz.Source(dot).render(output_file, format=\"svg\");" ] }, { diff --git a/docs/012.ipynb b/docs/012.ipynb index 8b337e6..7d3b8e1 100644 --- a/docs/012.ipynb +++ b/docs/012.ipynb @@ -53,7 +53,7 @@ } ], "source": [ - "%pip install -q ampform==0.12.6 tensorwaves[jax,pwa]==0.4.8" + "%pip install -q ampform==0.12.6 'tensorwaves[jax,pwa]==0.4.8'" ] }, { diff --git a/docs/013.ipynb b/docs/013.ipynb index c349a6d..4e2b4ac 100644 --- a/docs/013.ipynb +++ b/docs/013.ipynb @@ -46,7 +46,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.13.3 qrules[viz]==0.9.7 tensorwaves[jax,pwa]==0.4.8" + "%pip install -q ampform==0.13.3 'qrules[viz]==0.9.7' 'tensorwaves[jax,pwa]==0.4.8'" ] }, { diff --git a/docs/014.ipynb b/docs/014.ipynb index 4158dd0..7d91708 100644 --- a/docs/014.ipynb +++ b/docs/014.ipynb @@ -44,7 +44,7 @@ }, "outputs": [], "source": [ - "%pip install -q qrules[viz]==0.9.7 sympy==1.9 git+https://github.com/ComPWA/ampform@3ed3ed5" + "%pip install -q 'qrules[viz]==0.9.7' sympy==1.9 git+https://github.com/ComPWA/ampform@3ed3ed5" ] }, { diff --git a/docs/015.ipynb b/docs/015.ipynb index d97eaad..3de2508 100644 --- a/docs/015.ipynb +++ b/docs/015.ipynb @@ -45,7 +45,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.13.3 qrules[viz]==0.9.7 sympy==1.10" + "%pip install -q ampform==0.13.3 'qrules[viz]==0.9.7' sympy==1.10" ] }, { diff --git a/docs/018.ipynb b/docs/018.ipynb index 3520bd2..dec0198 100644 --- a/docs/018.ipynb +++ b/docs/018.ipynb @@ -45,7 +45,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.14.0 qrules[viz]==0.9.7 scipy==1.8.0 sympy==1.10.1 tensorwaves[jax,pwa]==0.4.8" + "%pip install -q ampform==0.14.0 'qrules[viz]==0.9.7' scipy==1.8.0 sympy==1.10.1 'tensorwaves[jax,pwa]==0.4.8'" ] }, { @@ -73,6 +73,7 @@ "import logging\n", "import os\n", "import warnings\n", + "from pathlib import Path\n", "\n", "import jax.numpy as jnp\n", "import numpy as np\n", @@ -123,7 +124,9 @@ "import graphviz\n", "\n", "src = qrules.io.asdot(reaction, collapse_graphs=True)\n", - "_ = graphviz.Source(src).render(\"018-graph\", format=\"svg\")" + "output_file = Path(\"018/graph\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "_ = graphviz.Source(src).render(output_file, format=\"svg\")" ] }, { @@ -252,7 +255,9 @@ "mesh = ax.pcolormesh(X, Y, Z)\n", "c_bar = plt.colorbar(mesh, ax=ax)\n", "c_bar.ax.set_ylabel(bar_title)\n", - "fig.savefig(\"018-TFPhaseSpaceGenerator.png\")\n", + "output_file = Path(\"018/TFPhaseSpaceGenerator.png\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.ion()\n", "plt.close(fig)" ] @@ -359,7 +364,9 @@ "\n", "plot_distribution_and_weights(unweighted_phsp, phsp_weights)\n", "plt.gcf().suptitle(\"TFWeightedPhaseSpaceGenerator sample\")\n", - "plt.savefig(\"018-TFWeightedPhaseSpaceGenerator.png\")\n", + "output_file = Path(\"018/TFWeightedPhaseSpaceGenerator.png\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "plt.savefig(output_file)\n", "plt.show()" ] }, @@ -456,7 +463,9 @@ "mesh = ax.pcolormesh(X, Y, Z)\n", "c_bar = plt.colorbar(mesh, ax=ax)\n", "c_bar.ax.set_ylabel(\"intensity\")\n", - "fig.savefig(\"018-intensity-distribution.png\")\n", + "output_file = Path(\"018/intensity-distribution.png\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.ion()\n", "plt.close(fig)" ] @@ -509,7 +518,9 @@ "source": [ "plot_distribution_and_weights(importance_phsp, importance_weights)\n", "plt.gcf().suptitle(\"Importance-sampled phase space distribution\")\n", - "plt.savefig(\"018-importance-sampling.png\")\n", + "output_file = Path(\"018/importance-sampling.png\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "plt.savefig(output_file)\n", "plt.show()" ] }, @@ -569,7 +580,9 @@ "mesh = ax.pcolormesh(X, Y, Z)\n", "c_bar = plt.colorbar(mesh, ax=ax)\n", "c_bar.ax.set_ylabel(R\"new intensity $\\times$ importance weight\")\n", - "fig.savefig(\"018-importance-sampling-after-modification.png\")\n", + "output_file = Path(\"018/importance-sampling-after-modification.png\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.ion()\n", "plt.close(fig)" ] diff --git a/docs/019.ipynb b/docs/019.ipynb index 067c519..662c36d 100644 --- a/docs/019.ipynb +++ b/docs/019.ipynb @@ -216,15 +216,28 @@ " return img\n", "end\n", " \n", - "mandelbrot()" + "img = mandelbrot()\n", + "mkpath(\"019\")\n", + "save(\"019/mandelbrot_image.png\", img)" ] }, { "cell_type": "markdown", - "metadata": {}, + "metadata": { + "tags": [ + "remove-output" + ] + }, "source": [ "![](https://github.com/ComPWA/compwa.github.io/assets/29308176/f8e604b9-b37c-4b5a-8114-91627da93d37)" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "" + ] } ], "metadata": { @@ -232,7 +245,7 @@ "toc_visible": true }, "kernelspec": { - "display_name": "julia-compwa.github.io 1.10.3", + "display_name": "julia-compwa.github.io 1.10.5", "language": "julia", "name": "julia-compwa.github.io-1.10" }, @@ -240,7 +253,7 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.10.3" + "version": "1.10.5" } }, "nbformat": 4, diff --git a/docs/020.ipynb b/docs/020.ipynb index 731e1ad..5f1f909 100644 --- a/docs/020.ipynb +++ b/docs/020.ipynb @@ -47,7 +47,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform[viz]~=0.14.1 hepstats~=0.6.0 pandas~=1.4.2 sympy~=1.10.1 tensorwaves[jax,pwa]~=0.4.8 zfit~=0.10.0" + "%pip install -q 'ampform[viz]~=0.14.1' hepstats~=0.6.0 pandas~=1.4.2 sympy~=1.10.1 'tensorwaves[jax,pwa]~=0.4.8' zfit~=0.10.0" ] }, { @@ -413,14 +413,13 @@ "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "from matplotlib import cm\n", "\n", "resonances = sorted(\n", " reaction.get_intermediate_particles(),\n", " key=lambda p: p.mass,\n", ")\n", "evenly_spaced_interval = np.linspace(0, 1, len(resonances))\n", - "colors = [cm.rainbow(x) for x in evenly_spaced_interval]\n", + "colors = [plt.cm.rainbow(x) for x in evenly_spaced_interval]\n", "fig, ax = plt.subplots(figsize=(9, 4))\n", "ax.hist(\n", " np.real(data[\"m_12\"]),\n", @@ -573,7 +572,6 @@ "source": [ "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "from matplotlib import cm\n", "\n", "reaction_info = model.reaction_info\n", "resonances = sorted(\n", @@ -582,7 +580,7 @@ ")\n", "\n", "evenly_spaced_interval = np.linspace(0, 1, len(resonances))\n", - "colors = [cm.rainbow(x) for x in evenly_spaced_interval]\n", + "colors = [plt.cm.rainbow(x) for x in evenly_spaced_interval]\n", "\n", "\n", "def indicate_masses(ax):\n", diff --git a/docs/021.ipynb b/docs/021.ipynb index dbb2e9e..1a532a1 100644 --- a/docs/021.ipynb +++ b/docs/021.ipynb @@ -56,7 +56,7 @@ }, "outputs": [], "source": [ - "%pip install -q ampform==0.14.4 qrules==0.9.7 sympy==1.11.1 tensorwaves[jax]==0.4.8" + "%pip install -q ampform==0.14.4 qrules==0.9.7 sympy==1.11.1 'tensorwaves[jax]==0.4.8'" ] }, { @@ -80,6 +80,7 @@ "import itertools\n", "import logging\n", "import os\n", + "from pathlib import Path\n", "from typing import TYPE_CHECKING\n", "\n", "import jax.numpy as jnp\n", @@ -1862,7 +1863,9 @@ "total_intensities = intensity_func(phsp)\n", "mesh = ax.pcolormesh(X, Y, total_intensities, norm=LogNorm())\n", "fig.colorbar(mesh, ax=ax, fraction=0.05, pad=0.02)\n", - "fig.savefig(\"021-intensity-distribution.png\", dpi=200)\n", + "output_file = Path(\"021/intensity-distribution.png\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, dpi=200)\n", "plt.show()" ] }, @@ -1940,7 +1943,9 @@ "set_ylim_to_zero(ax1)\n", "set_ylim_to_zero(ax2)\n", "ax2.legend()\n", - "fig.savefig(\"021-intensity-projections.svg\")\n", + "output_file = Path(\"021/intensity-projections.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file)\n", "plt.show()" ] }, @@ -2445,9 +2450,10 @@ "outputs": [], "source": [ "if STATIC_WEB_PAGE:\n", - " filename = \"021-polarimeter-field.png\"\n", - " plt.savefig(filename, dpi=200)\n", - " display(ui, Image(filename))" + " output_file = Path(\"021/polarimeter-field.png\")\n", + " output_file.parent.mkdir(exist_ok=True)\n", + " plt.savefig(output_file, dpi=200)\n", + " display(ui, Image(output_file))" ] }, { diff --git a/docs/022.ipynb b/docs/022.ipynb index bc0439c..ecc9307 100644 --- a/docs/022.ipynb +++ b/docs/022.ipynb @@ -79,7 +79,6 @@ "import sympy as sp\n", "from ampform.sympy import PoolSum\n", "from IPython.display import display\n", - "from matplotlib import cm\n", "from polarimetry import _to_index\n", "from polarimetry.data import create_data_transformer, generate_meshgrid_sample\n", "from polarimetry.io import (\n", @@ -500,11 +499,11 @@ " if τ == 0 and ρ == 0:\n", " Z = B_arrays[τ, ρ].real\n", " ax.set_title(f\"$B_{{{τ}{p}}}$\")\n", - " cmap = cm.viridis\n", + " cmap = plt.cm.viridis\n", " else:\n", " Z = B_norm[τ, ρ].real\n", " ax.set_title(f\"$B_{{{τ}{p}}} / B_{{00}}$\")\n", - " cmap = cm.coolwarm\n", + " cmap = plt.cm.coolwarm\n", " mesh = ax.pcolormesh(X, Y, Z, cmap=cmap)\n", " cbar = fig.colorbar(mesh, ax=ax, fraction=0.047, pad=0.01)\n", " if τ != 0 or ρ != 0:\n", @@ -557,7 +556,7 @@ }, "outputs": [], "source": [ - "def plot_field(vx, vy, v_abs, ax, strides=12, cmap=cm.viridis_r):\n", + "def plot_field(vx, vy, v_abs, ax, strides=12, cmap=plt.cm.viridis_r):\n", " mesh = ax.quiver(\n", " X[::strides, ::strides],\n", " Y[::strides, ::strides],\n", @@ -699,8 +698,8 @@ "ax1, ax2 = axes\n", "ax1.set_title(R\"$\\alpha$\")\n", "ax2.set_title(R\"$\\beta$\")\n", - "ax1.pcolormesh(X, Y, α_abs.real, cmap=cm.coolwarm).set_clim(vmin=-1, vmax=+1)\n", - "ax2.pcolormesh(X, Y, β_abs.real, cmap=cm.coolwarm).set_clim(vmin=-1, vmax=+1)\n", + "ax1.pcolormesh(X, Y, α_abs.real, cmap=plt.cm.coolwarm).set_clim(vmin=-1, vmax=+1)\n", + "ax2.pcolormesh(X, Y, β_abs.real, cmap=plt.cm.coolwarm).set_clim(vmin=-1, vmax=+1)\n", "ax1.set_xlabel(s1_label)\n", "ax2.set_xlabel(s1_label)\n", "ax1.set_ylabel(s2_label)\n", diff --git a/docs/025.ipynb b/docs/025.ipynb index 8a8e31e..47ff497 100644 --- a/docs/025.ipynb +++ b/docs/025.ipynb @@ -61,6 +61,7 @@ "outputs": [], "source": [ "import os\n", + "from pathlib import Path\n", "from typing import Any\n", "\n", "import matplotlib.pyplot as plt\n", @@ -428,10 +429,10 @@ "outputs": [], "source": [ "if STATIC_WEB_PAGE:\n", - " filename = \"025/rotated-sqrt-complex-plane.png\"\n", - " os.makedirs(os.path.dirname(filename), exist_ok=True)\n", - " mpl_fig.savefig(filename, dpi=200)\n", - " display(ui, Image(filename))" + " output_file = Path(\"025/rotated-sqrt-complex-plane.png\")\n", + " output_file.parent.mkdir(exist_ok=True)\n", + " mpl_fig.savefig(output_file, dpi=200)\n", + " display(ui, Image(output_file))" ] }, { diff --git a/docs/030.ipynb b/docs/030.ipynb index 3943f06..4508c43 100644 --- a/docs/030.ipynb +++ b/docs/030.ipynb @@ -45,7 +45,7 @@ }, "outputs": [], "source": [ - "%pip install -q 'qrules[viz]==0.10.2' 'tensorwaves[jax,phsp]==0.4.12' ampform==0.15.4 sympy==1.12" + "%pip install -q ampform==0.15.4 'qrules[viz]==0.10.2' sympy==1.12 'tensorwaves[jax,phsp]==0.4.12'" ] }, { @@ -72,6 +72,7 @@ "import re\n", "from collections import defaultdict\n", "from functools import lru_cache\n", + "from pathlib import Path\n", "from typing import Any\n", "\n", "import ampform\n", @@ -196,13 +197,26 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], "source": [ "dot = qrules.io.asdot(reaction, collapse_graphs=True)\n", - "graphviz.Source(dot)" + "graph = graphviz.Source(dot)\n", + "output_file = Path(\"030/qrules-output\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graph.render(output_file, format=\"svg\")\n", + "output_file.unlink()\n", + "graph" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Image](https://github.com/user-attachments/assets/431c2299-2ec1-41ee-8f6f-5f3e5c036024)" ] }, { @@ -266,8 +280,26 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\sum_{m_{A}=-1}^{1} \\sum_{m_{1}=-1/2}^{1/2} \\sum_{m_{2}=-1/2}^{1/2}{\\left|{A^{01}_{m_{A}, 0, m_{1}, m_{2}}}\\right|^{2}}$" + ], + "text/plain": [ + "PoolSum(Abs(A^01[m_A, 0, m1, m2])**2, (m_A, (0, 1, -1)), (m1, (-1/2, 1/2)), (m2, (-1/2, 1/2)))" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "model_builder = ampform.get_builder(reaction)\n", "model_builder.adapter.permutate_registered_topologies()\n", @@ -289,10 +321,32 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " A^{01}_{0, 0, - \\frac{1}{2}, - \\frac{1}{2}} &=& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_1(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_1(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_1(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(3/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_2(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(3/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_2(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(3/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_2(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "selected_amplitudes = {\n", " k: v for i, (k, v) in enumerate(model.amplitudes.items()) if i == 0\n", @@ -308,10 +362,29 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{cll}\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} \\\\\n", + " N_2(3/2^-) & m=1.92\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + " N_1(3/2^-) & m=1.82\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "src = R\"\\begin{array}{cll}\" \"\\n\"\n", "for symbol, resonances in create_dynamics_symbol.collected_symbols.items():\n", @@ -412,10 +485,29 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\rho^\\mathrm{CM}_{m_{1},m_{2}}\\left(s\\right) &=& - 16 i \\pi \\Sigma\\left(s\\right) \\\\\n", + " \\Sigma\\left(s\\right) &=& \\frac{- \\left(m_{1}^{2} - m_{2}^{2}\\right) \\left(- \\frac{1}{\\left(m_{1} + m_{2}\\right)^{2}} + \\frac{1}{s}\\right) \\log{\\left(\\frac{m_{1}}{m_{2}} \\right)} + \\frac{2 \\log{\\left(\\frac{\\left|{m_{1}^{2} + m_{2}^{2} + 2 \\sqrt{s} q\\left(s\\right) - s}\\right|}{2 m_{1} m_{2}} \\right)} q\\left(s\\right)}{\\sqrt{s}}}{16 \\pi^{2}} \\\\\n", + " q\\left(s\\right) &=& \\frac{\\sqrt{\\lambda\\left(s, m_{1}^{2}, m_{2}^{2}\\right)}}{2 \\sqrt{s}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "s, m1, m2 = sp.symbols(\"s m1 m2\", nonnegative=True)\n", "exprs = [\n", @@ -478,10 +570,27 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} &=& \\frac{\\Gamma_{N_1(3/2^-)} \\beta_{N_1(3/2^-)} m_{N_1(3/2^-)}}{- \\Gamma_{N_1(3/2^-)} m_{N_1(3/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\Gamma_{N_2(3/2^-)} \\beta_{N_2(3/2^-)} m_{N_2(3/2^-)}}{- \\Gamma_{N_2(3/2^-)} m_{N_2(3/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "dynamics_expressions_bw = {\n", " symbol: formulate_breit_wigner(resonances)\n", @@ -582,10 +691,27 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} &=& \\frac{\\frac{\\beta_{N_1(3/2^-)} g_{N_1(3/2^-)}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\beta_{N_2(3/2^-)} g_{N_2(3/2^-)}}{- m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}}}{- \\left(\\frac{\\left(g_{N_1(3/2^-)}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\left(g_{N_2(3/2^-)}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}}\\right) \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) + 1} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "dynamics_expressions_fvector = {\n", " symbol: formulate_f_vector(resonances)\n", @@ -663,10 +789,25 @@ }, "tags": [ "full-width", - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{\\Gamma_{N_1(3/2^-)} \\beta_{N_1(3/2^-)} m_{N_1(3/2^-)}}{- \\Gamma_{N_1(3/2^-)} m_{N_1(3/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\Gamma_{N_2(3/2^-)} \\beta_{N_2(3/2^-)} m_{N_2(3/2^-)}}{- \\Gamma_{N_2(3/2^-)} m_{N_2(3/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}}$" + ], + "text/plain": [ + "\\Gamma_{N_1(3/2^-)}*\\beta_{N_1(3/2^-)}*m_{N_1(3/2^-)}/(-\\Gamma_{N_1(3/2^-)}*m_{N_1(3/2^-)}*PhaseSpaceCM(m_01**2, m_0, m_1) - m_01**2 + m_{N_1(3/2^-)}**2) + \\Gamma_{N_2(3/2^-)}*\\beta_{N_2(3/2^-)}*m_{N_2(3/2^-)}/(-\\Gamma_{N_2(3/2^-)}*m_{N_2(3/2^-)}*PhaseSpaceCM(m_01**2, m_0, m_1) - m_01**2 + m_{N_2(3/2^-)}**2)" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "dynamics_expr_bw, *_ = dynamics_expressions_bw.values()\n", "dynamics_expr_bw" @@ -681,10 +822,25 @@ }, "tags": [ "full-width", - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{\\beta_{N_1(3/2^-)} g_{N_1(3/2^-)} \\left(m_{01}^{2} - \\left(m_{N_2(3/2^-)}\\right)^{2}\\right) + \\beta_{N_2(3/2^-)} g_{N_2(3/2^-)} \\left(m_{01}^{2} - \\left(m_{N_1(3/2^-)}\\right)^{2}\\right)}{- \\left(m_{01}^{2} - \\left(m_{N_1(3/2^-)}\\right)^{2}\\right) \\left(m_{01}^{2} - \\left(m_{N_2(3/2^-)}\\right)^{2}\\right) + \\left(- \\left(g_{N_1(3/2^-)}\\right)^{2} \\left(m_{01}^{2} - \\left(m_{N_2(3/2^-)}\\right)^{2}\\right) - \\left(g_{N_2(3/2^-)}\\right)^{2} \\left(m_{01}^{2} - \\left(m_{N_1(3/2^-)}\\right)^{2}\\right)\\right) \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right)}$" + ], + "text/plain": [ + "(\\beta_{N_1(3/2^-)}*g_{N_1(3/2^-)}*(m_01**2 - m_{N_2(3/2^-)}**2) + \\beta_{N_2(3/2^-)}*g_{N_2(3/2^-)}*(m_01**2 - m_{N_1(3/2^-)}**2))/(-(m_01**2 - m_{N_1(3/2^-)}**2)*(m_01**2 - m_{N_2(3/2^-)}**2) + (-g_{N_1(3/2^-)}**2*(m_01**2 - m_{N_2(3/2^-)}**2) - g_{N_2(3/2^-)}**2*(m_01**2 - m_{N_1(3/2^-)}**2))*PhaseSpaceCM(m_01**2, m_0, m_1))" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "dynamics_expr_fvector, *_ = dynamics_expressions_fvector.values()\n", "dynamics_expr_fvector.simplify(doit=False)" @@ -943,7 +1099,8 @@ }, "tags": [ "hide-input", - "scroll-input" + "scroll-input", + "remove-output" ] }, "outputs": [], @@ -1001,10 +1158,21 @@ "\n", "ax.set_ylim(0, None)\n", "fig.legend(loc=\"upper right\")\n", - "plt.tight_layout()\n", + "fig.tight_layout()\n", + "\n", + "output_file = Path(\"030/sub-intensities.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")\n", "plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Image](https://github.com/user-attachments/assets/116a418a-4394-4203-90ea-11d6c58c8aea)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1120,6 +1288,10 @@ " )\n", "\n", " ax1.legend(loc=\"upper left\")\n", + "\n", + " output_file = Path(f\"030/argand-{title.lower().replace(' ', '-')}.svg\")\n", + " output_file.parent.mkdir(exist_ok=True)\n", + " fig.savefig(output_file, bbox_inches=\"tight\")\n", " fig.show()" ] }, @@ -1128,7 +1300,8 @@ "execution_count": null, "metadata": { "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1140,12 +1313,20 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Image](https://github.com/user-attachments/assets/4c4060a0-dd38-4e3a-8e4c-04ac0a26f5ac)" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1157,6 +1338,13 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Image](https://github.com/user-attachments/assets/10816903-530f-4990-9cc6-0cb35269368f)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1270,6 +1458,10 @@ " # Add legends\n", " fig.legend(bbox_to_anchor=(0.1, 0.9), loc=\"upper left\")\n", " fig.tight_layout()\n", + "\n", + " output_file = Path(f\"030/phase-{title.lower().replace(' ', '-')}.svg\")\n", + " output_file.parent.mkdir(exist_ok=True)\n", + " fig.savefig(output_file, bbox_inches=\"tight\")\n", " fig.show()" ] }, @@ -1281,7 +1473,8 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1295,6 +1488,13 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Image](https://github.com/user-attachments/assets/a98341f5-9173-4aeb-a817-e9687a0bc7ec)" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1303,7 +1503,8 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1316,6 +1517,13 @@ " title=\"Breit-Wigner\",\n", ")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![Image](https://github.com/user-attachments/assets/c718704d-2648-443e-bb44-4693f6da7e6c)" + ] } ], "metadata": { diff --git a/docs/031.ipynb b/docs/031.ipynb index 8ab4239..70de3f9 100644 --- a/docs/031.ipynb +++ b/docs/031.ipynb @@ -45,7 +45,7 @@ }, "outputs": [], "source": [ - "%pip install -q 'qrules[viz]==0.10.2' 'tensorwaves[jax,phsp]==0.4.12' ampform==0.15.4 pandas==2.2.2 sympy==1.12" + "%pip install -q ampform==0.15.4 pandas==2.2.2 'qrules[viz]==0.10.2' sympy==1.12 'tensorwaves[jax,phsp]==0.4.12'" ] }, { @@ -72,6 +72,7 @@ "import re\n", "from collections import defaultdict\n", "from functools import lru_cache\n", + "from pathlib import Path\n", "from typing import Any\n", "\n", "import ampform\n", @@ -90,7 +91,7 @@ "from ampform.sympy import perform_cached_doit, unevaluated\n", "from attrs import define, field\n", "from IPython.display import Math\n", - "from matplotlib import cm\n", + "from matplotlib.figure import Figure\n", "from qrules.particle import Particle, ParticleCollection\n", "from sympy import Abs\n", "from tensorwaves.data import (\n", @@ -204,13 +205,26 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], "source": [ "dot = qrules.io.asdot(reaction, collapse_graphs=True)\n", - "graphviz.Source(dot)" + "graph = graphviz.Source(dot)\n", + "output_file = Path(\"031/qrules-output\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "graph.render(output_file, format=\"svg\")\n", + "output_file.unlink()\n", + "graph" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/943b0a0a-d6a6-4da0-8992-c02c1830f1b0)" ] }, { @@ -274,8 +288,26 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\sum_{m_{A}=-1}^{1} \\sum_{m_{1}=-1/2}^{1/2} \\sum_{m_{2}=-1/2}^{1/2}{\\left|{A^{01}_{m_{A}, 0, m_{1}, m_{2}}}\\right|^{2}}$" + ], + "text/plain": [ + "PoolSum(Abs(A^01[m_A, 0, m1, m2])**2, (m_A, (0, 1, -1)), (m1, (-1/2, 1/2)), (m2, (-1/2, 1/2)))" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "model_builder = ampform.get_builder(reaction)\n", "model_builder.adapter.permutate_registered_topologies()\n", @@ -297,10 +329,38 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " A^{01}_{0, 0, - \\frac{1}{2}, - \\frac{1}{2}} &=& - C_{J/\\psi(1S) \\to {N_1(1/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_1(1/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{-}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(1/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_1(1/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{-}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(1/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_1(1/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{-}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_1(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_1(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_1(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(1/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_2(1/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{-}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(1/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_2(1/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{-}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(1/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_2(1/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{-}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(3/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_2(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(3/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_2(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_2(3/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_2(3/2^-) \\to \\eta_{0} p_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "selected_amplitudes = {\n", " k: v for i, (k, v) in enumerate(model.amplitudes.items()) if i == 0\n", @@ -316,10 +376,32 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{cll}\n", + " X_{J^P={\\frac{3}{2}}^{-}, Q=+1} \\\\\n", + " N_1(1/2^-) & m=1.65\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + " N_2(1/2^-) & m=1.75\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} \\\\\n", + " N_2(3/2^-) & m=1.92\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + " N_1(3/2^-) & m=1.82\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "src = R\"\\begin{array}{cll}\" \"\\n\"\n", "for symbol, resonances in create_dynamics_symbol.collected_symbols.items():\n", @@ -420,10 +502,29 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\rho^\\mathrm{CM}_{m_{1},m_{2}}\\left(s\\right) &=& - 16 i \\pi \\Sigma\\left(s\\right) \\\\\n", + " \\Sigma\\left(s\\right) &=& \\frac{- \\left(m_{1}^{2} - m_{2}^{2}\\right) \\left(- \\frac{1}{\\left(m_{1} + m_{2}\\right)^{2}} + \\frac{1}{s}\\right) \\log{\\left(\\frac{m_{1}}{m_{2}} \\right)} + \\frac{2 \\log{\\left(\\frac{\\left|{m_{1}^{2} + m_{2}^{2} + 2 \\sqrt{s} q\\left(s\\right) - s}\\right|}{2 m_{1} m_{2}} \\right)} q\\left(s\\right)}{\\sqrt{s}}}{16 \\pi^{2}} \\\\\n", + " q\\left(s\\right) &=& \\frac{\\sqrt{\\lambda\\left(s, m_{1}^{2}, m_{2}^{2}\\right)}}{2 \\sqrt{s}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "s, m1, m2 = sp.symbols(\"s m1 m2\", nonnegative=True)\n", "exprs = [\n", @@ -486,10 +587,28 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " X_{J^P={\\frac{3}{2}}^{-}, Q=+1} &=& \\frac{\\Gamma_{N_1(1/2^-)} \\beta_{N_1(1/2^-)} m_{N_1(1/2^-)}}{- \\Gamma_{N_1(1/2^-)} m_{N_1(1/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_1(1/2^-)}\\right)^{2}} + \\frac{\\Gamma_{N_2(1/2^-)} \\beta_{N_2(1/2^-)} m_{N_2(1/2^-)}}{- \\Gamma_{N_2(1/2^-)} m_{N_2(1/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_2(1/2^-)}\\right)^{2}} \\\\\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} &=& \\frac{\\Gamma_{N_1(3/2^-)} \\beta_{N_1(3/2^-)} m_{N_1(3/2^-)}}{- \\Gamma_{N_1(3/2^-)} m_{N_1(3/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\Gamma_{N_2(3/2^-)} \\beta_{N_2(3/2^-)} m_{N_2(3/2^-)}}{- \\Gamma_{N_2(3/2^-)} m_{N_2(3/2^-)} \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) - m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "dynamics_expressions_bw = {\n", " symbol: formulate_breit_wigner(resonances)\n", @@ -590,10 +709,28 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " X_{J^P={\\frac{3}{2}}^{-}, Q=+1} &=& \\frac{\\frac{\\beta_{N_1(1/2^-)} g_{N_1(1/2^-)}}{- m_{01}^{2} + \\left(m_{N_1(1/2^-)}\\right)^{2}} + \\frac{\\beta_{N_2(1/2^-)} g_{N_2(1/2^-)}}{- m_{01}^{2} + \\left(m_{N_2(1/2^-)}\\right)^{2}}}{- \\left(\\frac{\\left(g_{N_1(1/2^-)}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_1(1/2^-)}\\right)^{2}} + \\frac{\\left(g_{N_2(1/2^-)}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_2(1/2^-)}\\right)^{2}}\\right) \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) + 1} \\\\\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} &=& \\frac{\\frac{\\beta_{N_1(3/2^-)} g_{N_1(3/2^-)}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\beta_{N_2(3/2^-)} g_{N_2(3/2^-)}}{- m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}}}{- \\left(\\frac{\\left(g_{N_1(3/2^-)}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} + \\frac{\\left(g_{N_2(3/2^-)}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_2(3/2^-)}\\right)^{2}}\\right) \\rho^\\mathrm{CM}_{m_{0},m_{1}}\\left(m_{01}^{2}\\right) + 1} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "dynamics_expressions_fvector = {\n", " symbol: formulate_f_vector(resonances)\n", @@ -864,7 +1001,8 @@ }, "tags": [ "hide-input", - "scroll-input" + "scroll-input", + "remove-output" ] }, "outputs": [], @@ -923,9 +1061,20 @@ "ax.set_ylim(0, None)\n", "fig.legend(loc=\"upper right\")\n", "plt.tight_layout()\n", + "\n", + "output_file = Path(\"031/contributions.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")\n", "plt.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/9d040c64-16e6-4657-9fc0-51e43f5bf343)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -937,16 +1086,14 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], "source": [ - "fig, ax = plt.subplots(figsize=(6, 5))\n", + "fig, ax = plt.subplots(figsize=(9, 5))\n", "fast_histogram(\n", " phsp[\"m_01\"].real,\n", " bins=100,\n", @@ -957,14 +1104,44 @@ "ax.set_ylabel(R\"Intensity [a.u.]\")\n", "ax.set_ylim(0, None)\n", "fig.tight_layout()\n", + "\n", + "output_file = Path(\"031/weighted-phsp-f-vector.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")\n", "fig.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/0373fdee-1582-4fad-b655-b21a2673bf4a)" + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "9bf0ee50c6214c378b4fc59591d6c6f2", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Generating intensity-based sample: 0%| | 0/50000 [00:00 None:\n", + ") -> Figure:\n", " intensities1 = function1(phsp)\n", " intensities2 = function2(phsp)\n", " fig, ax = plt.subplots(figsize=(11, 4))\n", @@ -1127,7 +1316,8 @@ " indicate_masses(ax, function1, ls=\"dashed\", lw=1, typ=\"F vector\")\n", " indicate_masses(ax, function2, ls=\"dotted\", lw=1, typ=\"Breit-Wigner\")\n", " fig.legend(loc=\"outside upper right\")\n", - " fig.show()" + " fig.show()\n", + " return fig" ] }, { @@ -1167,14 +1357,32 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + }, + "tags": [ + "remove-output", + "hide-input" + ] + }, "outputs": [], "source": [ "original_parameters_bw = dict(intensity_func_bw.parameters)\n", "intensity_func_bw.update_parameters(initial_parameters_bw)\n", "original_parameters_fvector = dict(intensity_func_fvector.parameters)\n", "intensity_func_fvector.update_parameters(initial_parameters_fvector)\n", - "compare_model(\"m_01\", data, phsp, intensity_func_fvector, intensity_func_bw)" + "fig = compare_model(\"m_01\", data, phsp, intensity_func_fvector, intensity_func_bw)\n", + "output_file = Path(\"031/before-fit.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/e362d975-84df-4f71-a242-c164f3160adb)" ] }, { @@ -1198,10 +1406,65 @@ "execution_count": null, "metadata": { "tags": [ - "scroll-output" + "scroll-output", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "4d4d0d7ae85047dbaa2c4766ebd30d74", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "FitResult(\n", + " minimum_valid=True,\n", + " execution_time=12.6900634765625,\n", + " function_calls=1682,\n", + " estimator_value=-7931.137816713118,\n", + " parameter_values={\n", + " 'm_{N_1(1/2^-)}': 1.6539461175761394,\n", + " 'm_{N_2(1/2^-)}': 1.7264292670507233,\n", + " 'm_{N_1(3/2^-)}': 1.7328191451306136,\n", + " 'm_{N_2(3/2^-)}': 1.908580828366668,\n", + " '\\\\Gamma_{N_1(1/2^-)}': 1.8524926041523075,\n", + " '\\\\Gamma_{N_2(1/2^-)}': 0.13046881396159438,\n", + " '\\\\Gamma_{N_1(3/2^-)}': 0.1573516791553556,\n", + " '\\\\Gamma_{N_2(3/2^-)}': 1.324380387465878,\n", + " '\\\\beta_{N_2(1/2^-)}': (-1.6897481365226579-1.1568947003976526j),\n", + " '\\\\beta_{N_2(3/2^-)}': (1.5375186053600138-0.44760512526013624j),\n", + " },\n", + " parameter_errors={\n", + " 'm_{N_1(1/2^-)}': 0.004603319099772491,\n", + " 'm_{N_2(1/2^-)}': 0.0006070545961158388,\n", + " 'm_{N_1(3/2^-)}': 0.0015172566194625206,\n", + " 'm_{N_2(3/2^-)}': 0.0077272263352300054,\n", + " '\\\\Gamma_{N_1(1/2^-)}': 0.06361609357610253,\n", + " '\\\\Gamma_{N_2(1/2^-)}': 0.005879299479538631,\n", + " '\\\\Gamma_{N_1(3/2^-)}': 0.019367706202832097,\n", + " '\\\\Gamma_{N_2(3/2^-)}': 0.05320290566507636,\n", + " '\\\\beta_{N_2(1/2^-)}': (0.1311293412261402+0.1278774780728592j),\n", + " '\\\\beta_{N_2(3/2^-)}': (0.11272653975271772+0.22792481789700972j),\n", + " },\n", + ")" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "fit_result_bw = minuit2.optimize(estimator_bw, initial_parameters_bw)\n", "assert fit_result_bw.minimum_valid\n", @@ -1213,10 +1476,65 @@ "execution_count": null, "metadata": { "tags": [ - "scroll-output" + "scroll-output", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "72a3252ff90b4bebb6ab418446b8c88d", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "FitResult(\n", + " minimum_valid=True,\n", + " execution_time=13.932363510131836,\n", + " function_calls=1011,\n", + " estimator_value=-8199.598714182841,\n", + " parameter_values={\n", + " 'm_{N_1(1/2^-)}': 1.6483798486877363,\n", + " 'm_{N_2(1/2^-)}': 1.7483200793152158,\n", + " 'm_{N_1(3/2^-)}': 1.8986142342242096,\n", + " 'm_{N_2(3/2^-)}': 1.9496754881738385,\n", + " 'g_{N_1(1/2^-)}': 1.6624278005128597,\n", + " 'g_{N_2(1/2^-)}': 0.9493267500468856,\n", + " 'g_{N_1(3/2^-)}': 1.0079832421160817,\n", + " 'g_{N_2(3/2^-)}': 0.9800998848231933,\n", + " '\\\\beta_{N_2(1/2^-)}': (0.9606446724644881-0.00903038965870049j),\n", + " '\\\\beta_{N_2(3/2^-)}': (0.9709322547787542+0.008602453798822136j),\n", + " },\n", + " parameter_errors={\n", + " 'm_{N_1(1/2^-)}': 0.001040462783404995,\n", + " 'm_{N_2(1/2^-)}': 0.0006658939683350329,\n", + " 'm_{N_1(3/2^-)}': 0.0011425836015682435,\n", + " 'm_{N_2(3/2^-)}': 0.0015413452101229357,\n", + " 'g_{N_1(1/2^-)}': 0.010998823395799513,\n", + " 'g_{N_2(1/2^-)}': 0.018365301903530223,\n", + " 'g_{N_1(3/2^-)}': 0.013236677643628186,\n", + " 'g_{N_2(3/2^-)}': 0.03222752091156066,\n", + " '\\\\beta_{N_2(1/2^-)}': (0.015907378725063155+0.016622785545148663j),\n", + " '\\\\beta_{N_2(3/2^-)}': (0.040758323198047446+0.01968492218927783j),\n", + " },\n", + ")" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "fit_result_fvector = minuit2.optimize(estimator_fvector, initial_parameters_fvector)\n", "assert fit_result_fvector.minimum_valid\n", @@ -1226,12 +1544,30 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "jupyter": { + "source_hidden": true + }, + "tags": [ + "remove-output", + "hide-input" + ] + }, "outputs": [], "source": [ "intensity_func_fvector.update_parameters(fit_result_fvector.parameter_values)\n", "intensity_func_bw.update_parameters(fit_result_bw.parameter_values)\n", - "compare_model(\"m_01\", data, phsp, intensity_func_fvector, intensity_func_bw)" + "fig = compare_model(\"m_01\", data, phsp, intensity_func_fvector, intensity_func_bw)\n", + "output_file = Path(\"031/after-fit.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/378e1a26-caf2-4af5-abf2-695d26c2a603)" ] }, { @@ -1293,8 +1629,23 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-16375.197428365682, -16269.360088952759)" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "compute_aic_bic(fit_result_fvector)" ] @@ -1307,10 +1658,132 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
initialfit resultexpecteddeviation
$\\beta_{N_2(1/2^-)}$1+0j0.961-0.00903j1+0j4.0%
$\\beta_{N_2(3/2^-)}$1+0j0.971+0.0086j1+0j3.0%
$g_{N_1(1/2^-)}$1.61.661.650.8%
$g_{N_1(3/2^-)}$11.0110.8%
$g_{N_2(1/2^-)}$10.94915.1%
$g_{N_2(3/2^-)}$10.9812.0%
$m_{N_1(1/2^-)}$1.61.651.650.1%
$m_{N_1(3/2^-)}$1.81.91.952.6%
$m_{N_2(1/2^-)}$1.71.751.750.1%
$m_{N_2(3/2^-)}$1.931.951.92.6%
\n", + "
" + ], + "text/plain": [ + " initial fit result expected deviation\n", + "$\\beta_{N_2(1/2^-)}$ 1+0j 0.961-0.00903j 1+0j 4.0%\n", + "$\\beta_{N_2(3/2^-)}$ 1+0j 0.971+0.0086j 1+0j 3.0%\n", + "$g_{N_1(1/2^-)}$ 1.6 1.66 1.65 0.8%\n", + "$g_{N_1(3/2^-)}$ 1 1.01 1 0.8%\n", + "$g_{N_2(1/2^-)}$ 1 0.949 1 5.1%\n", + "$g_{N_2(3/2^-)}$ 1 0.98 1 2.0%\n", + "$m_{N_1(1/2^-)}$ 1.6 1.65 1.65 0.1%\n", + "$m_{N_1(3/2^-)}$ 1.8 1.9 1.95 2.6%\n", + "$m_{N_2(1/2^-)}$ 1.7 1.75 1.75 0.1%\n", + "$m_{N_2(3/2^-)}$ 1.93 1.95 1.9 2.6%" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "compare_parameters(\n", " initial=initial_parameters_fvector,\n", @@ -1329,8 +1802,23 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-15838.275633426236, -15732.438294013313)" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "compute_aic_bic(fit_result_bw)" ] @@ -1343,10 +1831,132 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
initialfit resultexpecteddeviation
$\\Gamma_{N_1(1/2^-)}$0.6251.850.606205.7%
$\\Gamma_{N_1(3/2^-)}$0.5410.1570.54170.9%
$\\Gamma_{N_2(1/2^-)}$0.6060.130.57177.2%
$\\Gamma_{N_2(3/2^-)}$0.5181.320.526151.6%
$\\beta_{N_2(1/2^-)}$1+0j-1.69-1.16j1+0j292.8%
$\\beta_{N_2(3/2^-)}$1+0j1.54-0.448j1+0j69.9%
$m_{N_1(1/2^-)}$1.61.651.650.2%
$m_{N_1(3/2^-)}$1.81.731.856.3%
$m_{N_2(1/2^-)}$1.71.731.751.3%
$m_{N_2(3/2^-)}$1.931.911.90.5%
\n", + "
" + ], + "text/plain": [ + " initial fit result expected deviation\n", + "$\\Gamma_{N_1(1/2^-)}$ 0.625 1.85 0.606 205.7%\n", + "$\\Gamma_{N_1(3/2^-)}$ 0.541 0.157 0.541 70.9%\n", + "$\\Gamma_{N_2(1/2^-)}$ 0.606 0.13 0.571 77.2%\n", + "$\\Gamma_{N_2(3/2^-)}$ 0.518 1.32 0.526 151.6%\n", + "$\\beta_{N_2(1/2^-)}$ 1+0j -1.69-1.16j 1+0j 292.8%\n", + "$\\beta_{N_2(3/2^-)}$ 1+0j 1.54-0.448j 1+0j 69.9%\n", + "$m_{N_1(1/2^-)}$ 1.6 1.65 1.65 0.2%\n", + "$m_{N_1(3/2^-)}$ 1.8 1.73 1.85 6.3%\n", + "$m_{N_2(1/2^-)}$ 1.7 1.73 1.75 1.3%\n", + "$m_{N_2(3/2^-)}$ 1.93 1.91 1.9 0.5%" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "compare_parameters(\n", " initial=initial_parameters_bw,\n", diff --git a/docs/032.ipynb b/docs/032.ipynb index 29a9eb6..6d39e50 100644 --- a/docs/032.ipynb +++ b/docs/032.ipynb @@ -45,7 +45,7 @@ }, "outputs": [], "source": [ - "%pip install -q 'qrules[viz]==0.10.2' 'tensorwaves[jax,phsp]==0.4.12' ampform==0.15.4 pandas==2.2.2 sympy==1.12" + "%pip install -q ampform==0.15.4 'qrules[viz]==0.10.2' sympy==1.12 'tensorwaves[jax,phsp]==0.4.12'" ] }, { @@ -74,6 +74,8 @@ "from collections.abc import Iterable, Mapping\n", "from functools import lru_cache\n", "from itertools import product\n", + "from pathlib import Path\n", + "from textwrap import dedent\n", "from typing import Any\n", "\n", "import ampform\n", @@ -82,7 +84,6 @@ "import jax.numpy as jnp\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", - "import pandas as pd\n", "import qrules\n", "import sympy as sp\n", "from ampform.dynamics.builder import TwoBodyKinematicVariableSet\n", @@ -91,7 +92,7 @@ "from ampform.kinematics.phasespace import Kallen\n", "from ampform.sympy import perform_cached_doit, unevaluated\n", "from attrs import define, field, frozen\n", - "from IPython.display import Math, display\n", + "from IPython.display import Markdown, Math, display\n", "from qrules.particle import Particle, ParticleCollection\n", "from qrules.transition import ReactionInfo\n", "from sympy import Abs\n", @@ -217,16 +218,29 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], "source": [ - "for reaction in REACTIONS:\n", + "for i, reaction in enumerate(REACTIONS, 1):\n", " src = qrules.io.asdot(reaction, collapse_graphs=True)\n", " graph = graphviz.Source(src)\n", + " output_file = Path(f\"032/graph{i}\")\n", + " output_file.parent.mkdir(exist_ok=True)\n", + " graph.render(output_file, format=\"svg\")\n", + " output_file.unlink()\n", " display(graph)\n", - " del reaction, src, graph" + " del reaction, src, output_file, graph" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/1357ff8a-de3e-45e1-8997-32c603df6df4)\n", + "![](https://github.com/user-attachments/assets/04d02bba-c18a-4d53-b8ac-864a4ab12c53)" ] }, { @@ -315,10 +329,29 @@ }, "tags": [ "hide-input", - "full-width" + "full-width", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " A^{01}_{0, 0, - \\frac{1}{2}, - \\frac{1}{2}} &=& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+1/2} \\overline{p}_{+1/2}; N_1(3/2^-) \\to K^{0}_{0} \\Sigma^{+}_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,0}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+1/2} \\overline{p}_{-1/2}; N_1(3/2^-) \\to K^{0}_{0} \\Sigma^{+}_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{\\frac{1}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + " &+& - C_{J/\\psi(1S) \\to {N_1(3/2^-)}_{+3/2} \\overline{p}_{+1/2}; N_1(3/2^-) \\to K^{0}_{0} \\Sigma^{+}_{+1/2}} X_{J^P={\\frac{3}{2}}^{+}, Q=+1} D^{1}_{0,-1}\\left(- \\phi_{01},\\theta_{01},0\\right) D^{\\frac{3}{2}}_{- \\frac{3}{2},\\frac{1}{2}}\\left(- \\phi^{01}_{0},\\theta^{01}_{0},0\\right) \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "selected_amplitudes = {\n", " k: v for i, (k, v) in enumerate(MODELS[0].amplitudes.items()) if i == 0\n", @@ -334,10 +367,28 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{cll}\n", + " X_{J^P={\\frac{3}{2}}^{+}, Q=+1} \\\\\n", + " N_1(3/2^-) & m=1.82\\text{ GeV} & \\Gamma=0.6\\text{ GeV} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "src = R\"\\begin{array}{cll}\" \"\\n\"\n", "for symbol, resonances in create_dynamics_symbol.collected_symbols.items():\n", @@ -438,10 +489,29 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\begin{array}{rcl}\n", + " \\rho^\\mathrm{CM}_{m_{1},m_{2}}\\left(s\\right) &=& - 16 i \\pi \\Sigma\\left(s\\right) \\\\\n", + " \\Sigma\\left(s\\right) &=& \\frac{- \\left(m_{1}^{2} - m_{2}^{2}\\right) \\left(- \\frac{1}{\\left(m_{1} + m_{2}\\right)^{2}} + \\frac{1}{s}\\right) \\log{\\left(\\frac{m_{1}}{m_{2}} \\right)} + \\frac{2 \\log{\\left(\\frac{\\left|{m_{1}^{2} + m_{2}^{2} + 2 \\sqrt{s} q\\left(s\\right) - s}\\right|}{2 m_{1} m_{2}} \\right)} q\\left(s\\right)}{\\sqrt{s}}}{16 \\pi^{2}} \\\\\n", + " q\\left(s\\right) &=& \\frac{\\sqrt{\\lambda\\left(s, m_{1}^{2}, m_{2}^{2}\\right)}}{2 \\sqrt{s}} \\\\\n", + "\\end{array}$" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "s, m1, m2 = sp.symbols(\"s m1 m2\", nonnegative=True)\n", "exprs = [\n", @@ -553,10 +623,27 @@ }, "tags": [ "hide-input", - "scroll-input" + "scroll-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left[\\begin{matrix}\\frac{\\left(g_{N_1(3/2^-),0}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} & \\frac{g_{N_1(3/2^-),0} g_{N_1(3/2^-),1}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}}\\\\\\frac{g_{N_1(3/2^-),0} g_{N_1(3/2^-),1}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}} & \\frac{\\left(g_{N_1(3/2^-),1}\\right)^{2}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}}\\end{matrix}\\right]$" + ], + "text/plain": [ + "Matrix([\n", + "[ g_{N_1(3/2^-),0}**2/(-m_01**2 + m_{N_1(3/2^-)}**2), g_{N_1(3/2^-),0}*g_{N_1(3/2^-),1}/(-m_01**2 + m_{N_1(3/2^-)}**2)],\n", + "[g_{N_1(3/2^-),0}*g_{N_1(3/2^-),1}/(-m_01**2 + m_{N_1(3/2^-)}**2), g_{N_1(3/2^-),1}**2/(-m_01**2 + m_{N_1(3/2^-)}**2)]])" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def formulate_k_matrix(\n", " resonances: list[tuple[Particle, int]], n_channels: int\n", @@ -602,10 +689,27 @@ }, "tags": [ "hide-input", - "scroll-input" + "scroll-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left[\\begin{matrix}\\frac{\\beta_{N_1(3/2^-)} g_{N_1(3/2^-),0}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}}\\\\\\frac{\\beta_{N_1(3/2^-)} g_{N_1(3/2^-),1}}{- m_{01}^{2} + \\left(m_{N_1(3/2^-)}\\right)^{2}}\\end{matrix}\\right]$" + ], + "text/plain": [ + "Matrix([\n", + "[\\beta_{N_1(3/2^-)}*g_{N_1(3/2^-),0}/(-m_01**2 + m_{N_1(3/2^-)}**2)],\n", + "[\\beta_{N_1(3/2^-)}*g_{N_1(3/2^-),1}/(-m_01**2 + m_{N_1(3/2^-)}**2)]])" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def formulate_p_vector(\n", " resonances: list[tuple[Particle, int]], n_channels: int\n", @@ -651,10 +755,27 @@ }, "tags": [ "hide-input", - "scroll-input" + "scroll-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left[\\begin{matrix}\\rho^\\mathrm{CM}_{m_{0,0},m_{1,0}}\\left(m_{01}^{2}\\right) & 0\\\\0 & \\rho^\\mathrm{CM}_{m_{0,1},m_{1,1}}\\left(m_{01}^{2}\\right)\\end{matrix}\\right]$" + ], + "text/plain": [ + "Matrix([\n", + "[PhaseSpaceCM(m_01**2, m_{0,0}, m_{1,0}), 0],\n", + "[ 0, PhaseSpaceCM(m_01**2, m_{0,1}, m_{1,1})]])" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def formulate_phsp_factor_matrix(n_channels: int) -> dict[sp.MatrixElement, sp.Expr]:\n", " expressions = {}\n", @@ -699,8 +820,26 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\left(\\mathbb{I} + - i K \\rho\\right)^{-1} P$" + ], + "text/plain": [ + "(I - I*K*rho)**(-1)*P" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "F = (I - sp.I * K * rho).inv() * P\n", "F" @@ -709,11 +848,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "tags": [ - "full-width" - ] - }, + "metadata": {}, "outputs": [], "source": [ "F_vector = F.as_explicit()" @@ -724,10 +859,24 @@ "execution_count": null, "metadata": { "tags": [ - "full-width" + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/latex": [ + "$\\displaystyle \\frac{i \\beta_{N_1(3/2^-)} g_{N_1(3/2^-),0}}{\\left(g_{N_1(3/2^-),0}\\right)^{2} \\rho^\\mathrm{CM}_{m_{0,0},m_{1,0}}\\left(m_{01}^{2}\\right) + \\left(g_{N_1(3/2^-),1}\\right)^{2} \\rho^\\mathrm{CM}_{m_{0,1},m_{1,1}}\\left(m_{01}^{2}\\right) - i m_{01}^{2} + i \\left(m_{N_1(3/2^-)}\\right)^{2}}$" + ], + "text/plain": [ + "I*\\beta_{N_1(3/2^-)}*g_{N_1(3/2^-),0}/(g_{N_1(3/2^-),0}**2*PhaseSpaceCM(m_01**2, m_{0,0}, m_{1,0}) + g_{N_1(3/2^-),1}**2*PhaseSpaceCM(m_01**2, m_{0,1}, m_{1,1}) - I*m_01**2 + I*m_{N_1(3/2^-)}**2)" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "parametrizations = {**K_expressions, **rho_expressions, **P_expressions}\n", "F_exprs = F_vector.xreplace(parametrizations)\n", @@ -949,7 +1098,8 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -972,9 +1122,20 @@ "indicate_masses(ax, INTENSITY_FUNCS_FVECTOR[i])\n", "ax.legend()\n", "ax.set_ylim(0, None)\n", + "\n", + "output_file = Path(\"032/weighted-phsp.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")\n", "fig.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/12855c04-14de-46b8-a2f3-20b25673465f)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1014,7 +1175,8 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1035,9 +1197,20 @@ "indicate_masses(ax, INTENSITY_FUNCS_FVECTOR[i])\n", "ax.legend()\n", "ax.set_ylim(0, None)\n", + "\n", + "output_file = Path(\"032/toy-date.svg\")\n", + "output_file.parent.mkdir(exist_ok=True)\n", + "fig.savefig(output_file, bbox_inches=\"tight\")\n", "fig.show()" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/a34e1f8c-f21d-4396-88b3-b8f7e849bec1)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1129,6 +1302,10 @@ " )\n", " fig.legend()\n", " fig.tight_layout()\n", + "\n", + " output_file = Path(f\"032/{title.lower().replace(' ', '-')}.svg\")\n", + " output_file.parent.mkdir(exist_ok=True)\n", + " fig.savefig(output_file, bbox_inches=\"tight\")\n", " fig.show()\n", "\n", "\n", @@ -1187,7 +1364,8 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1199,6 +1377,13 @@ "compare_models(INTENSITY_FUNCS_FVECTOR, title=\"Model with starting parameters\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/458c1156-ae25-44f1-8c68-d8c395fa02fb)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1209,8 +1394,52 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "518301f02b6d42c69338abf728fea176", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "0it [00:00, ?it/s]" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "FitResult(\n", + " minimum_valid=True,\n", + " execution_time=2.1707212924957275,\n", + " function_calls=130,\n", + " estimator_value=-31725.142543423186,\n", + " parameter_values={\n", + " 'm_{N_1(3/2^-)}': 1.7281071116110833,\n", + " 'g_{N_1(3/2^-),0}': 3.3232991703411034,\n", + " 'g_{N_1(3/2^-),1}': 1.4418247651741936,\n", + " },\n", + " parameter_errors={\n", + " 'm_{N_1(3/2^-)}': 0.011169368106137329,\n", + " 'g_{N_1(3/2^-),0}': 0.06518758826745548,\n", + " 'g_{N_1(3/2^-),1}': 0.04383431405848117,\n", + " },\n", + ")" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "minuit2 = Minuit2()\n", "fit_result = minuit2.optimize(combined_estimators, initial_parameters)\n", @@ -1226,7 +1455,8 @@ "source_hidden": true }, "tags": [ - "hide-input" + "hide-input", + "remove-output" ] }, "outputs": [], @@ -1236,6 +1466,13 @@ "compare_models(INTENSITY_FUNCS_FVECTOR, title=\"Model with optimized parameters\")" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "![](https://github.com/user-attachments/assets/65f43c80-245d-430b-aa4f-f42856686184)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1268,28 +1505,44 @@ " return aic, bic\n", "\n", "\n", - "def compare_parameters(initial: dict, optimized: dict, expected: dict) -> pd.DataFrame:\n", + "def compare_parameters(initial: dict, optimized: dict, expected: dict) -> Markdown:\n", " parameters = sorted(set(initial) | set(optimized))\n", - " df = pd.DataFrame(\n", - " {\n", - " f\"${p}$\": (\n", - " f\"{initial[p]:.3g}\",\n", - " f\"{optimized[p]:.3g}\",\n", - " f\"{expected[p]:.3g}\",\n", - " f\"{100 * abs((optimized[p] - expected[p]) / expected[p]):.1f}%\",\n", - " )\n", - " for p in parameters\n", - " },\n", - " ).T\n", - " df.columns = (\"initial\", \"fit result\", \"expected\", \"deviation\")\n", - " return df" + " src = dedent(\"\"\"\n", + " | | initial | fit result | expected | deviation |\n", + " |---|--------:|-----------:|---------:|----------:|\n", + " \"\"\").strip()\n", + " for p in parameters:\n", + " columns = (\n", + " f\"${p}$\",\n", + " f\"{initial[p]:.3g}\",\n", + " f\"{optimized[p]:.3g}\",\n", + " f\"{expected[p]:.3g}\",\n", + " f\"{100 * abs((optimized[p] - expected[p]) / expected[p]):.1f}%\",\n", + " )\n", + " src += \"\\n| \" + \" | \".join(columns) + \" |\"\n", + " return Markdown(src)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": {}, - "outputs": [], + "metadata": { + "tags": [ + "keep_output" + ] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "(-63444.28508684637, -63417.82575199314)" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "compute_aic_bic(fit_result)" ] @@ -1298,14 +1551,30 @@ "cell_type": "code", "execution_count": null, "metadata": { - "jupyter": { - "source_hidden": true - }, "tags": [ - "hide-input" + "hide-input", + "keep_output" ] }, - "outputs": [], + "outputs": [ + { + "data": { + "text/markdown": [ + "| | initial | fit result | expected | deviation |\n", + "|---|--------:|-----------:|---------:|----------:|\n", + "| $g_{N_1(3/2^-),0}$ | 2.8 | 3.32 | 3.2 | 3.9% |\n", + "| $g_{N_1(3/2^-),1}$ | 1.6 | 1.44 | 1.5 | 3.9% |\n", + "| $m_{N_1(3/2^-)}$ | 1.9 | 1.73 | 1.71 | 1.1% |" + ], + "text/plain": [ + "" + ] + }, + "execution_count": null, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "compare_parameters(\n", " initial=initial_parameters,\n", diff --git a/docs/033.ipynb b/docs/033.ipynb index 52049fb..e950afb 100644 --- a/docs/033.ipynb +++ b/docs/033.ipynb @@ -51,7 +51,7 @@ }, "outputs": [], "source": [ - "%pip install -q iminuit==2.26.0 matplotlib==3.9.1 numpy==1.26.4 pandas==2.2.2 particle==0.24.0 phasespace==1.10.3 scipy==1.14.0 tqdm==4.66.4 vector==1.4.1" + "%pip install -q iminuit==2.26.0 numpy~=1.26.4 pandas==2.2.2 particle==0.24.0 phasespace==1.10.3 scipy==1.14.0 tqdm==4.66.4 vector==1.4.1" ] }, { diff --git a/docs/bibliography.bib b/docs/bibliography.bib index 0f5612c..4779be6 100644 --- a/docs/bibliography.bib +++ b/docs/bibliography.bib @@ -18,8 +18,9 @@ @article{aitchisonUnitarityAnalyticityCrossing2015 year = {2015}, month = jul, journal = {arXiv:1507.02697 [hep-ph]}, + eprint = {1507.02697}, url = {http://arxiv.org/abs/1507.02697}, - archiveprefix = {arxiv} + archiveprefix = {arXiv} } @book{Blatt:1952ije, @@ -39,8 +40,7 @@ @book{Byckling:1971vca year = {1973}, publisher = {Wiley}, address = {London, New York}, - isbn = {978-0-471-12885-4}, - lccn = {QC794.6.K5 B95} + isbn = {978-0-471-12885-4} } @article{Chung:1995dx, @@ -89,11 +89,12 @@ @article{JPAC:2019ufm journal = {Physical Review D: Particles and Fields}, volume = {101}, number = {3}, + eprint = {1910.04566}, pages = {034033}, issn = {2470-0010, 2470-0029}, doi = {10.1103/PhysRevD.101.034033}, url = {https://journals.aps.org/prd/abstract/10.1103/PhysRevD.101.034033}, - archiveprefix = {arxiv} + archiveprefix = {arXiv} } @article{Ketzer:2019wmd, @@ -103,11 +104,12 @@ @article{Ketzer:2019wmd month = jul, journal = {Progress in Particle and Nuclear Physics}, volume = {113}, + eprint = {1909.06366}, pages = {103755}, issn = {01466410}, doi = {10.1016/j.ppnp.2020.103755}, url = {https://linkinghub.elsevier.com/retrieve/pii/S0146641020300028}, - archiveprefix = {arxiv} + archiveprefix = {arXiv} } @misc{kutschkeAngularDistributionCookbook1996, @@ -126,11 +128,12 @@ @article{Marangotto:2019ucc month = dec, journal = {Advances in High Energy Physics}, volume = {2020}, + eprint = {1911.10025}, pages = {1--15}, issn = {1687-7365, 1687-7357}, doi = {10.1155/2020/6674595}, url = {https://www.hindawi.com/journals/ahep/2020/6674595/}, - archiveprefix = {arxiv} + archiveprefix = {arXiv} } @misc{meyerMatrixTutorial2008, @@ -181,9 +184,10 @@ @article{Wang:2020giv journal = {Chinese Physics C}, volume = {45}, number = {6}, + eprint = {2012.03699}, pages = {063103}, issn = {1674-1137, 2058-6132}, doi = {10.1088/1674-1137/abf139}, url = {https://iopscience.iop.org/article/10.1088/1674-1137/abf139}, - archiveprefix = {arxiv} + archiveprefix = {arXiv} } diff --git a/docs/conf.py b/docs/conf.py index 32ae478..91a928a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,6 +24,7 @@ def get_nb_exclusion_patterns() -> list[str]: "000*", "001*", "002*", + "003*", "005*", "008*", "009*", @@ -35,10 +36,14 @@ def get_nb_exclusion_patterns() -> list[str]: "015*", "017*", "018*", + "019*", "020*", "021*", "022*", "028*", + "030*", + "031*", + "032*", "033*", } julia_notebooks = { @@ -138,11 +143,29 @@ def install_ijulia() -> None: html_theme = "sphinx_book_theme" html_theme_options = { "icon_links": [ + { + "name": "Common Partial Wave Analysis", + "url": "https://compwa.github.io", + "icon": "_static/favicon.ico", + "type": "local", + }, { "name": "GitHub", - "url": f"https://github.com/{ORGANIZATION}", + "url": f"https://github.com/{ORGANIZATION}/{REPO_NAME}", "icon": "fa-brands fa-github", }, + { + "name": "Launch on Binder", + "url": f"https://mybinder.org/v2/gh/{ORGANIZATION}/{REPO_NAME}/{BRANCH}?filepath=docs", + "icon": "https://mybinder.readthedocs.io/en/latest/_static/favicon.png", + "type": "url", + }, + { + "name": "Launch on Colaboratory", + "url": f"https://colab.research.google.com/github/{ORGANIZATION}/{REPO_NAME}/blob/{BRANCH}", + "icon": "https://avatars.githubusercontent.com/u/33467679?s=100", + "type": "url", + }, ], "logo": {"text": "The ComPWA project"}, "repository_url": f"https://github.com/{ORGANIZATION}/{REPO_NAME}", @@ -244,6 +267,7 @@ def install_ijulia() -> None: nb_execution_show_tb = True nb_execution_timeout = -1 nb_output_stderr = "remove" +nb_render_markdown_format = "myst" nitpicky = True primary_domain = "py" project = REPO_TITLE diff --git a/pyproject.toml b/pyproject.toml index 47ccd71..ee9d7cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -240,8 +240,8 @@ addopts = [ "--doctest-modules", "--durations=0", "--ignore-glob=*/.ipynb_checkpoints/*", + "--ignore=docs/_static", "--ignore=docs/conf.py", - "--nbmake", "--nbmake-timeout=1200", "-k not docs/019.ipynb", ] @@ -354,16 +354,24 @@ split-on-trailing-comma = false "T20", "TCH00", ] -"**/003.ipynb" = ["B023", "PLC2701"] -"**/009.ipynb" = ["FURB113"] -"**/010.ipynb" = ["FURB113"] -"**/011.ipynb" = ["PLC2701", "PLR6301"] +"**/002.ipynb" = ["F821"] +"**/003.ipynb" = ["B023", "F821", "PLC2701", "S404", "S603"] +"**/004.ipynb" = ["S404", "S603"] +"**/005.ipynb" = ["F821", "S404", "S603"] +"**/006.ipynb" = ["S404", "S603"] +"**/009.ipynb" = ["FURB113", "S404", "S603"] +"**/010.ipynb" = ["FURB113", "S404", "S603"] +"**/011.ipynb" = ["F821", "PLC2701", "PLR6301"] "**/014.ipynb" = ["PLC2701"] "**/016.ipynb" = ["PLC2701"] -"**/021.ipynb" = ["I001"] -"**/022.ipynb" = ["PLC2701"] -"**/024.ipynb" = ["E731", "E741", "S307"] -"**/025.ipynb" = ["E731"] +"**/017.ipynb" = ["S404", "S603"] +"**/020.ipynb" = ["F821"] +"**/021.ipynb" = ["FIX004", "I001", "S404", "S603"] +"**/022.ipynb" = ["F821", "PLC2701"] +"**/024.ipynb" = ["E731", "E741", "F821", "S102", "S307"] +"**/025.ipynb" = ["E731", "S404", "S603"] +"**/027.ipynb" = ["PLW1510", "S404", "S603"] +"**/028.ipynb" = ["PERF203"] "**/98*.ipynb" = ["E731", "PLR6301"] "docs/*" = [ "D", @@ -373,22 +381,6 @@ split-on-trailing-comma = false "S113", "T201", ] -"docs/002.ipynb" = ["F821"] -"docs/003.ipynb" = ["F821", "S404", "S603"] -"docs/004.ipynb" = ["S404", "S603"] -"docs/005.ipynb" = ["F821", "S404", "S603"] -"docs/006.ipynb" = ["S404", "S603"] -"docs/009.ipynb" = ["S404", "S603"] -"docs/010.ipynb" = ["S404", "S603"] -"docs/011.ipynb" = ["F821"] -"docs/017.ipynb" = ["S404", "S603"] -"docs/020.ipynb" = ["F821"] -"docs/021.ipynb" = ["FIX004", "S404", "S603"] -"docs/022.ipynb" = ["F821"] -"docs/024.ipynb" = ["F821", "S102"] -"docs/025.ipynb" = ["S404", "S603"] -"docs/027.ipynb" = ["PLW1510", "S404", "S603"] -"docs/028.ipynb" = ["PERF203"] "docs/conf.py" = [ "A001", "D100",