{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5d5f4b54",
   "metadata": {},
   "source": [
    "# Tutorial for HN_derivative module"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "012c8b72",
   "metadata": {},
   "outputs": [],
   "source": [
    "# import the necessary packages along with HavNegpy\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import os\n",
    "import HavNegpy as dd\n",
    "%matplotlib qt"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "586e4585",
   "metadata": {},
   "source": [
    "## Example of a single derivative HN fit"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3c48b36e",
   "metadata": {},
   "source": [
    "**Often the loss peak is obscured by conductivity and electrode polarization contribution**\n",
    "**The derivative technique or the conductivity free loss spectra removes the ohmic contribution and the loss peak becomes more pronounced**\n",
    "**Note: It is the derivative of the real part of the permittvity as a function of log frequency and not the imaginary part**\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fd6018f",
   "metadata": {},
   "source": [
    "**The mathematical expression is:**\n",
    "$$ \\epsilon_{deriv} = \\frac{-d\\epsilon^{´}}{dlogf} = (\\epsilon^{´´})^{2}$$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f007abc6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# extract the data and take derivative\n",
    "\n",
    "filename = 'deri_hn_example_data.txt'\n",
    "col_names = ['Freq','Eps1','Eps2']\n",
    "df = pd.read_csv(filename, sep='\\t',index_col=False,usecols = [0,1,2],names=col_names,header=None,skiprows=3,encoding='unicode_escape',engine='python')\n",
    "f = df['Freq']\n",
    "e1 = df['Eps1']\n",
    "e2 = df['Eps2']\n",
    "\n",
    "x = np.log10(f)\n",
    "# taking derivative\n",
    "dx = np.gradient(x)\n",
    "dy = np.gradient(e1)\n",
    "\n",
    "e_d = -(dy/dx)\n",
    "\n",
    "y = np.log10(e_d)\n",
    "\n",
    "# regular dielectric loss\n",
    "y2 = np.log10(e2)\n",
    "\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "14a575ab",
   "metadata": {},
   "source": [
    "**Comparing the derivative and normal dielectric loss**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "db5d7e66",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0.5, 1.0, 'Derivative Comparison')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# twin plot\n",
    "fig,ax1 = plt.subplots()\n",
    "color = 'tab:blue'\n",
    "ax1.set_xlabel('log f [Hz]')\n",
    "ax1.set_ylabel('log $\\epsilon$\"',color=color)\n",
    "ax1.scatter(x,y2,color=color)\n",
    "ax2 = ax1.twinx()\n",
    "ax1.tick_params(axis='y', labelcolor=color)\n",
    "\n",
    "color = 'tab:red'\n",
    "ax2.set_ylabel('log ( d$\\epsilon´$/ dlog f )',color=color)\n",
    "ax2.scatter(x,y,color=color)\n",
    "ax2.tick_params(axis='y', labelcolor=color)\n",
    "#fig.tight_layout()\n",
    "plt.title('Derivative Comparison')\n",
    "#ax1.legend()\n",
    "\n"
   ]
  },
  {
   "attachments": {
    "deri_comaprison.png": {
     "image/png": "[encoded data, 35160 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "b43a93ee",
   "metadata": {},
   "source": [
    "**Twin Plot**\n",
    "![deri_comaprison.png](attachment:deri_comaprison.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "b234ace1",
   "metadata": {},
   "outputs": [],
   "source": [
    "# instantiate the HN module\n",
    "hn = dd.HN_derivative()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5e27d2c5-e5e3-4a57-bfd3-702e6f488c3e",
   "metadata": {},
   "source": [
    "**Select the region of interest (ROI) to fit the data using the select range method**. <br> \n",
    "The data in ROI is shown as image in the next cell"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "1f947205",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x_lower_limit 3.336427528448189 x_upper_limit 4.78492686549629\n"
     ]
    }
   ],
   "source": [
    "#select range\n",
    "x1,y1 = hn.select_range(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "cc9d8c5d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'log ( d$\\\\epsilon´$/ dlog f )')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plt.scatter(x1,y1)\n",
    "plt.xlabel('log f [Hz]')\n",
    "plt.ylabel('log ( d$\\epsilon´$/ dlog f )')"
   ]
  },
  {
   "attachments": {
    "ROI_single.png": {
     "image/png": "[encoded data, 21244 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "8157485f",
   "metadata": {},
   "source": [
    "![ROI_single.png](attachment:ROI_single.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "c06a7f1d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "enter the beta value:0.5\n",
      "enter the gamma value:1\n",
      "enter the fm:3.7\n",
      "enter the deps:10\n",
      "enter the E.P value:0.1\n",
      "enter the s:10\n",
      "dumped_parameters {'beta': 0.5, 'gamma': 1.0, 'freq': 5011.872336272725, 'deps': 10.0, 'ep': 0.1, 's': 10.0}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#dump the initial guess parameters using dump parameters method (varies for each fn), which dumps the parameters in a json file'\n",
    "#this is required before performing the first fitting as it takes the initial guess from the json file created\n",
    "\n",
    "hn.dump_parameters_deri_hn()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4ab97a2b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loaded parameters \n",
      " {'beta': 0.5, 'gamma': 1.0, 'freq': 5011.872336272725, 'deps': 10.0, 'ep': 0.1, 's': 10.0}\n"
     ]
    }
   ],
   "source": [
    "# view the initial fit based on the dumped parameters\n",
    "# the plot is shown as a image in the next cell\n",
    "\n",
    "hn.initial_view_deri_hn(x1,y1)"
   ]
  },
  {
   "attachments": {
    "initiial_view_single.png": {
     "image/png": "[encoded data, 29652 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "171cd8ee",
   "metadata": {},
   "source": [
    "**Plot of the initial fit based on the supplied parameters**\n",
    "![initiial_view_single.png](attachment:initiial_view_single.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e72e83a5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Choose the fit function:\n",
      " 1 -- deri_HN\n",
      " 2-- deri_HN with EP\n",
      " 3 -- double_deri_HN\n",
      "1\n",
      "0.8743134274054571 0.3894566919293242 2110.7173828498676 10.972522760387898\n",
      "log fmax: 3.721481303152409\n",
      "fit parameters dumped for next iteration {'beta': 0.8743134274054571, 'gamma': 0.3894566919293242, 'freq': 2110.7173828498676, 'deps': 10.972522760387898, 'ep': 0, 's': 1}\n"
     ]
    }
   ],
   "source": [
    "# perform least squares fitting\n",
    "# the plot is shown as a image in the next cell\n",
    "\n",
    "hn.fit(x1,y1)"
   ]
  },
  {
   "attachments": {
    "fitting_example_single.png": {
     "image/png": "[encoded data, 41800 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "2a1c2a00",
   "metadata": {},
   "source": [
    "**Plot of the final fit of the deri HN function**\n",
    "![fitting_example_single.png](attachment:fitting_example_single.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d87513f7",
   "metadata": {},
   "source": [
    " **An analysis file has to be created only once during the whole run (i.e. all fit runs can be saved in the same file, unless you change the function or require saving separate processes in separate files.)**"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "dd8958bc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Do you want to use an existing file to save fit results? \n",
      " eg: existing file to save HN parameters, y or n:y\n",
      "Enter the analysis_file_name:deri_hn_fit.TXT\n",
      "file exists\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# before saving fit results an analysis file has to be created using create_analysis file method\n",
    "\n",
    "hn.create_analysis_file()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "543e0c5f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#save the fit results using save_fit method of the corresponding fit function\n",
    "#takes one argument, read more on the documentation\n",
    "\n",
    "hn.save_fit_deri_hn(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "61c2830c",
   "metadata": {},
   "source": [
    "## Derivative HN function together with Electrode Polarization (EP) contribution.\n",
    "**We will use the same data set but will include the EP slope for analysis.**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "65536763",
   "metadata": {},
   "source": [
    "**Select the region of interest (ROI) to fit the data using the select range method**. \n",
    ">The data in ROI is shown as image in the next cell"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "b306f8be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x_lower_limit 2.6326448519295482 x_upper_limit 4.678897072477492\n"
     ]
    }
   ],
   "source": [
    "#select range\n",
    "# select peak along with EP slope\n",
    "x1,y1 = hn.select_range(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "5cca6d3d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'log ( d$\\\\epsilon´$/ dlog f )')"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plt.scatter(x1,y1)\n",
    "plt.xlabel('log f [Hz]')\n",
    "plt.ylabel('log ( d$\\epsilon´$/ dlog f )')"
   ]
  },
  {
   "attachments": {
    "ROI_ep.png": {
     "image/png": "[encoded data, 17064 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "59ece6bb",
   "metadata": {},
   "source": [
    "![ROI_ep.png](attachment:ROI_ep.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ee148c91",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "enter the beta value:0.87\n",
      "enter the gamma value:0.4\n",
      "enter the fm:3.7\n",
      "enter the deps:11\n",
      "enter the E.P value:10\n",
      "enter the s:0.8\n",
      "dumped_parameters {'beta': 0.87, 'gamma': 0.4, 'freq': 5011.872336272725, 'deps': 11.0, 'ep': 10.0, 's': 0.8}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#dump the initial guess parameters using dump parameters method (varies for each fn), which dumps the parameters in a json file'\n",
    "#this is required before performing the first fitting as it takes the initial guess from the json file created\n",
    "\n",
    "hn.dump_parameters_deri_hn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "6511dac1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loaded parameters \n",
      " {'beta': 0.87, 'gamma': 0.4, 'freq': 5011.872336272725, 'deps': 11.0, 'ep': 10.0, 's': 0.8}\n"
     ]
    }
   ],
   "source": [
    "# view the initial fit based on the dumped parameters\n",
    "# the plot is shown as a image in the next cell\n",
    "\n",
    "hn.initial_view_deri_hn_ep(x1,y1)"
   ]
  },
  {
   "attachments": {
    "initiial_view_ep.png": {
     "image/png": "[encoded data, 35612 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "fd6b0eab",
   "metadata": {},
   "source": [
    "**Plot of the initial fit based on the supplied parameters**\n",
    "![initiial_view_ep.png](attachment:initiial_view_ep.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "5e2934ef",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Choose the fit function:\n",
      " 1 -- deri_HN\n",
      " 2-- deri_HN with EP\n",
      " 3 -- double_deri_HN\n",
      "2\n",
      "0.9999999999999263 0.30272223892160405 2726.031593760782 9.452742872380538 1226.423197994526 0.9999999999999816\n",
      "log fmax: 3.8533074167765435\n",
      "fit parameters dumped for next iteration {'beta': 0.9999999999999263, 'gamma': 0.30272223892160405, 'freq': 2726.031593760782, 'deps': 9.452742872380538, 'ep': 1226.423197994526, 's': 0.9999999999999816}\n"
     ]
    }
   ],
   "source": [
    "# perform least squares fitting\n",
    "# the plot is shown as a image in the next cell\n",
    "\n",
    "hn.fit(x1,y1)"
   ]
  },
  {
   "attachments": {
    "fitting_example_ep.png": {
     "image/png": "[encoded data, 51924 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "1a0bbc8a",
   "metadata": {},
   "source": [
    "**Plot of the final fit of the deri HN function with EP**\n",
    "![fitting_example_ep.png](attachment:fitting_example_ep.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "38afcec9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Do you want to use an existing file to save fit results? \n",
      " eg: existing file to save HN parameters, y or n:n\n",
      "Choose the fit function:\n",
      " 1 -- deri_HN\n",
      " 2-- deri_HN with EP\n",
      " 3 -- double_deri_HN\n",
      "2\n",
      "Enter the analysis_file_name:deri_hn_ep.TXT\n",
      "file did not exist, created deri_hn_ep.TXT\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# before saving fit results an analysis file has to be created using create_analysis file method\n",
    "\n",
    "hn.create_analysis_file()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "69c891e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#save the fit results using save_fit method of the corresponding fit function\n",
    "#takes one argument, read more on the documentation\n",
    "\n",
    "hn.save_fit_deri_hn(1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c154a5f",
   "metadata": {},
   "source": [
    "## Fitting example for double HN function\n",
    "**We will now look at an example to fit two HN functions using the same datafile**"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "86e717b2",
   "metadata": {},
   "source": [
    "**Select the region of interest (ROI) to fit the data using the select range method**. \n",
    ">The data in ROI is shown as image in the next cell"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "5d57e1d4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "x_lower_limit 3.336575800996946 x_upper_limit 6.308199991188614\n"
     ]
    }
   ],
   "source": [
    "#select range\n",
    "x1,y1 = hn.select_range(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "88d22b2c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Text(0, 0.5, 'log ( d$\\\\epsilon´$/ dlog f )')"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "plt.scatter(x1,y1)\n",
    "plt.xlabel('log f [Hz]')\n",
    "plt.ylabel('log ( d$\\epsilon´$/ dlog f )')"
   ]
  },
  {
   "attachments": {
    "ROI_double.png": {
     "image/png": "[encoded data, 23632 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "5e9bf73c",
   "metadata": {},
   "source": [
    "![ROI_double.png](attachment:ROI_double.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "73fac4e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "enter the beta1 value:0.87\n",
      "enter the gamma1 value:0.4\n",
      "enter the fmax1:3.75\n",
      "enter the deps1:11\n",
      "enter the beta2 value:0.8\n",
      "enter the gamma2 value:0.7\n",
      "enter the fmax2:5.75\n",
      "enter the deps2:5.5\n",
      "enter the E.P value:0\n",
      "enter the s:1\n",
      "dumped_parameters {'beta1': 0.87, 'gamma1': 0.4, 'freq1': 5623.413251903491, 'deps1': 11.0, 'beta2': 0.8, 'gamma2': 0.7, 'freq2': 562341.3251903491, 'deps2': 5.5, 'ep': 0.0, 's': 1.0}\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#dump the initial guess parameters using dump parameters method (varies for each fn), which dumps the parameters in a json file'\n",
    "#this is required before performing the first fitting as it takes the initial guess from the json file created\n",
    "\n",
    "hn.dump_parameters_deri_double_hn()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "e2d8064e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loaded parameters \n",
      " {'beta1': 0.87, 'gamma1': 0.4, 'freq1': 5623.413251903491, 'deps1': 11.0, 'beta2': 0.8, 'gamma2': 0.7, 'freq2': 562341.3251903491, 'deps2': 5.5, 'ep': 0.0, 's': 1.0}\n"
     ]
    }
   ],
   "source": [
    "# view the initial fit based on the dumped parameters\n",
    "# the plot is shown as a image in the next cell\n",
    "\n",
    "hn.initial_view_deri_double_hn(x1,y1)"
   ]
  },
  {
   "attachments": {
    "initiial_view_double.png": {
     "image/png": "[encoded data, 38028 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "9d4cc455",
   "metadata": {},
   "source": [
    "**Plot of the initial fit based on the supplied parameters**\n",
    "![initiial_view_double.png](attachment:initiial_view_double.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "312bbce2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Choose the fit function:\n",
      " 1 -- deri_HN\n",
      " 2-- deri_HN with EP\n",
      " 3 -- double_deri_HN\n",
      "3\n",
      "[0.87, 0.4, 5623.413251903491, 11.0, 0.8, 0.7, 562341.3251903491, 5.5]\n",
      "log fmax1: 3.705619322917452 \n",
      "log fmax2: 5.936248537403254\n",
      "fit parameters dumped for next iteration {'beta1': 0.7818622198165105, 'gamma1': 0.5488332751217193, 'freq1': 2595.3686767985687, 'deps1': 10.469910357129896, 'beta2': 0.9202494000493214, 'gamma2': 0.3219547485269172, 'freq2': 308821.2152266843, 'deps2': 4.899440972296858, 'ep': 0, 's': 1}\n"
     ]
    }
   ],
   "source": [
    "# perform least squares fitting\n",
    "# the plot is shown as a image in the next cell\n",
    "\n",
    "hn.fit(x1,y1)"
   ]
  },
  {
   "attachments": {
    "fitting_example_double.png": {
     "image/png": "[encoded data, 54596 characters]"
    }
   },
   "cell_type": "markdown",
   "id": "0204be53",
   "metadata": {},
   "source": [
    "**Plot of the final fit of the double deri HN function**\n",
    "![fitting_example_double.png](attachment:fitting_example_double.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "aa052ee8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Do you want to use an existing file to save fit results? \n",
      " eg: existing file to save HN parameters, y or n:n\n",
      "Choose the fit function:\n",
      " 1 -- deri_HN\n",
      " 2-- deri_HN with EP\n",
      " 3 -- double_deri_HN\n",
      "3\n",
      "Enter the analysis_file_name:deri_double_hn_fit.TXT\n",
      "file did not exist, created deri_double_hn_fit.TXT\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# before saving fit results an analysis file has to be created using create_analysis file method\n",
    "\n",
    "hn.create_analysis_file()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "0f0126a9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "()"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#save the fit results using save_fit method of the corresponding fit function\n",
    "#takes one argument, read more on the documentation\n",
    "\n",
    "hn.save_fit_deri_hn(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9e687d85",
   "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.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
