From 227ffe6fa5c0846961687ecd50e5ca8d18914d4d Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:50:53 +0100 Subject: [PATCH] DOC: render average polarimeter angles as radians (#270) --- docs/uncertainties.ipynb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/uncertainties.ipynb b/docs/uncertainties.ipynb index 0a0982bc..a289a533 100644 --- a/docs/uncertainties.ipynb +++ b/docs/uncertainties.ipynb @@ -1766,6 +1766,14 @@ }, "outputs": [], "source": [ + "def render_radian_angle_uncertainties(value, stat, syst_min, syst_max) -> str:\n", + " val = f\"{value:+.2f}\"\n", + " stat = f\"{stat:.2f}\"\n", + " syst_min = f\"-{abs(syst_min):.2f}\"\n", + " syst_max = f\"+{abs(syst_max):.2f}\"\n", + " return Rf\"{val} \\pm {stat}_{{{syst_min}}}^{{{syst_max}}}\\;\\mathrm{{rad}}\"\n", + "\n", + "\n", "def render_angle_uncertainties(value, stat, syst_min, syst_max) -> str:\n", " value /= np.pi\n", " stat /= np.pi\n", @@ -1790,15 +1798,19 @@ "]\n", "for i, label in enumerate(labels):\n", " renderer = (\n", - " render_cartesian_uncertainties if i == 0 else render_angle_uncertainties\n", + " render_cartesian_uncertainties\n", + " if i == 0\n", + " else render_radian_angle_uncertainties\n", " )\n", - " value_with_uncertainties = renderer(\n", + " args = (\n", " nominal_weighted_alpha_polar[i],\n", " stat_weighted_alpha_polar_std[i],\n", " syst_weighted_alpha_polar_min[i],\n", " syst_weighted_alpha_polar_max[i],\n", " )\n", - " src += Rf\" {label} & = & {value_with_uncertainties} \\\\\" \"\\n\"\n", + " src += Rf\" {label} & = & {renderer(*args)} \\\\\" \"\\n\"\n", + " if i > 0:\n", + " src += Rf\" & = & {render_angle_uncertainties(*args)} \\\\\" \"\\n\"\n", "\n", "src += R\"\\end{array}\"\n", "Latex(src)"