{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a540c86a-3bed-4543-b952-342c796d7507",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dc1ec4fb-4073-4d32-887f-e488ef0a9437",
   "metadata": {},
   "outputs": [],
   "source": [
    "t = np.arange(0,45)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "74ff2c1e-6c77-4aef-a26f-e86e5b1ce2d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "# create signal\n",
    "sig = -3*np.ones((6,45))\n",
    "for rownum, start in enumerate([15,12,16,2,14,100]):\n",
    "    sig[rownum,start:] = 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "fdc289c2-b05f-4851-9fb2-01a7bda5dd5f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# create measurement\n",
    "meas = np.ones((6,45))\n",
    "data2 = {'well':[], 'cycle': [], 'fluorescence': []}\n",
    "data = {}\n",
    "for row in range(6):\n",
    "    value = sig[row,0]\n",
    "    for col in range(45):\n",
    "        diff = sig[row,col] - value\n",
    "        value += 0.4*diff\n",
    "        meas[row,col] = value\n",
    "        data2['well'].append('well {}'.format(row+1))\n",
    "        data2['cycle'].append(col)\n",
    "        data2['fluorescence'].append(value)\n",
    "    data[f'well {row}'] = meas[row]\n",
    "data[f'cycle'] = t\n",
    "df = pd.DataFrame(data2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "6e5b1731-6d98-41dd-8a38-f8c168aeaace",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 43620 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.lineplot(data=df, x=\"cycle\", y=\"fluorescence\", hue=\"well\");\n",
    "plt.savefig(\"pcr_results.png\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "841e114f-dd6d-4136-a093-8070a3069643",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('pcr_sample_1.csv', index=False)"
   ]
  }
 ],
 "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.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
