{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "334dee65",
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "\n",
    "sys.path.insert(0, '..\\src')\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "\n",
    "import satlas2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6cbf210c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'amplitude': 5+/-0 (inf max, -inf min, vary=True, correl={}),\n",
       " 'halflife': 3+/-0 (inf max, -inf min, vary=True, correl={})}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 27388 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "amplitude = 5\n",
    "halflife = 3\n",
    "model = satlas2.ExponentialDecay(amplitude, halflife)\n",
    "\n",
    "x = np.linspace(0, 5*halflife, 100)\n",
    "y = model.f(x)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])\n",
    "ax.plot(x, y)\n",
    "ax.set_xlabel('Time [s]')\n",
    "ax.set_ylabel('Intensity [-]')\n",
    "ax.set_title('Exponential decay')\n",
    "model.params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d74ea3ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'p2': 1+/-0 (inf max, -inf min, vary=True, correl={}),\n",
       " 'p1': 0+/-0 (inf max, -inf min, vary=True, correl={}),\n",
       " 'p0': 5+/-0 (inf max, -inf min, vary=True, correl={})}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 31432 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "coefficients = [1, 0, 5] # Polynomial coefficients, starting with highest order\n",
    "model = satlas2.Polynomial(coefficients)\n",
    "\n",
    "x = np.linspace(-10, 10, 100)\n",
    "y = model.f(x)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])\n",
    "ax.plot(x, y)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('y')\n",
    "ax.set_title('Polynomial')\n",
    "model.params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "52ee2a51",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'value2': 5+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'value1': 0+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'value0': 1+/-0 (inf max, 0 min, vary=True, correl={})}"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 13484 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "values = [1, 0, 5]\n",
    "boundaries = [3, 7]\n",
    "model = satlas2.Step(values, boundaries)\n",
    "\n",
    "x = np.linspace(0, 10, 100)\n",
    "y = model.f(x)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])\n",
    "ax.plot(x, y)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('y')\n",
    "ax.set_title('Step')\n",
    "model.params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "a0725112",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'A': 7+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'mu': 20+/-0 (inf max, -inf min, vary=True, correl={}),\n",
       " 'FWHMG': 10+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'FWHML': 15+/-0 (inf max, 0 min, vary=True, correl={})}"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 27512 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "amplitude = 7\n",
    "mu = 20\n",
    "FWHMG = 10\n",
    "FWHML = 15\n",
    "model = satlas2.Voigt(amplitude, mu, FWHMG, FWHML)\n",
    "fwhm, _ = model.calculateFWHM()\n",
    "\n",
    "x = np.linspace(mu-2*fwhm, mu+2*fwhm, 100)\n",
    "y = model.f(x)\n",
    "\n",
    "fig = plt.figure()\n",
    "ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])\n",
    "ax.plot(x, y)\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('y')\n",
    "ax.set_title('Voigt')\n",
    "model.params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8c989f0a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'A': 7+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'mu': 20+/-0 (inf max, -inf min, vary=True, correl={}),\n",
       " 'FWHMG': 10+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'FWHML': 15+/-0 (inf max, 0 min, vary=True, correl={}),\n",
       " 'Skew': 3+/-0 (inf max, -inf min, vary=True, correl={})}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 65956 characters]\n",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "amplitude = 7\n",
    "mu = 20\n",
    "FWHMG = 10\n",
    "FWHML = 15\n",
    "skew = [-3, -1, 0, 1, 3]\n",
    "fig = plt.figure()\n",
    "ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])\n",
    "\n",
    "x = np.linspace(mu-2*fwhm, mu+2*fwhm, 100)\n",
    "for s in skew:\n",
    "    model = satlas2.SkewedVoigt(amplitude, mu, FWHMG, FWHML, s)\n",
    "    y = model.f(x)\n",
    "    ax.plot(x, y, label='Skew = {}'.format(s))\n",
    "\n",
    "ax.set_xlabel('x')\n",
    "ax.set_ylabel('y')\n",
    "ax.set_title('Skewed Voigt')\n",
    "ax.legend(loc=0)\n",
    "model.params"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2f10c717",
   "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.11.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
