{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "93fb6114-6d2d-4fa4-a0d0-56b41a6d20ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 38976 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from pint import UnitRegistry\n",
    "unit = UnitRegistry()\n",
    "unit.formatter.default_format = \"~\"\n",
    "unit.setup_matplotlib()\n",
    "\n",
    "\n",
    "gain_first_stage = 10e6 * unit.V / unit.A\n",
    "gain_second_stage = 100e3 / 1e3\n",
    "\n",
    "tunnel_current_in = np.linspace(1e-12, 10e-9, 100) * unit.A\n",
    "volts_out = tunnel_current_in * gain_first_stage * gain_second_stage\n",
    "\n",
    "plt.xscale(\"log\")\n",
    "plt.plot(tunnel_current_in, volts_out)\n",
    "xticks = [1e-12, 10e-12, 100e-12, 1e-9, 10e-9] * unit.A\n",
    "plt.xticks(xticks, [f'{t.to(\"nA\"):.3f~}' for t in xticks], minor=False)\n",
    "plt.xlabel(\"Tunneling Current\")\n",
    "\n",
    "plt.yscale(\"log\")\n",
    "yticks = [0.001, 0.010, 0.1, 1.0, 5] * unit.V\n",
    "plt.yticks(yticks, [f'{t.to(\"V\"):.3f~}' for t in yticks], minor=False)\n",
    "plt.ylabel(\"Preamp Voltage\")\n",
    "plt.grid(True, \"both\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "f4bd3266-3aa1-478a-b6ff-cd4a49943c47",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "359.0 pA"
      ],
      "text/latex": [
       "$359.0\\ \\mathrm{pA}$"
      ],
      "text/plain": [
       "<Quantity(359.0, 'picoampere')>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "v = 0.359 * unit.V\n",
    "a = v / (gain_first_stage * gain_second_stage)\n",
    "a.to(\"pA\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e3dfcedf-d33c-4e3b-9d28-8282df12e121",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.13.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
