Initial
This commit is contained in:
135
notebooks/make_basedata.ipynb
Normal file
135
notebooks/make_basedata.ipynb
Normal file
@@ -0,0 +1,135 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "import-libs",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"from pyprojroot import here"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "load-data",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"data = pd.read_csv(here() / 'data/raw/experimental_data.csv', encoding='utf-8')\n",
|
||||
"print(f\"Loaded {data.shape[0]} measurements\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "filter-complete",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Filter to complete measurements only\n",
|
||||
"data = data[data['Complete?'] == 'Complete']\n",
|
||||
"print(f\"Complete measurements: {data.shape[0]}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "filter-test",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Remove test entries\n",
|
||||
"data = data[data['Study ID'] != 26]\n",
|
||||
"print(f\"After removing test entries: {data.shape[0]}\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "clean-names",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Clean up text fields\n",
|
||||
"data['Country'] = data['Country'].str.strip()\n",
|
||||
"data['Institution'] = data['Institution'].str.strip()\n",
|
||||
"data['Lab Name'] = data['Lab Name'].str.strip()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "add-country-code",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Add country codes\n",
|
||||
"from utils import country_abbrev\n",
|
||||
"data['Country Code'] = data['Country'].map(country_abbrev)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "calculate-metrics",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Calculate derived metrics\n",
|
||||
"data['CAR'] = data['Coincidence Rate (Hz)'] / np.sqrt(data['Singles Rate A (Hz)'] * data['Singles Rate B (Hz)'])\n",
|
||||
"data['Bell Violation Sigma'] = (data['Bell Parameter (S)'] - 2.0) / 0.1 # Simplified error"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "categorize",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Categorize fidelity\n",
|
||||
"def fidelity_category(f):\n",
|
||||
" if f >= 0.98:\n",
|
||||
" return 'Excellent'\n",
|
||||
" elif f >= 0.95:\n",
|
||||
" return 'Good'\n",
|
||||
" elif f >= 0.90:\n",
|
||||
" return 'Acceptable'\n",
|
||||
" else:\n",
|
||||
" return 'Poor'\n",
|
||||
"\n",
|
||||
"data['Fidelity Category'] = data['Entanglement Fidelity'].apply(fidelity_category)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "save-data",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Save processed data\n",
|
||||
"data.to_csv(here() / 'data/base/data.csv', index=False)\n",
|
||||
"data.to_pickle(here() / 'data/base/data.pkl')\n",
|
||||
"print(f\"Saved {data.shape[0]} processed measurements\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"name": "python",
|
||||
"version": "3.9.0"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
64
notebooks/plot_bell_violation.ipynb
Normal file
64
notebooks/plot_bell_violation.ipynb
Normal file
@@ -0,0 +1,64 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig, ax = plt.subplots(figsize=(10, 6))\n",
|
||||
"\n",
|
||||
"# Histogram of Bell parameter values\n",
|
||||
"ax.hist(data['Bell Parameter (S)'], bins=20, color='steelblue', alpha=0.7, edgecolor='black')\n",
|
||||
"\n",
|
||||
"# Add classical limit line\n",
|
||||
"ax.axvline(x=2.0, color='red', linestyle='--', linewidth=2, label='Classical limit (S=2)')\n",
|
||||
"\n",
|
||||
"# Add Tsirelson bound\n",
|
||||
"ax.axvline(x=2*np.sqrt(2), color='green', linestyle='--', linewidth=2, label=f'Tsirelson bound (S={2*np.sqrt(2):.2f})')\n",
|
||||
"\n",
|
||||
"ax.set_xlabel('Bell Parameter (S)', fontsize=12)\n",
|
||||
"ax.set_ylabel('Number of Experiments', fontsize=12)\n",
|
||||
"ax.set_title('Distribution of Bell Parameter Values Across All Laboratories', fontsize=14)\n",
|
||||
"ax.legend()\n",
|
||||
"ax.grid(True, alpha=0.3)\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/bell_violation.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
68
notebooks/plot_coincidence_rates.ipynb
Normal file
68
notebooks/plot_coincidence_rates.ipynb
Normal file
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 6))\n",
|
||||
"\n",
|
||||
"# Scatter plot: Singles vs Coincidence\n",
|
||||
"geometric_mean_singles = np.sqrt(data['Singles Rate A (Hz)'] * data['Singles Rate B (Hz)'])\n",
|
||||
"ax1.scatter(geometric_mean_singles, data['Coincidence Rate (Hz)'],\n",
|
||||
" alpha=0.6, s=80, c=data['Visibility (%)'], cmap='viridis',\n",
|
||||
" edgecolors='black', linewidth=0.5)\n",
|
||||
"ax1.set_xlabel('Geometric Mean of Singles Rates (Hz)', fontsize=11)\n",
|
||||
"ax1.set_ylabel('Coincidence Rate (Hz)', fontsize=11)\n",
|
||||
"ax1.set_title('Coincidence vs Singles Rates', fontsize=12)\n",
|
||||
"ax1.grid(True, alpha=0.3)\n",
|
||||
"cbar1 = plt.colorbar(ax1.collections[0], ax=ax1)\n",
|
||||
"cbar1.set_label('Visibility (%)', fontsize=10)\n",
|
||||
"\n",
|
||||
"# CAR distribution\n",
|
||||
"ax2.hist(data['CAR'], bins=20, color='coral', alpha=0.7, edgecolor='black')\n",
|
||||
"ax2.set_xlabel('Coincidence-to-Accidental Ratio (CAR)', fontsize=11)\n",
|
||||
"ax2.set_ylabel('Frequency', fontsize=11)\n",
|
||||
"ax2.set_title('Distribution of CAR Values', fontsize=12)\n",
|
||||
"ax2.grid(True, alpha=0.3)\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/coincidence_rates.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
92
notebooks/plot_detector_comparison.ipynb
Normal file
92
notebooks/plot_detector_comparison.ipynb
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig, axes = plt.subplots(2, 2, figsize=(14, 10))\n",
|
||||
"\n",
|
||||
"# Group by detector type\n",
|
||||
"detector_groups = data.groupby('Detector Type')\n",
|
||||
"\n",
|
||||
"# Bell parameter by detector\n",
|
||||
"ax1 = axes[0, 0]\n",
|
||||
"detector_bell = detector_groups['Bell Parameter (S)'].mean().sort_values(ascending=False)\n",
|
||||
"ax1.bar(range(len(detector_bell)), detector_bell.values, color='steelblue', edgecolor='black')\n",
|
||||
"ax1.set_xticks(range(len(detector_bell)))\n",
|
||||
"ax1.set_xticklabels(detector_bell.index, rotation=45)\n",
|
||||
"ax1.set_ylabel('Mean Bell Parameter (S)', fontsize=11)\n",
|
||||
"ax1.set_title('Bell Parameter by Detector Type', fontsize=12)\n",
|
||||
"ax1.grid(True, alpha=0.3, axis='y')\n",
|
||||
"\n",
|
||||
"# Fidelity by detector\n",
|
||||
"ax2 = axes[0, 1]\n",
|
||||
"detector_fid = detector_groups['Entanglement Fidelity'].mean().sort_values(ascending=False)\n",
|
||||
"ax2.bar(range(len(detector_fid)), detector_fid.values, color='coral', edgecolor='black')\n",
|
||||
"ax2.set_xticks(range(len(detector_fid)))\n",
|
||||
"ax2.set_xticklabels(detector_fid.index, rotation=45)\n",
|
||||
"ax2.set_ylabel('Mean Entanglement Fidelity', fontsize=11)\n",
|
||||
"ax2.set_title('Fidelity by Detector Type', fontsize=12)\n",
|
||||
"ax2.grid(True, alpha=0.3, axis='y')\n",
|
||||
"\n",
|
||||
"# Detection efficiency by detector\n",
|
||||
"ax3 = axes[1, 0]\n",
|
||||
"detector_eff = detector_groups['Detection Efficiency A (%)'].mean().sort_values(ascending=False)\n",
|
||||
"ax3.bar(range(len(detector_eff)), detector_eff.values, color='mediumseagreen', edgecolor='black')\n",
|
||||
"ax3.set_xticks(range(len(detector_eff)))\n",
|
||||
"ax3.set_xticklabels(detector_eff.index, rotation=45)\n",
|
||||
"ax3.set_ylabel('Mean Detection Efficiency (%)', fontsize=11)\n",
|
||||
"ax3.set_title('Detection Efficiency by Detector Type', fontsize=12)\n",
|
||||
"ax3.grid(True, alpha=0.3, axis='y')\n",
|
||||
"\n",
|
||||
"# Sample counts\n",
|
||||
"ax4 = axes[1, 1]\n",
|
||||
"detector_counts = data['Detector Type'].value_counts()\n",
|
||||
"ax4.bar(range(len(detector_counts)), detector_counts.values, color='mediumpurple', edgecolor='black')\n",
|
||||
"ax4.set_xticks(range(len(detector_counts)))\n",
|
||||
"ax4.set_xticklabels(detector_counts.index, rotation=45)\n",
|
||||
"ax4.set_ylabel('Number of Experiments', fontsize=11)\n",
|
||||
"ax4.set_title('Sample Size by Detector Type', fontsize=12)\n",
|
||||
"ax4.grid(True, alpha=0.3, axis='y')\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/detector_comparison.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
62
notebooks/plot_fidelity_dist.ipynb
Normal file
62
notebooks/plot_fidelity_dist.ipynb
Normal file
@@ -0,0 +1,62 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5))\n",
|
||||
"\n",
|
||||
"# Histogram of fidelity\n",
|
||||
"ax1.hist(data['Entanglement Fidelity'], bins=15, color='coral', alpha=0.7, edgecolor='black')\n",
|
||||
"ax1.set_xlabel('Entanglement Fidelity', fontsize=12)\n",
|
||||
"ax1.set_ylabel('Frequency', fontsize=12)\n",
|
||||
"ax1.set_title('Distribution of Entanglement Fidelity', fontsize=13)\n",
|
||||
"ax1.grid(True, alpha=0.3)\n",
|
||||
"\n",
|
||||
"# Category pie chart\n",
|
||||
"category_counts = data['Fidelity Category'].value_counts()\n",
|
||||
"colors = ['#2ecc71', '#3498db', '#f39c12', '#e74c3c']\n",
|
||||
"ax2.pie(category_counts.values, labels=category_counts.index, autopct='%1.1f%%',\n",
|
||||
" colors=colors, startangle=90)\n",
|
||||
"ax2.set_title('Fidelity Categories', fontsize=13)\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/fidelity_dist.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
72
notebooks/plot_temperature_effects.ipynb
Normal file
72
notebooks/plot_temperature_effects.ipynb
Normal file
@@ -0,0 +1,72 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(14, 5))\n",
|
||||
"\n",
|
||||
"# Separate room temp and cryogenic\n",
|
||||
"room_temp = data[data['Temperature (K)'] > 200]\n",
|
||||
"cryo = data[data['Temperature (K)'] <= 200]\n",
|
||||
"\n",
|
||||
"# Box plot comparison\n",
|
||||
"box_data = [room_temp['Entanglement Fidelity'], cryo['Entanglement Fidelity']]\n",
|
||||
"bp = ax1.boxplot(box_data, labels=['Room Temp', 'Cryogenic'],\n",
|
||||
" patch_artist=True, notch=True)\n",
|
||||
"bp['boxes'][0].set_facecolor('coral')\n",
|
||||
"bp['boxes'][1].set_facecolor('steelblue')\n",
|
||||
"ax1.set_ylabel('Entanglement Fidelity', fontsize=12)\n",
|
||||
"ax1.set_title('Fidelity: Room Temperature vs Cryogenic', fontsize=13)\n",
|
||||
"ax1.grid(True, alpha=0.3, axis='y')\n",
|
||||
"\n",
|
||||
"# Dark counts comparison\n",
|
||||
"box_data2 = [room_temp['Dark Count Rate A (Hz)'], cryo['Dark Count Rate A (Hz)']]\n",
|
||||
"bp2 = ax2.boxplot(box_data2, labels=['Room Temp', 'Cryogenic'],\n",
|
||||
" patch_artist=True, notch=True)\n",
|
||||
"bp2['boxes'][0].set_facecolor('coral')\n",
|
||||
"bp2['boxes'][1].set_facecolor('steelblue')\n",
|
||||
"ax2.set_ylabel('Dark Count Rate (Hz)', fontsize=12)\n",
|
||||
"ax2.set_title('Dark Counts: Room Temperature vs Cryogenic', fontsize=13)\n",
|
||||
"ax2.grid(True, alpha=0.3, axis='y')\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/temperature_effects.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
69
notebooks/plot_visibility_distance.ipynb
Normal file
69
notebooks/plot_visibility_distance.ipynb
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\n",
|
||||
"import numpy as np\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"fig, ax = plt.subplots(figsize=(10, 6))\n",
|
||||
"\n",
|
||||
"# Color by detector type\n",
|
||||
"colors = {'APD': 'steelblue', 'SNSPD': 'coral', 'PMT': 'green', 'SPAD': 'purple'}\n",
|
||||
"for detector in data['Detector Type'].unique():\n",
|
||||
" mask = data['Detector Type'] == detector\n",
|
||||
" ax.scatter(data[mask]['Distance (m)'], data[mask]['Visibility (%)'],\n",
|
||||
" label=detector, alpha=0.7, s=100, color=colors.get(detector, 'gray'),\n",
|
||||
" edgecolors='black', linewidth=1)\n",
|
||||
"\n",
|
||||
"# Fit and plot trend line\n",
|
||||
"z = np.polyfit(data['Distance (m)'], data['Visibility (%)'], 1)\n",
|
||||
"p = np.poly1d(z)\n",
|
||||
"x_trend = np.linspace(data['Distance (m)'].min(), data['Distance (m)'].max(), 100)\n",
|
||||
"ax.plot(x_trend, p(x_trend), 'r--', linewidth=2, alpha=0.5, label=f'Trend (slope={z[0]:.2f})')\n",
|
||||
"\n",
|
||||
"ax.set_xlabel('Photon Pair Distance (m)', fontsize=12)\n",
|
||||
"ax.set_ylabel('Visibility (%)', fontsize=12)\n",
|
||||
"ax.set_title('Visibility vs. Photon Pair Distance', fontsize=14)\n",
|
||||
"ax.legend(loc='best')\n",
|
||||
"ax.grid(True, alpha=0.3)\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/visibility_distance.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
84
notebooks/plot_world_map.ipynb
Normal file
84
notebooks/plot_world_map.ipynb
Normal file
@@ -0,0 +1,84 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "imports",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import pandas as pd\n",
|
||||
"import matplotlib.pyplot as plt\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": "plot",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Calculate mean Bell parameter by country\n",
|
||||
"country_stats = data.groupby('Country').agg({\n",
|
||||
" 'Bell Parameter (S)': 'mean',\n",
|
||||
" 'Study ID': 'count'\n",
|
||||
"}).rename(columns={'Study ID': 'Count'}).sort_values('Bell Parameter (S)', ascending=False)\n",
|
||||
"\n",
|
||||
"fig, ax = plt.subplots(figsize=(14, 8))\n",
|
||||
"\n",
|
||||
"# Horizontal bar chart\n",
|
||||
"countries = country_stats.index[:20] # Top 20\n",
|
||||
"values = country_stats['Bell Parameter (S)'][:20]\n",
|
||||
"counts = country_stats['Count'][:20]\n",
|
||||
"\n",
|
||||
"bars = ax.barh(range(len(countries)), values, color='steelblue', edgecolor='black')\n",
|
||||
"\n",
|
||||
"# Color bars by value\n",
|
||||
"for i, (bar, val) in enumerate(zip(bars, values)):\n",
|
||||
" if val > 2.8:\n",
|
||||
" bar.set_color('#27ae60')\n",
|
||||
" elif val > 2.7:\n",
|
||||
" bar.set_color('#3498db')\n",
|
||||
" else:\n",
|
||||
" bar.set_color('#e67e22')\n",
|
||||
"\n",
|
||||
"# Add classical limit line\n",
|
||||
"ax.axvline(x=2.0, color='red', linestyle='--', linewidth=2, alpha=0.7, label='Classical limit')\n",
|
||||
"\n",
|
||||
"# Add counts as text\n",
|
||||
"for i, (val, count) in enumerate(zip(values, counts)):\n",
|
||||
" ax.text(val + 0.01, i, f'n={int(count)}', va='center', fontsize=9)\n",
|
||||
"\n",
|
||||
"ax.set_yticks(range(len(countries)))\n",
|
||||
"ax.set_yticklabels(countries)\n",
|
||||
"ax.set_xlabel('Mean Bell Parameter (S)', fontsize=12)\n",
|
||||
"ax.set_title('Mean Bell Parameter by Country (Top 20)', fontsize=14)\n",
|
||||
"ax.legend()\n",
|
||||
"ax.grid(True, alpha=0.3, axis='x')\n",
|
||||
"\n",
|
||||
"plt.tight_layout()\n",
|
||||
"plt.savefig(here() / 'output/plots/world_map.png', dpi=300, bbox_inches='tight')"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
87
notebooks/tab_laboratories.ipynb
Normal file
87
notebooks/tab_laboratories.ipynb
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
"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
|
||||
}
|
||||
99
notebooks/tab_summary.ipynb
Normal file
99
notebooks/tab_summary.ipynb
Normal file
@@ -0,0 +1,99 @@
|
||||
{
|
||||
"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": [
|
||||
"# Create summary statistics\n",
|
||||
"summary_stats = pd.DataFrame({\n",
|
||||
" 'Metric': [\n",
|
||||
" 'Total Experiments',\n",
|
||||
" 'Participating Countries',\n",
|
||||
" 'Participating Institutions',\n",
|
||||
" 'Mean Bell Parameter (S)',\n",
|
||||
" 'Mean Entanglement Fidelity',\n",
|
||||
" 'Mean Visibility (\\\\%)',\n",
|
||||
" 'Bell Violations (\\\\%)',\n",
|
||||
" 'High Fidelity ($>0.98$) (\\\\%)'\n",
|
||||
" ],\n",
|
||||
" 'Value': [\n",
|
||||
" len(data),\n",
|
||||
" data['Country'].nunique(),\n",
|
||||
" data['Institution'].nunique(),\n",
|
||||
" f\"{data['Bell Parameter (S)'].mean():.3f} $\\pm$ {data['Bell Parameter (S)'].std():.3f}\",\n",
|
||||
" f\"{data['Entanglement Fidelity'].mean():.4f} $\\pm$ {data['Entanglement Fidelity'].std():.4f}\",\n",
|
||||
" f\"{data['Visibility (%)'].mean():.2f} $\\pm$ {data['Visibility (%)'].std():.2f}\",\n",
|
||||
" f\"{(data['CHSH Violation'] == 'Yes').sum() / len(data) * 100:.1f}\",\n",
|
||||
" f\"{(data['Entanglement Fidelity'] > 0.98).sum() / len(data) * 100:.1f}\"\n",
|
||||
" ]\n",
|
||||
"})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"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{Summary Statistics of Quantum Entanglement Measurements}\n",
|
||||
"\\label{tab:summary}\n",
|
||||
"\\begin{tabular}{lr}\n",
|
||||
"\\toprule\n",
|
||||
"\\textbf{Metric} & \\textbf{Value} \\\\\n",
|
||||
"\\midrule\n",
|
||||
"'''\n",
|
||||
"\n",
|
||||
"for _, row in summary_stats.iterrows():\n",
|
||||
" latex_table += f\"{row['Metric']} & {row['Value']} \\\\\\\\\\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/summary.tex', 'w') as f:\n",
|
||||
" f.write(latex_table)\n",
|
||||
"\n",
|
||||
"print(\"Summary table saved\")"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
100
notebooks/utils.py
Normal file
100
notebooks/utils.py
Normal file
@@ -0,0 +1,100 @@
|
||||
"""Utility functions for quantum entanglement data processing."""
|
||||
|
||||
# Country name standardization
|
||||
country_conversion = {
|
||||
'usa': 'USA',
|
||||
'united states': 'USA',
|
||||
'uk': 'UK',
|
||||
'united kingdom': 'UK',
|
||||
'england': 'UK',
|
||||
}
|
||||
|
||||
# Institution name standardization
|
||||
institution_conversion = {
|
||||
'Massachusetts Institute of Technology': 'MIT',
|
||||
'University of Oxford': 'Oxford',
|
||||
}
|
||||
|
||||
# Lab type categories
|
||||
lab_types = ['University', 'Government', 'Research Institute', 'Private']
|
||||
|
||||
# Photon source types
|
||||
source_types = ['SPDC', 'PDC', 'Quantum Dot', 'Atomic Cascade']
|
||||
|
||||
# Detector types
|
||||
detector_types = ['APD', 'SNSPD', 'PMT', 'SPAD']
|
||||
|
||||
# Measurement method types
|
||||
measurement_methods = ['Coincidence', 'Homodyne', 'Heterodyne', 'Tomography']
|
||||
|
||||
# Country abbreviations
|
||||
country_abbrev = {
|
||||
'USA': 'US',
|
||||
'UK': 'GB',
|
||||
'China': 'CN',
|
||||
'Germany': 'DE',
|
||||
'Italy': 'IT',
|
||||
'France': 'FR',
|
||||
'South Korea': 'KR',
|
||||
'Brazil': 'BR',
|
||||
'Japan': 'JP',
|
||||
'Australia': 'AU',
|
||||
'Sweden': 'SE',
|
||||
'Israel': 'IL',
|
||||
'Spain': 'ES',
|
||||
'Netherlands': 'NL',
|
||||
'Denmark': 'DK',
|
||||
'Poland': 'PL',
|
||||
'Ireland': 'IE',
|
||||
'Russia': 'RU',
|
||||
'Singapore': 'SG',
|
||||
'India': 'IN',
|
||||
'Switzerland': 'CH',
|
||||
'Canada': 'CA',
|
||||
'Czech Republic': 'CZ',
|
||||
'Taiwan': 'TW',
|
||||
'Pakistan': 'PK',
|
||||
'Egypt': 'EG',
|
||||
'Portugal': 'PT',
|
||||
'Mexico': 'MX',
|
||||
'Norway': 'NO',
|
||||
'Bangladesh': 'BD',
|
||||
'Greece': 'GR',
|
||||
'Slovakia': 'SK',
|
||||
}
|
||||
|
||||
# Country populations (in millions, approximate)
|
||||
country_populations = {
|
||||
'USA': 331,
|
||||
'UK': 67,
|
||||
'China': 1444,
|
||||
'Germany': 83,
|
||||
'Italy': 60,
|
||||
'France': 65,
|
||||
'South Korea': 52,
|
||||
'Brazil': 213,
|
||||
'Japan': 126,
|
||||
'Australia': 26,
|
||||
'Sweden': 10,
|
||||
'Israel': 9,
|
||||
'Spain': 47,
|
||||
'Netherlands': 17,
|
||||
'Denmark': 6,
|
||||
'Poland': 38,
|
||||
'Ireland': 5,
|
||||
'Russia': 144,
|
||||
'Singapore': 6,
|
||||
'India': 1380,
|
||||
'Switzerland': 9,
|
||||
'Canada': 38,
|
||||
'Czech Republic': 11,
|
||||
'Taiwan': 24,
|
||||
'Pakistan': 225,
|
||||
'Egypt': 102,
|
||||
'Portugal': 10,
|
||||
'Mexico': 129,
|
||||
'Norway': 5,
|
||||
'Bangladesh': 165,
|
||||
'Greece': 11,
|
||||
'Slovakia': 5,
|
||||
}
|
||||
Reference in New Issue
Block a user