{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting started with prenspire" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import random\n", "from pathlib import Path\n", "\n", "import lmfit\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from clophfit import prenspire\n", "from clophfit.binding.fitting import (\n", " Dataset,\n", " analyze_spectra,\n", " analyze_spectra_glob,\n", " fit_binding_glob,\n", ")\n", "from clophfit.binding.plotting import plot_emcee\n", "\n", "%load_ext autoreload\n", "%autoreload 2\n", "tpath = Path(\"../../tests/EnSpire\")" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "ef1 = prenspire.EnspireFile(tpath / \"h148g-spettroC.csv\")\n", "ef2 = prenspire.EnspireFile(tpath / \"e2-T-without_sample_column.csv\")\n", "ef3 = prenspire.EnspireFile(tpath / \"24well_clop0_95.csv\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(['A03', 'A04', 'A05', 'A06', 'B01', 'B02', 'C01', 'C02', 'C03'],\n", " ['A03', 'A04', 'A05', 'A06', 'B01', 'B02', 'C01', 'C02', 'C03'],\n", " [['A', ' ', ' ', '- ', '- ', '- ', '- '],\n", " ['B', '- ', '- ', ' ', ' ', ' ', ' '],\n", " ['C', '- ', '- ', '- ', ' ', ' ', ' '],\n", " ['D', ' ', ' ', ' ', ' ', ' ', ' ']])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ef3.wells, ef3._wells_platemap, ef3._platemap" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['file', 'verbose', 'metadata', 'measurements', 'wells', '_ini', '_fin', '_wells_platemap', '_platemap'])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ef1.__dict__.keys()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(dict_keys(['A']), dict_keys(['B', 'A', 'C', 'D', 'E', 'F', 'G', 'H']))" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ef1.measurements.keys(), ef2.measurements.keys()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "when testing each spectra for the presence of a single wavelength in the appropriate monochromator" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'temp': '25',\n", " 'Monochromator': 'Excitation',\n", " 'Min wavelength': '400',\n", " 'Max wavelength': '510',\n", " 'Wavelength': '530',\n", " 'Using of excitation filter': 'Top',\n", " 'Measurement height': '8.9',\n", " 'Number of flashes': '50',\n", " 'Number of flashes integrated': '50',\n", " 'Flash power': '100'}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ef2.measurements[\"A\"][\"metadata\"]" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['metadata', 'lambda', 'F01', 'F02', 'F03', 'F04', 'F05', 'F06', 'F07'])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ef2.measurements[\"A\"].keys()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[2163.0, 607.0, 1846.0, 517.0, 572.0, 2145.0, 2028.0]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "random.seed(11)\n", "random.sample(ef1.measurements[\"A\"][\"F01\"], 7)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Wells ['A01', 'A02']...['G04', 'G05'] generated.\n" ] }, { "data": { "text/plain": [ "Name H148G\n", "Temp 20.0\n", "Name: A01, dtype: object" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fp = tpath / \"h148g-spettroC-nota.csv\"\n", "n1 = prenspire.Note(fp, verbose=1)\n", "n1._note.set_index(\"Well\").loc[\"A01\", [\"Name\", \"Temp\"]]" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "dict_keys(['fpath', 'verbose', 'wells', '_note', 'titrations'])" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n1.__dict__.keys()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(True, False)" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "n1.wells == ef1.wells, n1.wells == ef2.wells" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | 5.2 | \n", "6.3 | \n", "7.4 | \n", "8.1 | \n", "8.2 | \n", "
|---|---|---|---|---|---|
| 272.0 | \n", "3151.0 | \n", "4181.0 | \n", "16413.0 | \n", "29192.0 | \n", "28816.0 | \n", "
| 273.0 | \n", "3130.0 | \n", "4204.0 | \n", "16926.0 | \n", "29909.0 | \n", "29545.0 | \n", "
| 274.0 | \n", "3043.0 | \n", "4232.0 | \n", "17331.0 | \n", "30900.0 | \n", "30750.0 | \n", "
| 275.0 | \n", "3079.0 | \n", "4283.0 | \n", "17680.0 | \n", "31717.0 | \n", "31547.0 | \n", "
| 276.0 | \n", "2975.0 | \n", "4264.0 | \n", "18020.0 | \n", "32564.0 | \n", "32336.0 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 496.0 | \n", "636.0 | \n", "4689.0 | \n", "43230.0 | \n", "87203.0 | \n", "87842.0 | \n", "
| 497.0 | \n", "683.0 | \n", "4923.0 | \n", "45173.0 | \n", "89719.0 | \n", "90666.0 | \n", "
| 498.0 | \n", "632.0 | \n", "4900.0 | \n", "46725.0 | \n", "93452.0 | \n", "94101.0 | \n", "
| 499.0 | \n", "854.0 | \n", "5140.0 | \n", "48452.0 | \n", "96643.0 | \n", "97506.0 | \n", "
| 500.0 | \n", "573.0 | \n", "5573.0 | \n", "50025.0 | \n", "99847.0 | \n", "100715.0 | \n", "
229 rows × 5 columns
\n", "