From 0594163f2256b69e1e5de2fd8c524dc5813a26e1 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 17 Aug 2022 11:06:02 +0200 Subject: [PATCH] MAINT!: rename "polarization" to "polarimetry" --- README.md | 4 +- data/particle-definitions.yaml | 2 +- docs/_relink_references.py | 4 +- docs/amplitude-model.ipynb | 8 +- docs/appendix/alignment.ipynb | 12 +- docs/appendix/angles.ipynb | 4 +- docs/appendix/benchmark.ipynb | 160 +++++++++--------- docs/appendix/dynamics.ipynb | 4 +- docs/appendix/phase-space.ipynb | 10 +- docs/appendix/serialization.ipynb | 32 ++-- docs/conf.py | 10 +- docs/cross-check.ipynb | 10 +- docs/index.md | 6 +- docs/intensity.ipynb | 14 +- .../{polarization.ipynb => polarimetry.ipynb} | 134 ++++++++------- docs/uncertainties.ipynb | 134 ++++++++------- environment.yml | 2 +- pyproject.toml | 2 +- setup.cfg | 6 +- src/{polarization => polarimetry}/__init__.py | 6 +- src/{polarization => polarimetry}/_attrs.py | 4 +- .../amplitude/__init__.py | 8 +- .../amplitude/angles.py | 2 +- src/{polarization => polarimetry}/data.py | 4 +- src/{polarization => polarimetry}/decay.py | 2 +- src/{polarization => polarimetry}/dynamics.py | 2 +- src/{polarization => polarimetry}/function.py | 0 src/{polarization => polarimetry}/io.py | 10 +- .../lhcb/__init__.py | 8 +- .../lhcb/dynamics.py | 6 +- .../lhcb/model-definitions.yaml | 0 .../lhcb/particle-definitions.yaml | 0 .../lhcb/particle.py | 4 +- src/{polarization => polarimetry}/plot.py | 0 src/{polarization => polarimetry}/py.typed | 0 src/{polarization => polarimetry}/spin.py | 0 tests/amplitude/test_angles.py | 2 +- tests/test_decay.py | 2 +- tests/test_io.py | 22 +-- 39 files changed, 316 insertions(+), 324 deletions(-) rename docs/{polarization.ipynb => polarimetry.ipynb} (87%) rename src/{polarization => polarimetry}/__init__.py (90%) rename src/{polarization => polarimetry}/_attrs.py (90%) rename src/{polarization => polarimetry}/amplitude/__init__.py (98%) rename src/{polarization => polarimetry}/amplitude/angles.py (99%) rename src/{polarization => polarimetry}/data.py (98%) rename src/{polarization => polarimetry}/decay.py (98%) rename src/{polarization => polarimetry}/dynamics.py (98%) rename src/{polarization => polarimetry}/function.py (100%) rename src/{polarization => polarimetry}/io.py (97%) rename src/{polarization => polarimetry}/lhcb/__init__.py (97%) rename src/{polarization => polarimetry}/lhcb/dynamics.py (94%) rename src/{polarization => polarimetry}/lhcb/model-definitions.yaml (100%) rename src/{polarization => polarimetry}/lhcb/particle-definitions.yaml (100%) rename src/{polarization => polarimetry}/lhcb/particle.py (94%) rename src/{polarization => polarimetry}/plot.py (100%) rename src/{polarization => polarimetry}/py.typed (100%) rename src/{polarization => polarimetry}/spin.py (100%) diff --git a/README.md b/README.md index ba65004b..f2c280a2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Polarization sensitivity in Λc → pπK +# Aligned polarimetry field of the Λc → p π K decay @@ -14,7 +14,7 @@ It's recommended to develop this code base with [VSCode](https://code.visualstud ```shell conda env create -conda activate polarization +conda activate polarimetry ``` Style checks are enforced with [Pre-commit](https://pre-commit.com). To activate for each commit, run: diff --git a/data/particle-definitions.yaml b/data/particle-definitions.yaml index 95504401..0f5d036d 100644 --- a/data/particle-definitions.yaml +++ b/data/particle-definitions.yaml @@ -136,7 +136,7 @@ K(1430): width: 190 lineshape: BuggBreitWignerMinL -# https://github.com/ComPWA/polarization-sensitivity/blob/34f5330/julia/notebooks/model0.jl#L43-L47 +# https://github.com/ComPWA/polarimetry/blob/34f5330/julia/notebooks/model0.jl#L43-L47 Sigma-: latex: \Sigma^- jp: 1/2^+ diff --git a/docs/_relink_references.py b/docs/_relink_references.py index 4084133a..370bf64e 100644 --- a/docs/_relink_references.py +++ b/docs/_relink_references.py @@ -19,7 +19,7 @@ "Literal[(-1, 1)]": "typing.Literal", "Literal[- 1, 1]": "typing.Literal", "Literal[-1, 1]": "typing.Literal", - "OuterStates": "polarization.decay.OuterStates", + "OuterStates": "polarimetry.decay.OuterStates", "ParametrizedBackendFunction": "tensorwaves.function.ParametrizedBackendFunction", "Path": "pathlib.Path", "Pattern": "typing.Pattern", @@ -35,7 +35,7 @@ "sp.acos": "sympy.functions.elementary.trigonometric.acos", } __REF_TYPE_SUBSTITUTIONS = { - "polarization.decay.OuterStates": "obj", + "polarimetry.decay.OuterStates": "obj", "tensorwaves.interface.DataSample": "obj", } diff --git a/docs/amplitude-model.ipynb b/docs/amplitude-model.ipynb index 61da7683..40beed27 100644 --- a/docs/amplitude-model.ipynb +++ b/docs/amplitude-model.ipynb @@ -32,10 +32,10 @@ "import sympy as sp\n", "from IPython.display import Markdown, display\n", "\n", - "from polarization.amplitude import simplify_latex_rendering\n", - "from polarization.io import as_markdown_table, display_latex\n", - "from polarization.lhcb import load_model_builder, load_model_parameters\n", - "from polarization.lhcb.particle import K, Λc, Σ, load_particles, p, π\n", + "from polarimetry.amplitude import simplify_latex_rendering\n", + "from polarimetry.io import as_markdown_table, display_latex\n", + "from polarimetry.lhcb import load_model_builder, load_model_parameters\n", + "from polarimetry.lhcb.particle import K, Λc, Σ, load_particles, p, π\n", "\n", "simplify_latex_rendering()" ] diff --git a/docs/appendix/alignment.ipynb b/docs/appendix/alignment.ipynb index ccc904f3..03f04c2b 100644 --- a/docs/appendix/alignment.ipynb +++ b/docs/appendix/alignment.ipynb @@ -42,16 +42,16 @@ "from tensorwaves.function.sympy import create_function\n", "from tqdm.auto import tqdm\n", "\n", - "from polarization.amplitude import AmplitudeModel, simplify_latex_rendering\n", - "from polarization.data import create_data_transformer, generate_meshgrid_sample\n", - "from polarization.io import display_latex, mute_jax_warnings, perform_cached_doit\n", - "from polarization.lhcb import (\n", + "from polarimetry.amplitude import AmplitudeModel, simplify_latex_rendering\n", + "from polarimetry.data import create_data_transformer, generate_meshgrid_sample\n", + "from polarimetry.io import display_latex, mute_jax_warnings, perform_cached_doit\n", + "from polarimetry.lhcb import (\n", " flip_production_coupling_signs,\n", " load_model_builder,\n", " load_model_parameters,\n", ")\n", - "from polarization.lhcb.particle import load_particles\n", - "from polarization.plot import use_mpl_latex_fonts\n", + "from polarimetry.lhcb.particle import load_particles\n", + "from polarimetry.plot import use_mpl_latex_fonts\n", "\n", "mute_jax_warnings()\n", "simplify_latex_rendering()" diff --git a/docs/appendix/angles.ipynb b/docs/appendix/angles.ipynb index a505d66d..d60ae820 100644 --- a/docs/appendix/angles.ipynb +++ b/docs/appendix/angles.ipynb @@ -28,12 +28,12 @@ }, "outputs": [], "source": [ - "from polarization.amplitude.angles import (\n", + "from polarimetry.amplitude.angles import (\n", " formulate_scattering_angle,\n", " formulate_theta_hat_angle,\n", " formulate_zeta_angle,\n", ")\n", - "from polarization.io import display_latex" + "from polarimetry.io import display_latex" ] }, { diff --git a/docs/appendix/benchmark.ipynb b/docs/appendix/benchmark.ipynb index 1b1954e4..c813017a 100644 --- a/docs/appendix/benchmark.ipynb +++ b/docs/appendix/benchmark.ipynb @@ -20,7 +20,7 @@ "metadata": {}, "source": [ ":::{tip}\n", - "This notebook benchmarks JAX on a **single CPU core**. Compare with Julia results as reported in [ComPWA/polarization-sensitivity#27](https://github.com/ComPWA/polarization-sensitivity/issues/27). See also the [Extended benchmark #68](https://github.com/ComPWA/polarization-sensitivity/discussions/68) discussion.\n", + "This notebook benchmarks JAX on a **single CPU core**. Compare with Julia results as reported in [ComPWA/polarimetry#27](https://github.com/ComPWA/polarimetry/issues/27). See also the [Extended benchmark #68](https://github.com/ComPWA/polarimetry/discussions/68) discussion.\n", ":::\n", "\n", ":::{note}\n", @@ -53,20 +53,20 @@ "from psutil import cpu_count\n", "from tensorwaves.function.sympy import create_function, create_parametrized_function\n", "\n", - "from polarization import formulate_polarization\n", - "from polarization.amplitude import DalitzPlotDecompositionBuilder\n", - "from polarization.data import (\n", + "from polarimetry import formulate_polarimetry\n", + "from polarimetry.amplitude import DalitzPlotDecompositionBuilder\n", + "from polarimetry.data import (\n", " create_data_transformer,\n", " generate_meshgrid_sample,\n", " generate_phasespace_sample,\n", ")\n", - "from polarization.io import mute_jax_warnings, perform_cached_doit\n", - "from polarization.lhcb import (\n", + "from polarimetry.io import mute_jax_warnings, perform_cached_doit\n", + "from polarimetry.lhcb import (\n", " load_model_builder,\n", " load_model_parameters,\n", " load_three_body_decay,\n", ")\n", - "from polarization.lhcb.particle import load_particles\n", + "from polarimetry.lhcb.particle import load_particles\n", "\n", "LOGGER = logging.getLogger()\n", "LOGGER.setLevel(logging.ERROR)\n", @@ -97,10 +97,10 @@ "outputs": [], "source": [ "%%time\n", - "polarization_exprs = formulate_polarization(amplitude_builder, reference_subsystem)\n", - "unfolded_polarization_exprs = [\n", + "polarimetry_exprs = formulate_polarimetry(amplitude_builder, reference_subsystem)\n", + "unfolded_polarimetry_exprs = [\n", " perform_cached_doit(expr.doit().xreplace(model.amplitudes))\n", - " for expr in polarization_exprs\n", + " for expr in polarimetry_exprs\n", "]\n", "unfolded_intensity_expr = perform_cached_doit(model.full_expression)" ] @@ -174,7 +174,7 @@ "outputs": [], "source": [ "src = \"Total number of mathematical operations:\\n\"\n", - "for xyz, expr in enumerate(unfolded_polarization_exprs):\n", + "for xyz, expr in enumerate(unfolded_polarimetry_exprs):\n", " n_operations = sp.count_ops(expr)\n", " src += Rf\"- $\\alpha_{'xyz'[xyz]}$: {n_operations:,}\" + \"\\n\"\n", "n_operations = sp.count_ops(unfolded_intensity_expr)\n", @@ -189,13 +189,13 @@ "outputs": [], "source": [ "%%time\n", - "parametrized_polarization_funcs = [\n", + "parametrized_polarimetry_funcs = [\n", " create_parametrized_function(\n", " expr,\n", " parameters=model.parameter_defaults,\n", " backend=\"jax\",\n", " )\n", - " for expr in unfolded_polarization_exprs\n", + " for expr in unfolded_polarimetry_exprs\n", "]\n", "parametrized_intensity_func = create_parametrized_function(\n", " unfolded_intensity_expr,\n", @@ -249,9 +249,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](random_point)\n", - "array = parametrized_polarization_funcs[1](random_point)\n", - "array = parametrized_polarization_funcs[2](random_point)" + "array = parametrized_polarimetry_funcs[0](random_point)\n", + "array = parametrized_polarimetry_funcs[1](random_point)\n", + "array = parametrized_polarimetry_funcs[2](random_point)" ] }, { @@ -268,7 +268,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][\"random point (compilation)\"] = __\n", - "timing_parametrized[\"polarization\"][\"random point (compilation)\"] = _" + "timing_parametrized[\"polarimetry\"][\"random point (compilation)\"] = _" ] }, { @@ -295,9 +295,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](random_point)\n", - "array = parametrized_polarization_funcs[1](random_point)\n", - "array = parametrized_polarization_funcs[2](random_point)" + "array = parametrized_polarimetry_funcs[0](random_point)\n", + "array = parametrized_polarimetry_funcs[1](random_point)\n", + "array = parametrized_polarimetry_funcs[2](random_point)" ] }, { @@ -314,7 +314,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][\"random point (cached)\"] = __\n", - "timing_parametrized[\"polarization\"][\"random point (cached)\"] = _" + "timing_parametrized[\"polarimetry\"][\"random point (cached)\"] = _" ] }, { @@ -348,9 +348,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](grid_sample)\n", - "array = parametrized_polarization_funcs[1](grid_sample)\n", - "array = parametrized_polarization_funcs[2](grid_sample)" + "array = parametrized_polarimetry_funcs[0](grid_sample)\n", + "array = parametrized_polarimetry_funcs[1](grid_sample)\n", + "array = parametrized_polarimetry_funcs[2](grid_sample)" ] }, { @@ -367,7 +367,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][f\"{res}x{res} grid\"] = __\n", - "timing_parametrized[\"polarization\"][f\"{res}x{res} grid\"] = _" + "timing_parametrized[\"polarimetry\"][f\"{res}x{res} grid\"] = _" ] }, { @@ -394,9 +394,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](grid_sample)\n", - "array = parametrized_polarization_funcs[1](grid_sample)\n", - "array = parametrized_polarization_funcs[2](grid_sample)" + "array = parametrized_polarimetry_funcs[0](grid_sample)\n", + "array = parametrized_polarimetry_funcs[1](grid_sample)\n", + "array = parametrized_polarimetry_funcs[2](grid_sample)" ] }, { @@ -413,7 +413,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][f\"{res}x{res} grid (cached)\"] = __\n", - "timing_parametrized[\"polarization\"][f\"{res}x{res} grid (cached)\"] = _" + "timing_parametrized[\"polarimetry\"][f\"{res}x{res} grid (cached)\"] = _" ] }, { @@ -449,9 +449,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](phsp_sample)\n", - "array = parametrized_polarization_funcs[1](phsp_sample)\n", - "array = parametrized_polarization_funcs[2](phsp_sample)" + "array = parametrized_polarimetry_funcs[0](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[1](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[2](phsp_sample)" ] }, { @@ -468,7 +468,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][f\"{n_events:,} phsp\"] = __\n", - "timing_parametrized[\"polarization\"][f\"{n_events:,} phsp\"] = _" + "timing_parametrized[\"polarimetry\"][f\"{n_events:,} phsp\"] = _" ] }, { @@ -495,9 +495,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](phsp_sample)\n", - "array = parametrized_polarization_funcs[1](phsp_sample)\n", - "array = parametrized_polarization_funcs[2](phsp_sample)" + "array = parametrized_polarimetry_funcs[0](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[1](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[2](phsp_sample)" ] }, { @@ -514,7 +514,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][f\"{n_events:,} phsp (cached)\"] = __\n", - "timing_parametrized[\"polarization\"][f\"{n_events:,} phsp (cached)\"] = _" + "timing_parametrized[\"polarimetry\"][f\"{n_events:,} phsp (cached)\"] = _" ] }, { @@ -531,7 +531,7 @@ "outputs": [], "source": [ "parametrized_intensity_func.update_parameters(modified_parameters)\n", - "for func in parametrized_polarization_funcs:\n", + "for func in parametrized_polarimetry_funcs:\n", " func.update_parameters(modified_parameters)" ] }, @@ -559,9 +559,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](phsp_sample)\n", - "array = parametrized_polarization_funcs[1](phsp_sample)\n", - "array = parametrized_polarization_funcs[2](phsp_sample)" + "array = parametrized_polarimetry_funcs[0](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[1](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[2](phsp_sample)" ] }, { @@ -578,7 +578,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][f\"modified {n_events:,} phsp\"] = __\n", - "timing_parametrized[\"polarization\"][f\"modified {n_events:,} phsp\"] = _" + "timing_parametrized[\"polarimetry\"][f\"modified {n_events:,} phsp\"] = _" ] }, { @@ -605,9 +605,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = parametrized_polarization_funcs[0](phsp_sample)\n", - "array = parametrized_polarization_funcs[1](phsp_sample)\n", - "array = parametrized_polarization_funcs[2](phsp_sample)" + "array = parametrized_polarimetry_funcs[0](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[1](phsp_sample)\n", + "array = parametrized_polarimetry_funcs[2](phsp_sample)" ] }, { @@ -624,7 +624,7 @@ "outputs": [], "source": [ "timing_parametrized[\"intensity\"][f\"modified {n_events:,} phsp (cached)\"] = __\n", - "timing_parametrized[\"polarization\"][f\"modified {n_events:,} phsp (cached)\"] = _" + "timing_parametrized[\"polarimetry\"][f\"modified {n_events:,} phsp (cached)\"] = _" ] }, { @@ -634,7 +634,7 @@ "outputs": [], "source": [ "parametrized_intensity_func.update_parameters(original_parameters)\n", - "for func in parametrized_polarization_funcs:\n", + "for func in parametrized_polarimetry_funcs:\n", " func.update_parameters(original_parameters)" ] }, @@ -651,8 +651,8 @@ "metadata": {}, "outputs": [], "source": [ - "subs_polarization_exprs = [\n", - " expr.xreplace(model.parameter_defaults) for expr in unfolded_polarization_exprs\n", + "subs_polarimetry_exprs = [\n", + " expr.xreplace(model.parameter_defaults) for expr in unfolded_polarimetry_exprs\n", "]\n", "subs_intensity_expr = unfolded_intensity_expr.xreplace(model.parameter_defaults)" ] @@ -680,7 +680,7 @@ "outputs": [], "source": [ "src = \"Number of mathematical operations after substituting all parameters:\\n\"\n", - "for xyz, expr in enumerate(subs_polarization_exprs):\n", + "for xyz, expr in enumerate(subs_polarimetry_exprs):\n", " n_operations = sp.count_ops(expr)\n", " src += Rf\"- $\\alpha_{'xyz'[xyz]}$: {n_operations:,}\" + \"\\n\"\n", "n_operations = sp.count_ops(subs_intensity_expr)\n", @@ -695,8 +695,8 @@ "outputs": [], "source": [ "%%time\n", - "polarization_funcs = [\n", - " create_function(expr, backend=\"jax\") for expr in subs_polarization_exprs\n", + "polarimetry_funcs = [\n", + " create_function(expr, backend=\"jax\") for expr in subs_polarimetry_exprs\n", "]\n", "intensity_func = create_function(subs_intensity_expr, backend=\"jax\")" ] @@ -732,9 +732,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = polarization_funcs[0](random_point)\n", - "array = polarization_funcs[1](random_point)\n", - "array = polarization_funcs[2](random_point)" + "array = polarimetry_funcs[0](random_point)\n", + "array = polarimetry_funcs[1](random_point)\n", + "array = polarimetry_funcs[2](random_point)" ] }, { @@ -751,7 +751,7 @@ "outputs": [], "source": [ "timing_substituted[\"intensity\"][\"random point (compilation)\"] = __\n", - "timing_substituted[\"polarization\"][\"random point (compilation)\"] = _" + "timing_substituted[\"polarimetry\"][\"random point (compilation)\"] = _" ] }, { @@ -778,9 +778,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = polarization_funcs[0](random_point)\n", - "array = polarization_funcs[1](random_point)\n", - "array = polarization_funcs[2](random_point)" + "array = polarimetry_funcs[0](random_point)\n", + "array = polarimetry_funcs[1](random_point)\n", + "array = polarimetry_funcs[2](random_point)" ] }, { @@ -797,7 +797,7 @@ "outputs": [], "source": [ "timing_substituted[\"intensity\"][\"random point (cached)\"] = __\n", - "timing_substituted[\"polarization\"][\"random point (cached)\"] = _" + "timing_substituted[\"polarimetry\"][\"random point (cached)\"] = _" ] }, { @@ -831,9 +831,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = polarization_funcs[0](grid_sample)\n", - "array = polarization_funcs[1](grid_sample)\n", - "array = polarization_funcs[2](grid_sample)" + "array = polarimetry_funcs[0](grid_sample)\n", + "array = polarimetry_funcs[1](grid_sample)\n", + "array = polarimetry_funcs[2](grid_sample)" ] }, { @@ -850,7 +850,7 @@ "outputs": [], "source": [ "timing_substituted[\"intensity\"][f\"{res}x{res} grid\"] = __\n", - "timing_substituted[\"polarization\"][f\"{res}x{res} grid\"] = _" + "timing_substituted[\"polarimetry\"][f\"{res}x{res} grid\"] = _" ] }, { @@ -877,9 +877,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = polarization_funcs[0](grid_sample)\n", - "array = polarization_funcs[1](grid_sample)\n", - "array = polarization_funcs[2](grid_sample)" + "array = polarimetry_funcs[0](grid_sample)\n", + "array = polarimetry_funcs[1](grid_sample)\n", + "array = polarimetry_funcs[2](grid_sample)" ] }, { @@ -896,7 +896,7 @@ "outputs": [], "source": [ "timing_substituted[\"intensity\"][f\"{res}x{res} grid (cached)\"] = __\n", - "timing_substituted[\"polarization\"][f\"{res}x{res} grid (cached)\"] = _" + "timing_substituted[\"polarimetry\"][f\"{res}x{res} grid (cached)\"] = _" ] }, { @@ -930,9 +930,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = polarization_funcs[0](phsp_sample)\n", - "array = polarization_funcs[1](phsp_sample)\n", - "array = polarization_funcs[2](phsp_sample)" + "array = polarimetry_funcs[0](phsp_sample)\n", + "array = polarimetry_funcs[1](phsp_sample)\n", + "array = polarimetry_funcs[2](phsp_sample)" ] }, { @@ -949,7 +949,7 @@ "outputs": [], "source": [ "timing_substituted[\"intensity\"][f\"{n_events:,} phsp\"] = __\n", - "timing_substituted[\"polarization\"][f\"{n_events:,} phsp\"] = _" + "timing_substituted[\"polarimetry\"][f\"{n_events:,} phsp\"] = _" ] }, { @@ -976,9 +976,9 @@ "outputs": [], "source": [ "%%timeit -n1 -r1 -q -o\n", - "array = polarization_funcs[0](phsp_sample)\n", - "array = polarization_funcs[1](phsp_sample)\n", - "array = polarization_funcs[2](phsp_sample)" + "array = polarimetry_funcs[0](phsp_sample)\n", + "array = polarimetry_funcs[1](phsp_sample)\n", + "array = polarimetry_funcs[2](phsp_sample)" ] }, { @@ -995,7 +995,7 @@ "outputs": [], "source": [ "timing_substituted[\"intensity\"][f\"{n_events:,} phsp (cached)\"] = __\n", - "timing_substituted[\"polarization\"][f\"{n_events:,} phsp (cached)\"] = _" + "timing_substituted[\"polarimetry\"][f\"{n_events:,} phsp (cached)\"] = _" ] }, { @@ -1021,9 +1021,9 @@ "def collect_sorted_row_title() -> list[str]:\n", " row_titles = {}\n", " row_titles.update(timing_parametrized[\"intensity\"])\n", - " row_titles.update(timing_parametrized[\"polarization\"])\n", + " row_titles.update(timing_parametrized[\"polarimetry\"])\n", " row_titles.update(timing_substituted[\"intensity\"])\n", - " row_titles.update(timing_substituted[\"polarization\"])\n", + " row_titles.update(timing_substituted[\"polarimetry\"])\n", " return list(row_titles)\n", "\n", "\n", @@ -1038,9 +1038,9 @@ "values = [\n", " (\n", " remove_loop_info(timing_parametrized[\"intensity\"].get(row)),\n", - " remove_loop_info(timing_parametrized[\"polarization\"].get(row)),\n", + " remove_loop_info(timing_parametrized[\"polarimetry\"].get(row)),\n", " remove_loop_info(timing_substituted[\"intensity\"].get(row)),\n", - " remove_loop_info(timing_substituted[\"polarization\"].get(row)),\n", + " remove_loop_info(timing_substituted[\"polarimetry\"].get(row)),\n", " )\n", " for row in row_titles\n", "]\n", diff --git a/docs/appendix/dynamics.ipynb b/docs/appendix/dynamics.ipynb index 864a4c52..ef2ef5e4 100644 --- a/docs/appendix/dynamics.ipynb +++ b/docs/appendix/dynamics.ipynb @@ -24,7 +24,7 @@ "import sympy as sp\n", "from ampform.kinematics.phasespace import Kallen\n", "\n", - "from polarization.dynamics import (\n", + "from polarimetry.dynamics import (\n", " BlattWeisskopf,\n", " BreitWignerMinL,\n", " BuggBreitWigner,\n", @@ -33,7 +33,7 @@ " P,\n", " Q,\n", ")\n", - "from polarization.io import display_doit, display_latex" + "from polarimetry.io import display_doit, display_latex" ] }, { diff --git a/docs/appendix/phase-space.ipynb b/docs/appendix/phase-space.ipynb index d7b7c7d3..0abb1576 100644 --- a/docs/appendix/phase-space.ipynb +++ b/docs/appendix/phase-space.ipynb @@ -38,16 +38,16 @@ ")\n", "from matplotlib.colors import LogNorm\n", "\n", - "from polarization.data import (\n", + "from polarimetry.data import (\n", " create_mass_symbol_mapping,\n", " create_phase_space_filter,\n", " generate_meshgrid_sample,\n", " generate_phasespace_sample,\n", ")\n", - "from polarization.io import display_doit, display_latex, mute_jax_warnings\n", - "from polarization.lhcb import load_model_builder\n", - "from polarization.lhcb.particle import load_particles\n", - "from polarization.plot import use_mpl_latex_fonts\n", + "from polarimetry.io import display_doit, display_latex, mute_jax_warnings\n", + "from polarimetry.lhcb import load_model_builder\n", + "from polarimetry.lhcb.particle import load_particles\n", + "from polarimetry.plot import use_mpl_latex_fonts\n", "\n", "mute_jax_warnings()" ] diff --git a/docs/appendix/serialization.ipynb b/docs/appendix/serialization.ipynb index f054ce53..e0b0c5be 100644 --- a/docs/appendix/serialization.ipynb +++ b/docs/appendix/serialization.ipynb @@ -44,21 +44,21 @@ "from tensorwaves.function.sympy import create_function\n", "from tqdm.auto import tqdm\n", "\n", - "from polarization import formulate_polarization\n", - "from polarization.data import (\n", + "from polarimetry import formulate_polarimetry\n", + "from polarimetry.data import (\n", " create_data_transformer,\n", " generate_meshgrid_sample,\n", " generate_phasespace_sample,\n", ")\n", - "from polarization.io import (\n", - " export_polarization_field,\n", - " import_polarization_field,\n", + "from polarimetry.io import (\n", + " export_polarimetry_field,\n", + " import_polarimetry_field,\n", " mute_jax_warnings,\n", " perform_cached_doit,\n", ")\n", - "from polarization.lhcb import load_model_builder, load_model_parameters\n", - "from polarization.lhcb.particle import load_particles\n", - "from polarization.plot import use_mpl_latex_fonts\n", + "from polarimetry.lhcb import load_model_builder, load_model_parameters\n", + "from polarimetry.lhcb.particle import load_particles\n", + "from polarimetry.plot import use_mpl_latex_fonts\n", "\n", "logging.getLogger().setLevel(logging.ERROR)\n", "mute_jax_warnings()\n", @@ -85,10 +85,10 @@ }, "outputs": [], "source": [ - "polarization_exprs = formulate_polarization(amplitude_builder, reference_subsystem)\n", + "polarimetry_exprs = formulate_polarimetry(amplitude_builder, reference_subsystem)\n", "unfolded_exprs = [\n", " perform_cached_doit(expr.doit().xreplace(model.amplitudes))\n", - " for expr in tqdm([model.full_expression, *polarization_exprs], leave=False)\n", + " for expr in tqdm([model.full_expression, *polarimetry_exprs], leave=False)\n", "]\n", "actual_funcs = [\n", " create_function(expr.xreplace(model.parameter_defaults), backend=\"jax\")\n", @@ -182,14 +182,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Exported polarization grids" + "## Exported polarimetry grids" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Decided to use the `alpha-x-arrays.json` format. It can be exported with {func}`.export_polarization_field`." + "Decided to use the `alpha-x-arrays.json` format. It can be exported with {func}`.export_polarimetry_field`." ] }, { @@ -198,8 +198,8 @@ "metadata": {}, "outputs": [], "source": [ - "filename = \"polarizations-model-0.json\"\n", - "export_polarization_field(\n", + "filename = \"polarimetry-model-0.json\"\n", + "export_polarimetry_field(\n", " sigma1=X[0],\n", " sigma2=Y[:, 0],\n", " intensity=actual_funcs[0](grid_sample).real,\n", @@ -228,7 +228,7 @@ " byt = os.path.getsize(filename)\n", " kb = f\"{1e-3*byt:.0f}\"\n", " src = (\n", - " f\"Polarization grid can be downloaded here: {{download}}`{filename}`\"\n", + " f\"Polarimetry grid can be downloaded here: {{download}}`{filename}`\"\n", " f\" ({kb} kB).\"\n", " )\n", " display(Markdown(src))" @@ -258,7 +258,7 @@ "metadata": {}, "outputs": [], "source": [ - "field_definition = import_polarization_field(\"polarizations-model-0.json\")\n", + "field_definition = import_polarimetry_field(\"polarimetry-model-0.json\")\n", "imported_sigma1 = field_definition[\"m^2_Kpi\"]\n", "imported_sigma2 = field_definition[\"m^2_pK\"]\n", "imported_arrays = (\n", diff --git a/docs/conf.py b/docs/conf.py index c8b9db74..81d31c32 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -92,8 +92,8 @@ def generate_api() -> None: " ".join( [ "sphinx-apidoc", - f"../src/polarization/", - f"../src/polarization/version.py", + f"../src/polarimetry/", + f"../src/polarimetry/version.py", "-o api/", "--force", "--no-toc", @@ -128,7 +128,7 @@ def generate_api() -> None: } autodoc_member_order = "bysource" autodoc_type_aliases = { - "OuterStates": "polarization.decay.OuterStates", + "OuterStates": "polarimetry.decay.OuterStates", } autodoc_typehints_format = "short" autosectionlabel_prefix_document = True @@ -162,7 +162,7 @@ def generate_api() -> None: "binderhub_url": "https://mybinder.org", }, "path_to_docs": "docs", - "repository_url": "https://github.com/ComPWA/polarization-sensitivity", + "repository_url": "https://github.com/ComPWA/polarimetry", "repository_branch": "main", "show_navbar_depth": 2, "show_toc_level": 2, @@ -170,7 +170,7 @@ def generate_api() -> None: "use_edit_page_button": True, "use_issues_button": True, } -html_title = "Polarization sensitivity" +html_title = "Polarimetry Λc → p K π" intersphinx_mapping = { "IPython": ("https://ipython.readthedocs.io/en/stable", None), "ampform": (f"https://ampform.readthedocs.io/en/stable", None), diff --git a/docs/cross-check.ipynb b/docs/cross-check.ipynb index 9c87f3ca..0ae94f33 100644 --- a/docs/cross-check.ipynb +++ b/docs/cross-check.ipynb @@ -41,21 +41,21 @@ "from tensorwaves.function.sympy import create_parametrized_function\n", "from tqdm.auto import tqdm\n", "\n", - "from polarization.amplitude import simplify_latex_rendering\n", - "from polarization.data import create_data_transformer\n", - "from polarization.io import (\n", + "from polarimetry.amplitude import simplify_latex_rendering\n", + "from polarimetry.data import create_data_transformer\n", + "from polarimetry.io import (\n", " as_latex,\n", " display_latex,\n", " mute_jax_warnings,\n", " perform_cached_doit,\n", ")\n", - "from polarization.lhcb import (\n", + "from polarimetry.lhcb import (\n", " get_conversion_factor,\n", " load_model,\n", " load_model_builder,\n", " parameter_key_to_symbol,\n", ")\n", - "from polarization.lhcb.particle import load_particles\n", + "from polarimetry.lhcb.particle import load_particles\n", "\n", "mute_jax_warnings()\n", "\n", diff --git a/docs/index.md b/docs/index.md index 1919df39..b84a0d11 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,7 @@ myst: all_links_external: True --- -# Polarization sensitivity +# Polarimetry in Λc → p π K @@ -14,10 +14,10 @@ maxdepth: 2 amplitude-model cross-check intensity -polarization +polarimetry uncertainties appendix -API +API ``` {{ LINK_TO_JULIA_PAGES }} diff --git a/docs/intensity.ipynb b/docs/intensity.ipynb index d70d5937..bd00788c 100644 --- a/docs/intensity.ipynb +++ b/docs/intensity.ipynb @@ -46,23 +46,23 @@ "from tensorwaves.interface import DataSample\n", "from tqdm.auto import tqdm\n", "\n", - "from polarization.data import (\n", + "from polarimetry.data import (\n", " create_data_transformer,\n", " generate_meshgrid_sample,\n", " generate_phasespace_sample,\n", " generate_sub_meshgrid_sample,\n", ")\n", - "from polarization.decay import Particle\n", - "from polarization.function import (\n", + "from polarimetry.decay import Particle\n", + "from polarimetry.function import (\n", " compute_sub_function,\n", " integrate_intensity,\n", " interference_intensity,\n", " sub_intensity,\n", ")\n", - "from polarization.io import mute_jax_warnings, perform_cached_doit\n", - "from polarization.lhcb import load_model\n", - "from polarization.lhcb.particle import load_particles\n", - "from polarization.plot import get_contour_line, stylize_contour, use_mpl_latex_fonts\n", + "from polarimetry.io import mute_jax_warnings, perform_cached_doit\n", + "from polarimetry.lhcb import load_model\n", + "from polarimetry.lhcb.particle import load_particles\n", + "from polarimetry.plot import get_contour_line, stylize_contour, use_mpl_latex_fonts\n", "\n", "mute_jax_warnings()\n", "particles = load_particles(\"../data/particle-definitions.yaml\")\n", diff --git a/docs/polarization.ipynb b/docs/polarimetry.ipynb similarity index 87% rename from docs/polarization.ipynb rename to docs/polarimetry.ipynb index f8f14edd..cbb023bc 100644 --- a/docs/polarization.ipynb +++ b/docs/polarimetry.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Polarization sensitivity" + "# Polarimeter vector field" ] }, { @@ -50,20 +50,20 @@ "from tensorwaves.interface import DataSample\n", "from tqdm.auto import tqdm\n", "\n", - "from polarization import formulate_polarization\n", - "from polarization.data import create_data_transformer, generate_meshgrid_sample\n", - "from polarization.function import compute_sub_function\n", - "from polarization.io import mute_jax_warnings, perform_cached_doit\n", - "from polarization.lhcb import (\n", + "from polarimetry import formulate_polarimetry\n", + "from polarimetry.data import create_data_transformer, generate_meshgrid_sample\n", + "from polarimetry.function import compute_sub_function\n", + "from polarimetry.io import mute_jax_warnings, perform_cached_doit\n", + "from polarimetry.lhcb import (\n", " flip_production_coupling_signs,\n", " load_model_builder,\n", " load_model_parameters,\n", ")\n", - "from polarization.lhcb.particle import load_particles\n", - "from polarization.plot import get_contour_line, stylize_contour, use_mpl_latex_fonts\n", + "from polarimetry.lhcb.particle import load_particles\n", + "from polarimetry.plot import get_contour_line, stylize_contour, use_mpl_latex_fonts\n", "\n", "filterwarnings(\"ignore\")\n", - "logging.getLogger(\"polarization.function\").setLevel(logging.INFO)\n", + "logging.getLogger(\"polarimetry.function\").setLevel(logging.INFO)\n", "mute_jax_warnings()" ] }, @@ -139,19 +139,17 @@ }, "outputs": [], "source": [ - "unfolded_polarization_exprs = {}\n", + "unfolded_polarimetry_exprs = {}\n", "unfolded_intensity_expr = {}\n", "for i, model in tqdm(models.items(), \"Unfolding expressions\"):\n", " reference_subsystem = i\n", - " polarization_exprs = formulate_polarization(\n", - " amplitude_builder, reference_subsystem\n", - " )\n", - " unfolded_polarization_exprs[i] = [\n", + " polarimetry_exprs = formulate_polarimetry(amplitude_builder, reference_subsystem)\n", + " unfolded_polarimetry_exprs[i] = [\n", " perform_cached_doit(expr.doit().xreplace(model.amplitudes))\n", - " for expr in tqdm(polarization_exprs, leave=False)\n", + " for expr in tqdm(polarimetry_exprs, leave=False)\n", " ]\n", " unfolded_intensity_expr[i] = perform_cached_doit(model.full_expression)\n", - "del i, polarization_exprs, reference_subsystem" + "del i, polarimetry_exprs, reference_subsystem" ] }, { @@ -169,7 +167,7 @@ }, "outputs": [], "source": [ - "polarization_funcs = {}\n", + "polarimetry_funcs = {}\n", "intensity_func = {}\n", "for i, model in tqdm(models.items(), \"Lambdifying to JAX\"):\n", " production_couplings = {\n", @@ -183,13 +181,13 @@ " for symbol, value in model.parameter_defaults.items()\n", " if symbol not in production_couplings\n", " }\n", - " polarization_funcs[i] = [\n", + " polarimetry_funcs[i] = [\n", " create_parametrized_function(\n", " expr.xreplace(fixed_parameters),\n", " parameters=production_couplings,\n", " backend=\"jax\",\n", " )\n", - " for expr in tqdm(unfolded_polarization_exprs[i], leave=False)\n", + " for expr in tqdm(unfolded_polarimetry_exprs[i], leave=False)\n", " ]\n", " intensity_func[i] = create_parametrized_function(\n", " unfolded_intensity_expr[i].xreplace(fixed_parameters),\n", @@ -205,7 +203,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Polarization distributions" + "## Polarimetry distributions" ] }, { @@ -232,7 +230,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Average polarization values" + "### Average polarimetry values" ] }, { @@ -264,7 +262,7 @@ " return jnp.nansum(values * weights) / jnp.nansum(weights)\n", "\n", "\n", - "def create_average_polarization_table(reference_subsystem: int) -> None:\n", + "def create_average_polarimetry_table(reference_subsystem: int) -> None:\n", " latex = R\"\\begin{array}{cccc}\" + \"\\n\"\n", " latex += (\n", " R\"& \\bar{|\\alpha|} & \\bar\\alpha_x & \\bar\\alpha_y & \\bar\\alpha_z \\\\\" + \"\\n\"\n", @@ -274,7 +272,7 @@ " latex += f\" {label} & \"\n", " x, y, z = (\n", " compute_sub_function(\n", - " polarization_funcs[reference_subsystem][xyz],\n", + " polarimetry_funcs[reference_subsystem][xyz],\n", " data_sample,\n", " [identifier],\n", " )\n", @@ -309,7 +307,7 @@ }, "outputs": [], "source": [ - "create_average_polarization_table(1)" + "create_average_polarimetry_table(1)" ] }, { @@ -325,7 +323,7 @@ "metadata": {}, "outputs": [], "source": [ - "create_average_polarization_table(2)" + "create_average_polarimetry_table(2)" ] }, { @@ -343,7 +341,7 @@ }, "outputs": [], "source": [ - "create_average_polarization_table(3)" + "create_average_polarimetry_table(3)" ] }, { @@ -494,19 +492,19 @@ " ax.set_ylabel(s2_label)\n", "\n", "intensity_arrays = []\n", - "polarization_arrays = []\n", + "polarimetry_arrays = []\n", "for subsystem in range(nrows):\n", " # alpha_xyz distributions\n", " alpha_xyz_arrays = []\n", " for i in range(2, ncols):\n", " xyz = i - 2\n", " if subsystem == 0:\n", - " z_values = polarization_funcs[1][xyz](data_sample)\n", - " polarization_arrays.append(z_values)\n", + " z_values = polarimetry_funcs[1][xyz](data_sample)\n", + " polarimetry_arrays.append(z_values)\n", " else:\n", " identifier = subsystem_identifiers[subsystem - 1]\n", " z_values = compute_sub_function(\n", - " polarization_funcs[1][xyz], data_sample, identifier\n", + " polarimetry_funcs[1][xyz], data_sample, identifier\n", " )\n", " z_values = np.real(z_values)\n", " alpha_xyz_arrays.append(z_values)\n", @@ -578,7 +576,7 @@ ")\n", "axes[0].set_ylabel(s2_label)\n", "I_times_alpha = jnp.array(\n", - " [array * intensity_arrays[0] for array in polarization_arrays]\n", + " [array * intensity_arrays[0] for array in polarimetry_arrays]\n", ")\n", "global_min_max = float(jnp.nanmax(jnp.abs(I_times_alpha)))\n", "for ax, z_values, xyz in zip(axes, I_times_alpha, \"xyz\"):\n", @@ -595,7 +593,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Total polarization vector field" + "### Total polarimetry vector field" ] }, { @@ -624,13 +622,13 @@ }, "outputs": [], "source": [ - "def plot_polarization_field(polarization_arrays, ax, strides=12, cmap=cm.viridis_r):\n", - " alpha_abs = jnp.sqrt(jnp.sum(polarization_arrays**2, axis=0))\n", + "def plot_polarimetry_field(polarimetry_arrays, ax, strides=12, cmap=cm.viridis_r):\n", + " alpha_abs = jnp.sqrt(jnp.sum(polarimetry_arrays**2, axis=0))\n", " mesh = ax.quiver(\n", " X[::strides, ::strides],\n", " Y[::strides, ::strides],\n", - " np.real(polarization_arrays[2][::strides, ::strides]),\n", - " np.real(polarization_arrays[0][::strides, ::strides]),\n", + " np.real(polarimetry_arrays[2][::strides, ::strides]),\n", + " np.real(polarimetry_arrays[0][::strides, ::strides]),\n", " np.real(alpha_abs[::strides, ::strides]),\n", " cmap=cmap,\n", " )\n", @@ -647,14 +645,14 @@ " tight_layout=True,\n", " )\n", " ax.set_box_aspect(1)\n", - " fig.suptitle(R\"Total polarization field $\\vec{\\alpha}$\", x=0.47, y=0.96)\n", + " fig.suptitle(R\"Total polarimetry field $\\vec{\\alpha}$\", x=0.47, y=0.96)\n", " ax.set_title(f\"(reference subsystem {reference_subsystem})\")\n", " ax.set_xlabel(X_LABEL_ALPHA)\n", " ax.set_ylabel(Y_LABEL_ALPHA)\n", - " polarization_arrays = [\n", - " func(data_sample) for func in polarization_funcs[reference_subsystem]\n", + " polarimetry_arrays = [\n", + " func(data_sample) for func in polarimetry_funcs[reference_subsystem]\n", " ]\n", - " mesh = plot_polarization_field(jnp.array(polarization_arrays), ax)\n", + " mesh = plot_polarimetry_field(jnp.array(polarimetry_arrays), ax)\n", " color_bar = fig.colorbar(mesh, ax=ax, pad=0.01)\n", " color_bar.set_label(R\"$\\left|\\vec{\\alpha}\\right|$\")\n", "\n", @@ -726,11 +724,11 @@ " ax.set_xlabel(X_LABEL_ALPHA)\n", " ax.set_ylabel(Y_LABEL_ALPHA)\n", " reference_subsystem = 1\n", - " polarization_arrays = [\n", - " func(data_sample) for func in polarization_funcs[reference_subsystem]\n", + " polarimetry_arrays = [\n", + " func(data_sample) for func in polarimetry_funcs[reference_subsystem]\n", " ]\n", - " polarization_arrays = jnp.array(polarization_arrays).real\n", - " mesh = plot_polarization_field(polarization_arrays, ax, strides=14)\n", + " polarimetry_arrays = jnp.array(polarimetry_arrays).real\n", + " mesh = plot_polarimetry_field(polarimetry_arrays, ax, strides=14)\n", " color_bar = fig.colorbar(mesh, ax=ax, pad=0.01)\n", " color_bar.set_label(R\"$\\left|\\vec{\\alpha}\\right|$\")\n", " fig.savefig(output_filename)\n", @@ -787,7 +785,7 @@ " return regex\n", "\n", "\n", - "def plot_polarization_field_per_resonance(reference_subsystem: int) -> None:\n", + "def plot_polarimetry_field_per_resonance(reference_subsystem: int) -> None:\n", " spectator = FINAL_STATE[reference_subsystem]\n", " subsystem_name = subsystem_identifiers[reference_subsystem - 1]\n", " subsystem_resonances = [\n", @@ -807,20 +805,20 @@ " tight_layout=True,\n", " )\n", " fig.suptitle(\n", - " f\"Polarization field, aligned to ${spectator}$\",\n", + " f\"Polarimetry field, aligned to ${spectator}$\",\n", " y={1: 0.95, 2: 0.97}[nrows],\n", " )\n", " for i, (ax, resonance) in enumerate(zip(axes.flatten(), subsystem_resonances)):\n", " ax.set_box_aspect(1)\n", " non_zero_couplings = [to_regex(resonance.name)]\n", - " polarizations = [\n", + " polarimetry_field = [\n", " compute_sub_function(func, data_sample, non_zero_couplings)\n", - " for func in polarization_funcs[reference_subsystem]\n", + " for func in polarimetry_funcs[reference_subsystem]\n", " ]\n", - " polarizations = jnp.array(polarizations).real\n", - " abs_alpha = jnp.sqrt(jnp.sum(polarizations**2, axis=0))\n", - " mesh = plot_polarization_field(\n", - " polarizations,\n", + " polarimetry_field = jnp.array(polarimetry_field).real\n", + " abs_alpha = jnp.sqrt(jnp.sum(polarimetry_field**2, axis=0))\n", + " mesh = plot_polarimetry_field(\n", + " polarimetry_field,\n", " ax=ax,\n", " strides=22,\n", " )\n", @@ -849,7 +847,7 @@ "\n", "\n", "for reference_subsystem in tqdm([1, 2, 3]):\n", - " plot_polarization_field_per_resonance(reference_subsystem)\n", + " plot_polarimetry_field_per_resonance(reference_subsystem)\n", " del reference_subsystem" ] }, @@ -874,19 +872,19 @@ " sharey=True,\n", " tight_layout=True,\n", ")\n", - "fig.suptitle(\"Polarization field per sub-system\", y=0.95)\n", + "fig.suptitle(\"Polarimetry field per sub-system\", y=0.95)\n", "items = zip(axes, [1, 2, 3], subsystem_identifiers, subsystem_labels)\n", "for ax, reference_subsystem, subsystem_name, subsystem_label in items:\n", " ax.set_box_aspect(1)\n", " non_zero_couplings = [subsystem_name]\n", - " polarizations = [\n", + " polarimetry_field = [\n", " compute_sub_function(func, data_sample, non_zero_couplings)\n", - " for func in polarization_funcs[reference_subsystem]\n", + " for func in polarimetry_funcs[reference_subsystem]\n", " ]\n", - " polarizations = jnp.array(polarizations).real\n", - " abs_alpha = jnp.sqrt(jnp.sum(polarizations**2, axis=0))\n", - " mesh = plot_polarization_field(\n", - " polarizations,\n", + " polarimetry_field = jnp.array(polarimetry_field).real\n", + " abs_alpha = jnp.sqrt(jnp.sum(polarimetry_field**2, axis=0))\n", + " mesh = plot_polarimetry_field(\n", + " polarimetry_field,\n", " ax=ax,\n", " strides=18,\n", " )\n", @@ -942,12 +940,12 @@ " 0\n", " ]\n", " non_zero_couplings = [to_regex(resonance.name)]\n", - " polarizations = [\n", + " polarimetry_field = [\n", " compute_sub_function(func, data_sample, non_zero_couplings)\n", - " for func in polarization_funcs[reference_subsystem]\n", + " for func in polarimetry_funcs[reference_subsystem]\n", " ]\n", - " polarizations = jnp.array(polarizations).real\n", - " mesh = plot_polarization_field(polarizations, ax=ax, strides=14)\n", + " polarimetry_field = jnp.array(polarimetry_field).real\n", + " mesh = plot_polarimetry_field(polarimetry_field, ax=ax, strides=14)\n", " color_bar = fig.colorbar(mesh, ax=ax, pad=0.01)\n", " color_bar.set_label(R\"$\\left|\\vec{\\alpha}\\right|$\")\n", " fig.savefig(output_filename, transparent=True)\n", @@ -988,12 +986,12 @@ " 0\n", " ]\n", " non_zero_couplings = [to_regex(resonance.name)]\n", - " polarizations = [\n", + " polarimetry_field = [\n", " compute_sub_function(func, data_sample, non_zero_couplings)\n", - " for func in polarization_funcs[reference_subsystem]\n", + " for func in polarimetry_funcs[reference_subsystem]\n", " ]\n", - " polarizations = jnp.array(polarizations).real\n", - " mesh = plot_polarization_field(polarizations, ax=ax, strides=22)\n", + " polarimetry_field = jnp.array(polarimetry_field).real\n", + " mesh = plot_polarimetry_field(polarimetry_field, ax=ax, strides=22)\n", " color_bar = fig.colorbar(mesh, ax=ax, pad=0.01)\n", " color_bar.set_label(R\"$\\left|\\vec{\\alpha}\\right|$\")\n", " fig.savefig(output_filename, transparent=True)\n", diff --git a/docs/uncertainties.ipynb b/docs/uncertainties.ipynb index 2cc23de2..868eeee6 100644 --- a/docs/uncertainties.ipynb +++ b/docs/uncertainties.ipynb @@ -48,28 +48,28 @@ "from tensorwaves.function.sympy import create_parametrized_function\n", "from tqdm.auto import tqdm\n", "\n", - "from polarization import formulate_polarization\n", - "from polarization.amplitude import AmplitudeModel\n", - "from polarization.data import (\n", + "from polarimetry import formulate_polarimetry\n", + "from polarimetry.amplitude import AmplitudeModel\n", + "from polarimetry.data import (\n", " create_data_transformer,\n", " generate_meshgrid_sample,\n", " generate_phasespace_sample,\n", ")\n", - "from polarization.function import integrate_intensity, sub_intensity\n", - "from polarization.io import (\n", - " export_polarization_field,\n", + "from polarimetry.function import integrate_intensity, sub_intensity\n", + "from polarimetry.io import (\n", + " export_polarimetry_field,\n", " mute_jax_warnings,\n", " perform_cached_doit,\n", ")\n", - "from polarization.lhcb import (\n", + "from polarimetry.lhcb import (\n", " ParameterBootstrap,\n", " load_model_builder,\n", " load_model_parameters,\n", ")\n", - "from polarization.lhcb.particle import load_particles\n", - "from polarization.plot import use_mpl_latex_fonts\n", + "from polarimetry.lhcb.particle import load_particles\n", + "from polarimetry.plot import use_mpl_latex_fonts\n", "\n", - "logging.getLogger(\"polarization.io\").setLevel(logging.INFO)\n", + "logging.getLogger(\"polarimetry.io\").setLevel(logging.INFO)\n", "mute_jax_warnings()\n", "FUNCTION_CACHE: dict[sp.Expr, ParametrizedBackendFunction] = {}" ] @@ -171,10 +171,8 @@ "unfolded_exprs = {}\n", "for title, model in tqdm(models.items(), desc=\"Unfolding expressions\"):\n", " amplitude_builder = load_model_builder(model_file, particles, model_id=title)\n", - " polarization_exprs = formulate_polarization(\n", - " amplitude_builder, reference_subsystem\n", - " )\n", - " folded_exprs = {f\"alpha_{i}\": expr for i, expr in zip(\"xyz\", polarization_exprs)}\n", + " polarimetry_exprs = formulate_polarimetry(amplitude_builder, reference_subsystem)\n", + " folded_exprs = {f\"alpha_{i}\": expr for i, expr in zip(\"xyz\", polarimetry_exprs)}\n", " folded_exprs[\"intensity\"] = model.intensity\n", " unfolded_exprs[title] = {\n", " key: perform_cached_doit(expr.doit().xreplace(model.amplitudes))\n", @@ -230,7 +228,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "This time, we do not {ref}`substitute certain parameters with their parameter defaults`, but lambdify the full expression, so that parameter values can be set for different models. Note that this makes lambdification slower. This is mitigated by caching the lambdified function if using the unfolded expression as cache key." + "This time, we do not {ref}`substitute certain parameters with their parameter defaults`, but lambdify the full expression, so that parameter values can be set for different models. Note that this makes lambdification slower. This is mitigated by caching the lambdified function if using the unfolded expression as cache key." ] }, { @@ -329,7 +327,7 @@ "stat_decay_rates = defaultdict(list)\n", "for i in tqdm(\n", " range(n_bootstraps),\n", - " desc=\"Computing polarizations and intensities for parameter combinations\",\n", + " desc=\"Computing polarimetry and intensities for parameter combinations\",\n", "):\n", " new_parameters = {k: v[i] for k, v in bootstrap_parameters.items()}\n", " for key, func in nominal_functions.items():\n", @@ -356,8 +354,8 @@ "outputs": [], "source": [ "stat_intensities = jnp.array(stat_grids[\"intensity\"])\n", - "stat_polarizations = jnp.array([stat_grids[f\"alpha_{i}\"] for i in \"xyz\"])\n", - "stat_polarization_norms = jnp.sqrt(jnp.sum(stat_polarizations**2, axis=0))\n", + "stat_polarimetry = jnp.array([stat_grids[f\"alpha_{i}\"] for i in \"xyz\"])\n", + "stat_polarimetry_norm = jnp.sqrt(jnp.sum(stat_polarimetry**2, axis=0))\n", "stat_decay_rates = {k: jnp.array(v) for k, v in stat_decay_rates.items()}" ] }, @@ -375,8 +373,8 @@ "outputs": [], "source": [ "assert stat_intensities.shape == (n_bootstraps, n_events)\n", - "assert stat_polarizations.shape == (3, n_bootstraps, n_events)\n", - "assert stat_polarization_norms.shape == (n_bootstraps, n_events)\n", + "assert stat_polarimetry.shape == (3, n_bootstraps, n_events)\n", + "assert stat_polarimetry_norm.shape == (n_bootstraps, n_events)\n", "n_bootstraps, n_events" ] }, @@ -389,21 +387,21 @@ "outputs": [], "source": [ "stat_alpha_mean = [\n", - " jnp.mean(stat_polarization_norms, axis=0),\n", - " *jnp.mean(stat_polarizations, axis=1),\n", + " jnp.mean(stat_polarimetry_norm, axis=0),\n", + " *jnp.mean(stat_polarimetry, axis=1),\n", "]\n", "stat_alpha_std = [\n", - " jnp.std(stat_polarization_norms, axis=0),\n", - " *jnp.std(stat_polarizations, axis=1),\n", + " jnp.std(stat_polarimetry_norm, axis=0),\n", + " *jnp.std(stat_polarimetry, axis=1),\n", "]\n", "\n", "stat_alpha_times_I_mean = [\n", - " jnp.mean(stat_polarization_norms * stat_intensities, axis=0),\n", - " *jnp.mean(stat_polarizations * stat_intensities, axis=1),\n", + " jnp.mean(stat_polarimetry_norm * stat_intensities, axis=0),\n", + " *jnp.mean(stat_polarimetry * stat_intensities, axis=1),\n", "]\n", "stat_alpha_times_I_std = [\n", - " jnp.std(stat_polarization_norms * stat_intensities, axis=0),\n", - " *jnp.std(stat_polarizations * stat_intensities, axis=1),\n", + " jnp.std(stat_polarimetry_norm * stat_intensities, axis=0),\n", + " *jnp.std(stat_polarimetry * stat_intensities, axis=1),\n", "]\n", "stat_alpha_times_I_mean = jnp.array(stat_alpha_times_I_mean)\n", "stat_alpha_times_I_std = jnp.array(stat_alpha_times_I_std)\n", @@ -488,7 +486,7 @@ " sharey=True,\n", ")\n", "plt.subplots_adjust(hspace=0.02, wspace=0.02)\n", - "fig.suptitle(R\"Polarization sensitivity $\\vec\\alpha$ (statistical)\")\n", + "fig.suptitle(R\"Polarimetry field $\\vec\\alpha$ (statistical)\")\n", "s1_label = R\"$m^2\\left(K^-\\pi^+\\right)$ [GeV$/c^2$]\"\n", "s2_label = R\"$m^2\\left(pK^-\\right)$ [GeV$/c^2$]\"\n", "s3_label = R\"$m^2\\left(p\\pi^+\\right)$ [GeV$/c^2$]\"\n", @@ -632,10 +630,10 @@ "for func in nominal_functions.values():\n", " func.update_parameters(nominal_parameters)\n", "nominal_intensity = nominal_functions[\"intensity\"](phsp_sample)\n", - "nominal_polarizations = jnp.array(\n", + "nominal_polarimetry = jnp.array(\n", " [nominal_functions[f\"alpha_{i}\"](phsp_sample).real for i in \"xyz\"]\n", ")\n", - "nominal_polarization_norms = jnp.sqrt(jnp.sum(nominal_polarizations**2, axis=0))" + "nominal_polarimetry_norm = jnp.sqrt(jnp.sum(nominal_polarimetry**2, axis=0))" ] }, { @@ -670,8 +668,8 @@ " if i != 0:\n", " title = Rf\"$\\alpha_{'xyz'[i-1]}$\"\n", " z_values = jnp.abs(\n", - " (stat_alpha_mean[i] - nominal_polarizations[i - 1])\n", - " / nominal_polarizations[i - 1]\n", + " (stat_alpha_mean[i] - nominal_polarimetry[i - 1])\n", + " / nominal_polarimetry[i - 1]\n", " )\n", " else:\n", " title = \"$I$\"\n", @@ -740,8 +738,8 @@ "outputs": [], "source": [ "syst_intensities = jnp.array(syst_grids[\"intensity\"])\n", - "syst_polarizations = jnp.array([syst_grids[f\"alpha_{i}\"] for i in \"xyz\"])\n", - "syst_polarization_norms = jnp.sqrt(jnp.sum(syst_polarizations**2, axis=0))\n", + "syst_polarimetry = jnp.array([syst_grids[f\"alpha_{i}\"] for i in \"xyz\"])\n", + "syst_polarimetry_norm = jnp.sqrt(jnp.sum(syst_polarimetry**2, axis=0))\n", "syst_decay_rates = {k: jnp.array(v) for k, v in syst_decay_rates.items()}" ] }, @@ -762,8 +760,8 @@ "source": [ "n_models = len(models)\n", "assert syst_intensities.shape == (n_models, n_events)\n", - "assert syst_polarizations.shape == (3, n_models, n_events)\n", - "assert syst_polarization_norms.shape == (n_models, n_events)\n", + "assert syst_polarimetry.shape == (3, n_models, n_events)\n", + "assert syst_polarimetry_norm.shape == (n_models, n_events)\n", "n_models, n_events" ] }, @@ -774,12 +772,12 @@ "outputs": [], "source": [ "syst_alpha_mean = [\n", - " jnp.mean(syst_polarization_norms, axis=0),\n", - " *jnp.mean(syst_polarizations, axis=1),\n", + " jnp.mean(syst_polarimetry_norm, axis=0),\n", + " *jnp.mean(syst_polarimetry, axis=1),\n", "]\n", "alpha_diff_with_model_0 = [\n", - " syst_polarization_norms - syst_polarization_norms[0],\n", - " *(syst_polarizations - syst_polarizations[:, None, 0]),\n", + " syst_polarimetry_norm - syst_polarimetry_norm[0],\n", + " *(syst_polarimetry - syst_polarimetry[:, None, 0]),\n", "]\n", "\n", "syst_alpha_mean = jnp.array(syst_alpha_mean)\n", @@ -796,16 +794,16 @@ "metadata": {}, "outputs": [], "source": [ - "syst_polarizations_times_I = [\n", - " syst_polarization_norms * syst_intensities,\n", - " *(syst_polarizations * syst_intensities),\n", + "syst_polarimetry_times_I = [\n", + " syst_polarimetry_norm * syst_intensities,\n", + " *(syst_polarimetry * syst_intensities),\n", "]\n", - "syst_polarizations_times_I = jnp.array(syst_polarizations_times_I)\n", + "syst_polarimetry_times_I = jnp.array(syst_polarimetry_times_I)\n", "\n", "\n", - "syst_alpha_times_I_mean = syst_polarizations_times_I.mean(axis=1)\n", + "syst_alpha_times_I_mean = syst_polarimetry_times_I.mean(axis=1)\n", "syst_alpha_times_I_diff = (\n", - " syst_polarizations_times_I - syst_polarizations_times_I[:, None, 0]\n", + " syst_polarimetry_times_I - syst_polarimetry_times_I[:, None, 0]\n", ")\n", "assert syst_alpha_times_I_diff.shape == (4, n_models, n_events)\n", "assert jnp.nanmax(syst_alpha_times_I_diff[:, 0]) == 0.0\n", @@ -953,7 +951,7 @@ " sharey=True,\n", ")\n", "plt.subplots_adjust(hspace=0.02, wspace=0.02)\n", - "fig.suptitle(R\"Polarization sensitivity $\\vec\\alpha$ (systematics)\")\n", + "fig.suptitle(R\"Polerimetry field $\\vec\\alpha$ (systematics)\")\n", "axes[0, 0].set_ylabel(s2_label)\n", "axes[1, 0].set_ylabel(s2_label)\n", "\n", @@ -1084,7 +1082,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Uncertainty on polarization" + "## Uncertainty on polarimetry" ] }, { @@ -1128,10 +1126,10 @@ " return jnp.sqrt(dot(array, array, axis=axis))\n", "\n", "\n", - "def compute_theta(polarizations: jnp.ndarray) -> jnp.ndarray:\n", + "def compute_theta(polerimetry: jnp.ndarray) -> jnp.ndarray:\n", " return jnp.arccos(\n", - " dot(polarizations, nominal_polarizations[:, None])\n", - " / (norm(polarizations) * norm(nominal_polarizations))\n", + " dot(polerimetry, nominal_polarimetry[:, None])\n", + " / (norm(polerimetry) * norm(nominal_polarimetry))\n", " )\n", "\n", "\n", @@ -1139,8 +1137,8 @@ " return 2 * jnp.pi * (1 - jnp.cos(theta))\n", "\n", "\n", - "stat_theta = compute_theta(stat_polarizations)\n", - "syst_theta = compute_theta(syst_polarizations)\n", + "stat_theta = compute_theta(stat_polarimetry)\n", + "syst_theta = compute_theta(syst_polarimetry)\n", "assert stat_theta.shape == (n_bootstraps, n_events)\n", "assert syst_theta.shape == (n_models, n_events)\n", "\n", @@ -1200,13 +1198,13 @@ "source": [ "stat_alpha_rel_difference = (\n", " 100\n", - " * norm(stat_polarizations - nominal_polarizations[:, None])\n", - " / norm(nominal_polarizations[:, None])\n", + " * norm(stat_polarimetry - nominal_polarimetry[:, None])\n", + " / norm(nominal_polarimetry[:, None])\n", ")\n", "syst_alpha_rel_difference = (\n", " 100\n", - " * norm(syst_polarizations - nominal_polarizations[:, None])\n", - " / norm(nominal_polarizations[:, None])\n", + " * norm(syst_polarimetry - nominal_polarimetry[:, None])\n", + " / norm(nominal_polarimetry[:, None])\n", ")\n", "assert stat_alpha_rel_difference.shape == (n_bootstraps, n_events)\n", "assert syst_alpha_rel_difference.shape == (n_models, n_events)\n", @@ -1334,7 +1332,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Average polarizations" + "## Average polarimetry values" ] }, { @@ -1359,18 +1357,18 @@ "\n", "\n", "stat_weighted_alpha_norm = jnp.sqrt(\n", - " compute_weighted_average(stat_polarization_norms**2, weights=stat_intensities)\n", + " compute_weighted_average(stat_polarimetry_norm**2, weights=stat_intensities)\n", ")\n", "stat_weighted_alpha = compute_weighted_average(\n", - " stat_polarizations,\n", + " stat_polarimetry,\n", " weights=stat_intensities,\n", ")\n", "\n", "syst_weighted_alpha_norm = jnp.sqrt(\n", - " compute_weighted_average(syst_polarization_norms**2, weights=syst_intensities)\n", + " compute_weighted_average(syst_polarimetry_norm**2, weights=syst_intensities)\n", ")\n", "syst_weighted_alpha = compute_weighted_average(\n", - " syst_polarizations,\n", + " syst_polarimetry,\n", " weights=syst_intensities,\n", ")\n", "\n", @@ -1750,8 +1748,8 @@ " for key, func in nominal_functions.items():\n", " func.update_parameters(nominal_parameters)\n", " func.update_parameters(new_parameters)\n", - " filename = f\"export/polarization-field-bootstrap-{i}.json\"\n", - " export_polarization_field(\n", + " filename = f\"export/polarimetry-field-bootstrap-{i}.json\"\n", + " export_polarimetry_field(\n", " sigma1=X_export[0],\n", " sigma2=Y_export[:, 0],\n", " intensity=nominal_functions[\"intensity\"](grid_sample).real,\n", @@ -1807,8 +1805,8 @@ "for i, (title, funcs) in tqdm(items):\n", " for func in funcs.values():\n", " func.update_parameters(original_parameters[title])\n", - " filename = f\"export/polarization-field-model-{i}.json\"\n", - " export_polarization_field(\n", + " filename = f\"export/polarimetry-field-model-{i}.json\"\n", + " export_polarimetry_field(\n", " sigma1=X_export[0],\n", " sigma2=Y_export[:, 0],\n", " intensity=funcs[\"intensity\"](grid_sample).real,\n", @@ -1883,7 +1881,7 @@ "combined_json[s1_key] = s1_values\n", "combined_json[s2_key] = s2_values\n", "\n", - "filename = \"export/polarization-field.json\"\n", + "filename = \"export/polarimetry-field.json\"\n", "with open(filename, \"w\") as f:\n", " json.dump(combined_json, f)" ] diff --git a/environment.yml b/environment.yml index 6bf71e3e..24a460e8 100644 --- a/environment.yml +++ b/environment.yml @@ -1,4 +1,4 @@ -name: polarization +name: polarimetry channels: - defaults dependencies: diff --git a/pyproject.toml b/pyproject.toml index df92fece..d26f234e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ requires = [ ] [tool.setuptools_scm] -write_to = "src/polarization/version.py" +write_to = "src/polarimetry/version.py" [tool.black] exclude = ''' diff --git a/setup.cfg b/setup.cfg index 05f4c5d3..e5a70801 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] -name = polarization-sensitivity -description = Symbolic polarization sensitivity +name = polarimetry +description = Symbolic expressions that describe an aligned polarimeter vector field author = Mikhail Mikhasenko, Remco de Boer long_description = file: README.md long_description_content_type = text/markdown @@ -68,6 +68,6 @@ dev = where = src [options.package_data] -polarization.lhcb = +polarimetry.lhcb = model-definitions.yaml particle-definitions.yaml diff --git a/src/polarization/__init__.py b/src/polarimetry/__init__.py similarity index 90% rename from src/polarization/__init__.py rename to src/polarimetry/__init__.py index 2635ae85..1867f522 100644 --- a/src/polarization/__init__.py +++ b/src/polarimetry/__init__.py @@ -6,7 +6,7 @@ from ampform.sympy import PoolSum from sympy.physics.matrices import msigma -from polarization.spin import create_spin_range +from polarimetry.spin import create_spin_range from .amplitude import DalitzPlotDecompositionBuilder @@ -16,13 +16,13 @@ from typing import Literal -def formulate_polarization( +def formulate_polarimetry( builder: DalitzPlotDecompositionBuilder, reference_subsystem: Literal[1, 2, 3] = 1 ) -> tuple[PoolSum, PoolSum, PoolSum]: half = sp.Rational(1, 2) if builder.decay.initial_state.spin != half: raise ValueError( - "Can only formulate polarization for an initial state with spin 1/2, but" + "Can only formulate polarimetry for an initial state with spin 1/2, but" f" got {builder.decay.initial_state.spin}" ) model = builder.formulate(reference_subsystem) diff --git a/src/polarization/_attrs.py b/src/polarimetry/_attrs.py similarity index 90% rename from src/polarization/_attrs.py rename to src/polarimetry/_attrs.py index dc6c4243..38d558be 100644 --- a/src/polarization/_attrs.py +++ b/src/polarimetry/_attrs.py @@ -7,7 +7,7 @@ from attrs import Attribute if TYPE_CHECKING: - from polarization.decay import LSCoupling + from polarimetry.decay import LSCoupling def assert_spin_value(instance, attribute: Attribute, value: sp.Rational) -> None: @@ -18,7 +18,7 @@ def assert_spin_value(instance, attribute: Attribute, value: sp.Rational) -> Non def to_ls(obj: LSCoupling | tuple[int, SupportsFloat] | None) -> LSCoupling: - from polarization.decay import LSCoupling + from polarimetry.decay import LSCoupling if obj is None: return None diff --git a/src/polarization/amplitude/__init__.py b/src/polarimetry/amplitude/__init__.py similarity index 98% rename from src/polarization/amplitude/__init__.py rename to src/polarimetry/amplitude/__init__.py index 95113122..cadfbda9 100644 --- a/src/polarization/amplitude/__init__.py +++ b/src/polarimetry/amplitude/__init__.py @@ -11,12 +11,8 @@ from sympy.physics.quantum.spin import Rotation as Wigner from sympy.physics.quantum.spin import WignerD -from polarization.decay import ( - ThreeBodyDecay, - ThreeBodyDecayChain, - get_decay_product_ids, -) -from polarization.spin import create_spin_range +from polarimetry.decay import ThreeBodyDecay, ThreeBodyDecayChain, get_decay_product_ids +from polarimetry.spin import create_spin_range from .angles import formulate_scattering_angle, formulate_zeta_angle diff --git a/src/polarization/amplitude/angles.py b/src/polarimetry/amplitude/angles.py similarity index 99% rename from src/polarization/amplitude/angles.py rename to src/polarimetry/amplitude/angles.py index 01f089d4..29c67e2b 100644 --- a/src/polarization/amplitude/angles.py +++ b/src/polarimetry/amplitude/angles.py @@ -2,7 +2,7 @@ import sympy as sp -from polarization.dynamics import Kallen +from polarimetry.dynamics import Kallen def formulate_scattering_angle( diff --git a/src/polarization/data.py b/src/polarimetry/data.py similarity index 98% rename from src/polarization/data.py rename to src/polarimetry/data.py index f7a4b1ae..bf166c14 100644 --- a/src/polarization/data.py +++ b/src/polarimetry/data.py @@ -15,8 +15,8 @@ from tensorwaves.function.sympy import create_function from tensorwaves.interface import DataSample -from polarization.amplitude import AmplitudeModel -from polarization.decay import ThreeBodyDecay +from polarimetry.amplitude import AmplitudeModel +from polarimetry.decay import ThreeBodyDecay if sys.version_info < (3, 8): from typing_extensions import Literal diff --git a/src/polarization/decay.py b/src/polarimetry/decay.py similarity index 98% rename from src/polarization/decay.py rename to src/polarimetry/decay.py index da8668bc..3ad689a8 100644 --- a/src/polarization/decay.py +++ b/src/polarimetry/decay.py @@ -8,7 +8,7 @@ from attrs import field, frozen from attrs.validators import instance_of -from polarization._attrs import assert_spin_value, to_ls, to_rational +from polarimetry._attrs import assert_spin_value, to_ls, to_rational if sys.version_info < (3, 8): from typing_extensions import Literal diff --git a/src/polarization/dynamics.py b/src/polarimetry/dynamics.py similarity index 98% rename from src/polarization/dynamics.py rename to src/polarimetry/dynamics.py index eec2f792..add5651c 100644 --- a/src/polarization/dynamics.py +++ b/src/polarimetry/dynamics.py @@ -123,7 +123,7 @@ def _latex(self, printer, *args) -> str: @make_commutative @implement_doit_method class FlattéSWave(UnevaluatedExpression): - # https://github.com/ComPWA/polarization-sensitivity/blob/34f5330/julia/notebooks/model0.jl#L151-L161 + # https://github.com/ComPWA/polarimetry/blob/34f5330/julia/notebooks/model0.jl#L151-L161 def __new__(cls, s, m0, widths, masses1, masses2): return create_expression(cls, s, m0, widths, masses1, masses2) diff --git a/src/polarization/function.py b/src/polarimetry/function.py similarity index 100% rename from src/polarization/function.py rename to src/polarimetry/function.py diff --git a/src/polarization/io.py b/src/polarimetry/io.py similarity index 97% rename from src/polarization/io.py rename to src/polarimetry/io.py index 72e7dc5f..78e9ba9d 100644 --- a/src/polarization/io.py +++ b/src/polarimetry/io.py @@ -3,7 +3,7 @@ Functions in this module are registered with :func:`functools.singledispatch` and can be extended as follows: ->>> from polarization.io import as_latex +>>> from polarimetry.io import as_latex >>> @as_latex.register(int) ... def _(obj: int) -> str: ... return "my custom rendering" @@ -33,7 +33,7 @@ from ampform.sympy import UnevaluatedExpression from IPython.display import Math, display -from polarization.decay import IsobarNode, Particle, ThreeBodyDecay, ThreeBodyDecayChain +from polarimetry.decay import IsobarNode, Particle, ThreeBodyDecay, ThreeBodyDecayChain _LOGGER = logging.getLogger(__name__) @@ -251,7 +251,7 @@ def perform_cached_doit( unevaluated_expr: A `sympy.Expr ` on which to call :code:`doit()`. directory: The directory in which to cache the result. If `None`, the cache - directory will be put under the source code directory where `polarization` + directory will be put under the source code directory where `polarimetry` is installed. .. tip:: For a faster cache, set `PYTHONHASHSEED @@ -316,7 +316,7 @@ def mute_jax_warnings() -> None: jax_logger.setLevel(logging.ERROR) -def export_polarization_field( +def export_polarimetry_field( sigma1: jnp.ndarray, sigma2: jnp.ndarray, alpha_x: jnp.ndarray, @@ -351,7 +351,7 @@ def export_polarization_field( json.dump(json_data, f, separators=(",", ":")) -def import_polarization_field(filename: str, steps: int = 1) -> dict[str, jnp.ndarray]: +def import_polarimetry_field(filename: str, steps: int = 1) -> dict[str, jnp.ndarray]: with open(filename) as f: json_data: dict = json.load(f) return { diff --git a/src/polarization/lhcb/__init__.py b/src/polarimetry/lhcb/__init__.py similarity index 97% rename from src/polarization/lhcb/__init__.py rename to src/polarimetry/lhcb/__init__.py index 1b5f76c4..90488bba 100644 --- a/src/polarization/lhcb/__init__.py +++ b/src/polarimetry/lhcb/__init__.py @@ -17,13 +17,13 @@ import yaml from sympy.core.symbol import Str -from polarization.amplitude import ( +from polarimetry.amplitude import ( AmplitudeModel, DalitzPlotDecompositionBuilder, DynamicsBuilder, ) -from polarization.decay import IsobarNode, Particle, ThreeBodyDecay, ThreeBodyDecayChain -from polarization.spin import filter_parity_violating_ls, generate_ls_couplings +from polarimetry.decay import IsobarNode, Particle, ThreeBodyDecay, ThreeBodyDecayChain +from polarimetry.spin import filter_parity_violating_ls, generate_ls_couplings from .dynamics import ( formulate_breit_wigner, @@ -331,7 +331,7 @@ def parameter_key_to_symbol(key: str) -> sp.Indexed | sp.Symbol: H_prod = sp.IndexedBase(R"\mathcal{H}^\mathrm{production}") half = sp.Rational(1, 2) if key.startswith("A"): - # https://github.com/ComPWA/polarization-sensitivity/issues/5#issue-1220525993 + # https://github.com/ComPWA/polarimetry/issues/5#issue-1220525993 R = _stringify(key[1:-1]) i = int(key[-1]) if str(R).startswith("L"): diff --git a/src/polarization/lhcb/dynamics.py b/src/polarimetry/lhcb/dynamics.py similarity index 94% rename from src/polarization/lhcb/dynamics.py rename to src/polarimetry/lhcb/dynamics.py index 311d987d..46238d2a 100644 --- a/src/polarization/lhcb/dynamics.py +++ b/src/polarimetry/lhcb/dynamics.py @@ -2,8 +2,8 @@ import sympy as sp -from polarization.decay import Particle, ThreeBodyDecayChain -from polarization.dynamics import BreitWignerMinL, BuggBreitWigner, FlattéSWave, Q +from polarimetry.decay import Particle, ThreeBodyDecayChain +from polarimetry.dynamics import BreitWignerMinL, BuggBreitWigner, FlattéSWave, Q from .particle import PARTICLE_TO_ID, K, Σ, p, π @@ -84,7 +84,7 @@ def formulate_breit_wigner(decay_chain: ThreeBodyDecayChain): resonance_width: decay_chain.resonance.width, child1_mass: decay_chain.decay_products[0].mass, child2_mass: decay_chain.decay_products[1].mass, - # https://github.com/ComPWA/polarization-sensitivity/pull/11#issuecomment-1128784376 + # https://github.com/ComPWA/polarimetry/pull/11#issuecomment-1128784376 R_dec: 1.5, R_prod: 5, } diff --git a/src/polarization/lhcb/model-definitions.yaml b/src/polarimetry/lhcb/model-definitions.yaml similarity index 100% rename from src/polarization/lhcb/model-definitions.yaml rename to src/polarimetry/lhcb/model-definitions.yaml diff --git a/src/polarization/lhcb/particle-definitions.yaml b/src/polarimetry/lhcb/particle-definitions.yaml similarity index 100% rename from src/polarization/lhcb/particle-definitions.yaml rename to src/polarimetry/lhcb/particle-definitions.yaml diff --git a/src/polarization/lhcb/particle.py b/src/polarimetry/lhcb/particle.py similarity index 94% rename from src/polarization/lhcb/particle.py rename to src/polarimetry/lhcb/particle.py index ea060779..d3c3ce86 100644 --- a/src/polarization/lhcb/particle.py +++ b/src/polarimetry/lhcb/particle.py @@ -8,7 +8,7 @@ import sympy as sp import yaml -from polarization.decay import Particle +from polarimetry.decay import Particle if sys.version_info < (3, 8): from typing_extensions import TypedDict @@ -84,5 +84,5 @@ class ResonanceJSON(TypedDict): π = __PARTICLE_DATABASE["pi+"] PARTICLE_TO_ID = {Λc: 0, p: 1, π: 2, K: 3} -# https://github.com/ComPWA/polarization-sensitivity/blob/34f5330/julia/notebooks/model0.jl#L43-L47 +# https://github.com/ComPWA/polarimetry/blob/34f5330/julia/notebooks/model0.jl#L43-L47 Σ = __PARTICLE_DATABASE["Sigma-"] diff --git a/src/polarization/plot.py b/src/polarimetry/plot.py similarity index 100% rename from src/polarization/plot.py rename to src/polarimetry/plot.py diff --git a/src/polarization/py.typed b/src/polarimetry/py.typed similarity index 100% rename from src/polarization/py.typed rename to src/polarimetry/py.typed diff --git a/src/polarization/spin.py b/src/polarimetry/spin.py similarity index 100% rename from src/polarization/spin.py rename to src/polarimetry/spin.py diff --git a/tests/amplitude/test_angles.py b/tests/amplitude/test_angles.py index 287c92d3..01fc541a 100644 --- a/tests/amplitude/test_angles.py +++ b/tests/amplitude/test_angles.py @@ -3,7 +3,7 @@ import sympy as sp from ampform.kinematics.phasespace import Kallen, compute_third_mandelstam -from polarization.amplitude.angles import ( +from polarimetry.amplitude.angles import ( formulate_scattering_angle, formulate_theta_hat_angle, formulate_zeta_angle, diff --git a/tests/test_decay.py b/tests/test_decay.py index bc102cfd..dc1d87c0 100644 --- a/tests/test_decay.py +++ b/tests/test_decay.py @@ -1,4 +1,4 @@ -from polarization.decay import IsobarNode, Particle +from polarimetry.decay import IsobarNode, Particle # https://compwa-org--129.org.readthedocs.build/report/018.html#resonances-and-ls-scheme dummy_args = dict(mass=0, width=0) diff --git a/tests/test_io.py b/tests/test_io.py index a094e263..c1b2ad80 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -9,12 +9,12 @@ import pytest import sympy as sp -from polarization import formulate_polarization -from polarization.amplitude import DalitzPlotDecompositionBuilder -from polarization.decay import IsobarNode, Particle -from polarization.io import _warn_about_unsafe_hash, as_latex, get_readable_hash -from polarization.lhcb import load_model_builder -from polarization.lhcb.particle import load_particles +from polarimetry import formulate_polarimetry +from polarimetry.amplitude import DalitzPlotDecompositionBuilder +from polarimetry.decay import IsobarNode, Particle +from polarimetry.io import _warn_about_unsafe_hash, as_latex, get_readable_hash +from polarimetry.lhcb import load_model_builder +from polarimetry.lhcb.particle import load_particles if TYPE_CHECKING: from _pytest.logging import LogCaptureFixture @@ -81,7 +81,7 @@ def test_get_readable_hash(assumptions, expected_hash, caplog: LogCaptureFixture @pytest.mark.parametrize( - ("model_id", "intensity_hash", "polarization_hash"), + ("model_id", "intensity_hash", "polarimetry_hash"), [ (0, 55901977, 26197362), (1, 55901977, 26197362), @@ -103,7 +103,7 @@ def test_get_readable_hash(assumptions, expected_hash, caplog: LogCaptureFixture # 17: No dynamics implemented for lineshape "Flatte1405_LS" ], ) -def test_get_readable_hash_large(model_id, intensity_hash, polarization_hash): +def test_get_readable_hash_large(model_id, intensity_hash, polarimetry_hash): python_hash_seed = os.environ.get("PYTHONHASHSEED") if python_hash_seed != "0": pytest.skip("PYTHONHASHSEED is not 0") @@ -112,9 +112,9 @@ def test_get_readable_hash_large(model_id, intensity_hash, polarization_hash): model = builder.formulate(reference_subsystem=1) h = get_readable_hash(model.full_expression) assert int(h[17:25]) == intensity_hash - polarization_exprs = formulate_polarization(builder, reference_subsystem=1) - h = get_readable_hash(polarization_exprs[0].doit().xreplace(model.amplitudes)) - assert int(h[17:25]) == polarization_hash + polarimetry_exprs = formulate_polarimetry(builder, reference_subsystem=1) + h = get_readable_hash(polarimetry_exprs[0].doit().xreplace(model.amplitudes)) + assert int(h[17:25]) == polarimetry_hash def __get_model_builder(model_id: int | str) -> DalitzPlotDecompositionBuilder: