photodetector/calculations.ipynb

279 lines
167 KiB
Plaintext
Raw Normal View History

2024-10-20 11:47:17 -06:00
{
"cells": [
{
"cell_type": "code",
2024-10-20 13:06:04 -06:00
"execution_count": 42,
2024-10-20 11:47:17 -06:00
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"from matplotlib import pyplot as plt\n",
"import xarray as xr\n",
"from pathlib import Path\n",
"\n",
"dir_ = Path(globals()[\"_dh\"][0]) # __file__ does not exist in ipynb"
]
},
{
"cell_type": "code",
2024-10-20 13:06:04 -06:00
"execution_count": 43,
2024-10-20 11:47:17 -06:00
"metadata": {},
"outputs": [],
"source": [
"def read_wpd_csv(\n",
" filepath: Path | str, x_coord: str, ds_coord: str | None = None\n",
") -> xr.DataArray:\n",
" filepath = Path(filepath)\n",
"\n",
" header = np.loadtxt(filepath, dtype=str, max_rows=2, delimiter=\",\")\n",
" header_values = header[0][::2]\n",
" try:\n",
" np.array(header_values, dtype=float)\n",
" except ValueError:\n",
" np.array(header_values)\n",
"\n",
" values = np.loadtxt(filepath, dtype=float, skiprows=2, delimiter=\",\")\n",
"\n",
" coords = dict()\n",
" dims = [x_coord]\n",
" if ds_coord is not None:\n",
" dims.append(ds_coord)\n",
" coords[ds_coord] = header_values\n",
"\n",
" for col in range(int(values.shape[1] / 2)):\n",
" x = values[:, col * 2]\n",
" if col == 0:\n",
" coords[x_coord] = x\n",
" else:\n",
" if np.any(x != coords[x_coord]):\n",
" raise ValueError(f\"All webplotdigitizer datasets must share x values\")\n",
"\n",
" da = xr.DataArray(\n",
" values[:, 1::2],\n",
" dims=dims,\n",
" coords=coords,\n",
" attrs=dict(filename=filepath.name),\n",
" )\n",
" return da"
]
},
{
"cell_type": "code",
2024-10-20 13:06:04 -06:00
"execution_count": 47,
2024-10-20 11:47:17 -06:00
"metadata": {},
"outputs": [],
"source": [
"# LED properties\n",
"LEDS = {\n",
" \"APHHS1005F3C-70MAV\": dict(\n",
2024-10-20 13:06:04 -06:00
" emission=8e-3, # W/sr\n",
" emission_current=70e-3, # A\n",
" max_current=1200e-3, # A 1% duty, 10us pulse\n",
" lambda_=940e-9, # m\n",
" ),\n",
" # \"SFH 4053\": dict(\n",
" # emission=7e-3, # W/sr\n",
" # emission_current=70e-3, # A\n",
" # lambda_=860e-9, # m\n",
" # ),\n",
" \"IN-S42CTQHIR\": dict(\n",
" emission=4.5e-3, # W/sr\n",
" emission_current=70e-3, # A\n",
" max_current=500e-3, # A 1% duty, 100us pulse\n",
" lambda_=940e-9, # m\n",
" ),\n",
" \"15404094BA420\": dict(\n",
" emission=3e-3, # W/sr\n",
" emission_current=70e-3, # A\n",
" max_current=500e-3, # A 10% duty, 10kHz (10us pulse)\n",
" lambda_=940e-9, # m\n",
" ),\n",
2024-10-20 11:47:17 -06:00
"}\n",
"\n",
"# Photodiode properties\n",
"PHOTODIODES = {\n",
" \"PD15-22B/TR8\": dict(\n",
" dark_current=5e-9, # A\n",
" light_current=read_wpd_csv(\n",
" dir_ / \"data/PD15-22B/reverse_light_current.csv\",\n",
" \"irradiance\",\n",
" \"vr\",\n",
" ).isel(vr=0),\n",
" ),\n",
" \"TEMD5110X01\": dict(\n",
" dark_current=3e-9, # A\n",
" light_current=read_wpd_csv(\n",
" dir_ / \"data/TEMD5110X01/reverse_light_current.csv\",\n",
" \"irradiance\",\n",
" \"vr\",\n",
" ).isel(vr=0),\n",
" ),\n",
"}"
]
},
{
"cell_type": "code",
2024-10-20 13:06:04 -06:00
"execution_count": 50,
2024-10-20 11:47:17 -06:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Text(0.5, 1.0, 'Photodiode Transfer Function')"
]
},
2024-10-20 13:06:04 -06:00
"execution_count": 50,
2024-10-20 11:47:17 -06:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnYAAAHWCAYAAAD6oMSKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6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jz1GTk6ORzvDMHj22WepX78+oaGh9O/fn+3btxf5uZ0+fZoHHniABg0aEBQURPPmzfn73/+Oy+Uqsn1J5d83+PLLLzNjxgx3zDt27CA3N5cpU6bQpUsXIiMjCQsLo3fv3qxYscLrPt5++233Prp168a6des82h47dozx48dTv359goKCqFOnDtdccw0HDx4EwGKxMHv2bDIyMtz/f2dfivzggw/o0qULISEhREVFcfPNN/Prr796HKNfv360a9eODRs20KdPH0JDQ3nssccu+jMq6pKoxWLh6aefdj/P/3nYu3cv48aNo3r16kRGRjJ+/HgyMzMLvf6DDz6ge/fuhIaGUqNGDfr06cPixYsB817L7du3891337k/i379+gHe77GbN2+e+/OJjo7mtttu4/Dhwx5txo0bR3h4OIcPH2b06NGEh4dTq1YtHn74YZxO5wV/TiLlwT//bBYRt3379gFQs2ZNj/L777+fGjVq8NRTT3Hw4EFmzJjBxIkTmTt3rrvN008/zdSpUxk4cCD33XcfiYmJvPXWW6xbt45Vq1Zht9t5/PHHSU1N5bfffuO1114DCi41ZmVl0a9fP/bu3cvEiRNp0qQJ8+bNY9y4cZw+fZq//OUvgJlwXXPNNfzwww/ce++9tGnThvnz5zN27NgSvce7776b999/nxtuuIGHHnqIn376ienTp7Nz507mz5/vbjdlyhSeffZZhg8fzvDhw9m4cSODBw8mNzfXY3+ZmZn07duXw4cP88c//pGGDRuyevVqJk+ezNGjR8vkfsLZs2eTnZ3NPffcQ1BQEFFRUaSlpfHuu+9yyy23MGHCBM6cOcN7773HkCFDWLt2baFBDR9++CFnzpzhj3/8IxaLhRdffJHrrruO/fv3Y7fbAbj++uvZvn07999/P40bNyY5OZklS5Zw6NAhGjduzL///W/efvtt1q5dy7vvvgvAFVdcAcBzzz3Hk08+yZgxY7j77rtJSUnh9ddfp0+fPvz8889Ur17dHcuJEycYNmwYN998M7fddhuxsbHn/QxOnjzp8dxms1GjRo0L+jzHjBlDkyZNmD59Ohs3buTdd98lJiaGv//97+42U6dO5emnn+aKK65g2rRpBAYG8tNPP7F8+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rQodHk4KCiI8ePHl+oYn3zyCUuWLHE//vOf/5Tq9We79957PZ737t2bEydOkJaWBsBnn32Gy+ViypQpHj/PwAVNn7N+/XqSk5P505/+5HHv3YgRI2jdunWR50dRMeb/X4n4C12KFfEzCQkJtGzZkoCAAGJjY2nVqlWhX2QADRs29HienyDkJwD5CV6rVq082gUGBtK0aVN3fXF++eUXWrRoUej4bdq08TjGL7/8Qp06dQqNkDz32N6OYbVaad68uUd57dq1qV69uscxAFq0aOHRrlatWoUu/+3Zs4ctW7YUSrzyJScnnzeu82nSpEmR5e+//z6vvPIKu3btwuFwFNv+fP+HQUFB/P3vf+ehhx4iNjaWyy+/nJEjR3LHHXdQu3btYuPbs2cPhmEU+rzy5V/qzVevXr1SD77o06dPmQ2eKO6ziIiIYN++fVitVuLi4srkeN7OD4DWrVvzww8/eJQFBwcX+nmqUaNGqRNukfKmxE7Ez3Tv3t09KrY4NputyHLDMMo6pEuiLCctdrlcDBo0iEceeaTI+pYtW170MUJCQgqVffDBB4wbN47Ro0fz17/+lZiYGGw2G9OnT3ffK3m2kvwfPvDAA4waNYrPPvuMRYsW8eSTTzJ9+nS
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"fig, ax = plt.subplots(tight_layout=True)\n",
"for diode, properties in PHOTODIODES.items():\n",
" lc: xr.DataArray = properties[\"light_current\"]\n",
" lines = ax.loglog(lc.coords[\"irradiance\"], lc, label=diode)\n",
"\n",
" ax.axhline(properties[\"dark_current\"], color=lines[0].get_color(), linestyle=\"--\")\n",
" ax.axvline(\n",
" np.max(lc.coords[\"irradiance\"]), color=lines[0].get_color(), linestyle=\"--\"\n",
" )\n",
"\n",
"ax.set_xlabel(\"Irradiance [$W/m^2$]\")\n",
"ax.set_ylabel(\"Current [A]\")\n",
"ax.grid(True)\n",
"ax.legend(loc=\"upper left\")\n",
"ax.set_title(\"Photodiode Transfer Function\")"
]
},
{
"cell_type": "code",
2024-10-20 13:06:04 -06:00
"execution_count": 61,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Max light current: 117 uA\n"
]
}
],
"source": [
"print(\n",
" f'Max light current: {PHOTODIODES[\"TEMD5110X01\"][\"light_current\"].max().data / 1e-6:.0f} uA'\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 49,
2024-10-20 11:47:17 -06:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Text(0.5, 1.0, 'Component comparison')"
]
},
2024-10-20 13:06:04 -06:00
"execution_count": 49,
2024-10-20 11:47:17 -06:00
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
2024-10-20 13:06:04 -06:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAnYAAAHWCAYAAAD6oMSKAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOydd3zM9x/HX3eXXPbeIbKHEEmsNJQYIYigKI3RxGx/VaXaUjqsao2irdFSGbSIUbH3CEHESCIiQ0QSQQbZe9y9f3+cHF93WRVN8Hk+Ht8H38/3/dnf3L3vM14fHhERGAwGg8FgMBivPfyWLgCDwWAwGAwGo3lgjh2DwWAwGAzGGwJz7BgMBoPBYDDeEJhjx2AwGAwGg/GGwBw7BoPBYDAYjDcE5tgxGAwGg8FgvCEwx47BYDAYDAbjDYE5dgwGg8FgMBhvCMyxYzAYDAaDwXhDYI4dg8FgMFoMCwsL+Pv7t3QxGIw3BubYMRhvISkpKfjoo49gZWUFZWVlaGpqomfPnvj1119RXl7e0sV77dmxYwd++eWXli4Gg8F4C+Gxs2IZjLeLI0eO4P3334eSkhI+/PBDdOzYEVVVVbh48SL++ecf+Pv7Y/PmzS1dzNeaoUOHIi4uDmlpaS1dlFZPZWUl+Hw+FBUVW7ooDMYbgUJLF4DBYPx3pKam4oMPPoC5uT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qsi5GjBgBPp+PJUuWyIxy1Y4oeXp6QigU4rfffuOMMgUEBKCwsPCV9MWGDRs49+vWrQMAaRvXjoI9X57
2024-10-20 11:47:17 -06:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
2024-10-20 13:06:04 -06:00
"d = np.linspace(0.1, 1000, 10000) # downrange distance\n",
"# area_objective = np.pi * (80e-3 / 2) ** 2\n",
"# area_spot = np.pi * (3e-3 / 2) ** 2 # approximation\n",
"# gain_optical = area_objective / area_spot\n",
"gain_optical = 80**2 # telescope claims 80x which I believe is linear, not area\n",
2024-10-20 11:47:17 -06:00
"\n",
"# Received power density\n",
2024-10-20 13:06:04 -06:00
"fig, ax = plt.subplots(tight_layout=True)\n",
2024-10-20 11:47:17 -06:00
"for led, properties in LEDS.items():\n",
2024-10-20 13:06:04 -06:00
" incident_power = properties[\"emission\"] * (1 / (d**2)) # W / m^2 at objective\n",
" power_density = incident_power * gain_optical\n",
2024-10-20 11:47:17 -06:00
"\n",
" lines = ax.loglog(\n",
" d,\n",
2024-10-20 13:06:04 -06:00
" power_density,\n",
" label=f\"{led} ({properties['emission_current']/1e-3:.1f} mA)\",\n",
2024-10-20 11:47:17 -06:00
" )\n",
"\n",
2024-10-20 13:06:04 -06:00
" max_current = properties.get(\"max_current\", None)\n",
" if max_current is not None:\n",
" ax.loglog(\n",
" d,\n",
" power_density * max_current / properties[\"emission_current\"],\n",
" color=lines[0].get_color(),\n",
" alpha=0.5,\n",
" label=f\"{led} ({max_current/1e-3:.1f} mA)\",\n",
" )\n",
"\n",
"\n",
2024-10-20 11:47:17 -06:00
"ax.set_prop_cycle(None) # reset color cycle to keep colors consistent across plots\n",
"for diode, properties in PHOTODIODES.items():\n",
" ax.axhline(\n",
" np.max(properties[\"light_current\"].coords[\"irradiance\"]),\n",
" linestyle=\"--\",\n",
" label=f\"{diode} Psat\",\n",
" color=ax._get_lines.get_next_color(),\n",
" )\n",
"\n",
"ax.set_xlabel(\"Range [m]\")\n",
"ax.set_ylabel(\"RX Power Density [$W/m^2$]\")\n",
"ax.grid(True)\n",
"ax.legend(loc=\"upper right\")\n",
"ax.set_title(\"Component comparison\")"
]
2024-10-20 13:06:04 -06:00
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
2024-10-20 11:47:17 -06:00
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 2
}