{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "imports", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from pyprojroot import here" ] }, { "cell_type": "code", "execution_count": null, "id": "load", "metadata": {}, "outputs": [], "source": [ "data = pd.read_csv(here() / 'data/base/data.csv')" ] }, { "cell_type": "code", "execution_count": null, "id": "create-table", "metadata": {}, "outputs": [], "source": [ "# Group by detector type and calculate statistics\n", "detector_stats = data.groupby('Detector Type').agg({\n", " 'Study ID': 'count',\n", " 'Bell Parameter (S)': ['mean', 'std'],\n", " 'Entanglement Fidelity': ['mean', 'std'],\n", " 'Detection Efficiency A (%)': 'mean'\n", "}).round(3)\n", "\n", "detector_stats.columns = ['N', 'Bell S (mean)', 'Bell S (std)', \n", " 'Fidelity (mean)', 'Fidelity (std)', 'Efficiency (%)']" ] }, { "cell_type": "code", "execution_count": null, "id": "save-latex", "metadata": {}, "outputs": [], "source": [ "# Convert to LaTeX\n", "latex_table = r'''\\begin{table}[h]\n", "\\centering\n", "\\caption{Performance Metrics by Detector Type}\n", "\\label{tab:laboratories}\n", "\\begin{tabular}{lcccccc}\n", "\\toprule\n", "\\textbf{Detector} & \\textbf{N} & \\textbf{Bell S} & \\textbf{$\\sigma$} & \\textbf{Fidelity} & \\textbf{$\\sigma$} & \\textbf{Eff (\\%)} \\\\\n", "\\midrule\n", "'''\n", "\n", "for idx, row in detector_stats.iterrows():\n", " latex_table += f\"{idx} & {int(row['N'])} & {row['Bell S (mean)']:.3f} & {row['Bell S (std)']:.3f} & \"\n", " latex_table += f\"{row['Fidelity (mean)']:.4f} & {row['Fidelity (std)']:.4f} & {row['Efficiency (%)']:.1f} \\\\\\\\\\n\"\n", "\n", "latex_table += r'''\\bottomrule\n", "\\end{tabular}\n", "\\end{table}\n", "'''\n", "\n", "# Save to file\n", "with open(here() / 'output/tables/laboratories.tex', 'w') as f:\n", " f.write(latex_table)\n", "\n", "print(\"Laboratories table saved\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" } }, "nbformat": 4, "nbformat_minor": 5 }