{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8bc4a913-a35e-47c6-8546-548b5519f44b",
   "metadata": {},
   "source": [
    "# Plot ELPI data"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a4c01de0-6483-4190-9ce9-63b6d750c3d6",
   "metadata": {},
   "source": [
    "First we import the aerosoltools package"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "2e761643-71a5-402e-914c-4647940a4531",
   "metadata": {
    "nbsphinx": "hidden"
   },
   "outputs": [],
   "source": [
    "import os;\n",
    "import sys;\n",
    "\n",
    "# Adjust this to the relative path from your notebook to the source directory\n",
    "sys.path.insert(0, os.path.abspath('../../../src'));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "b1fb6cb2-fa34-47bb-a938-fcbebed5e234",
   "metadata": {},
   "outputs": [],
   "source": [
    "import aerosoltools as at;"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d43e7e26-498b-40e0-b02b-f3cc86c49acc",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "source": [
    "Next we import the ELPI data via the Load function. The filename variable should give the path and filename of the relevant dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "f0523ddf-e666-4b3f-b3cf-e2ce8d1635db",
   "metadata": {},
   "outputs": [],
   "source": [
    "filename = r\"..\\..\\..\\tests\\data\\Sample_ELPI.txt\";\n",
    "ELPI_data = at.Load_ELPI_file(filename);"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "555e6d8a-4ae0-4809-8bf9-7673415a7705",
   "metadata": {},
   "source": [
    "The data is now loaded and can be treated or plotted directly. \n",
    "\n",
    "A quick way to visualize the data is via a timeseries plot, which can be done with a single line of code, as seen below.\n",
    "Here it is important to note, that the keyword y_3d is used to give a lower bound of 1 for the logarithmic colorbar. This was needed as some concentrations were reported as 0, which cannot be shown on a log scale. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c55ffb5c-0179-4bd5-b87d-e6e395583a52",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "[encoded data, 81936 characters]",
      "text/plain": [
       "<Figure size 1000x600 with 3 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "ELPI_data.plot_timeseries(y_3d=(1,0));"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4048b82f-d7cf-4225-a106-78f93824a4c1",
   "metadata": {},
   "source": [
    "## Check Various metadata"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03729a74-82f3-46bd-8795-5135e34189f9",
   "metadata": {},
   "source": [
    "We can also check various metadata loaded directly from the elpi data file"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "b1c814be-44c7-4dfe-bffa-c8f1bbec8790",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cm$^{-3}$\n"
     ]
    }
   ],
   "source": [
    "# We can check the unit of the data. All load functions return number concentration data also if the original data file was in a different mode\n",
    "print(ELPI_data.unit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "0e8ca87f-52fb-4a54-bb70-940d3e6df7fe",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "dN\n"
     ]
    }
   ],
   "source": [
    "# We can check the data type\n",
    "print(ELPI_data.dtype)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "446fc074-bf57-4913-a923-61d7c2365b9d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ELPI\n"
     ]
    }
   ],
   "source": [
    "# We can ensure that the correct instrument was stored\n",
    "print(ELPI_data.instrument)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "554aff54-34b9-4cdd-8c99-7d272ae0e9ac",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1.0\n"
     ]
    }
   ],
   "source": [
    "# We can check the density of the datafile, which should always be given in g/cm3\n",
    "print(ELPI_data.density)"
   ]
  }
 ],
 "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.22"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
