{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Getting started with PyProBE" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pyprobe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Convert data to standard format" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create the cell object and load some data. If this is the first time that the data has been loaded, it must first be converted into the standard format for PyProBE." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Describe the cell. Required fields are 'Name'.\n", "info_dictionary = {'Name': 'Sample cell',\n", " 'Chemistry': 'NMC622',\n", " 'Nominal Capacity [Ah]': 0.04,\n", " 'Cycler number': 1,\n", " 'Channel number': 1,}\n", "\n", "# Create a cell object\n", "cell = pyprobe.Cell(info=info_dictionary)\n", "\n", "data_directory = '../../../tests/sample_data/neware'\n", "\n", "# Uncomment if running locally\n", "# cell.process_cycler_file(cycler='neware',\n", "# folder_path=data_directory,\n", "# input_filename='sample_data_neware.xlsx',\n", "# output_filename='sample_data_neware.parquet')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If a parquet file exists alongside the original data file, you can add it as a Procedure object to the procedure dictionary of the cell. The key of the dictionary is the procedure name that you provide." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cell.add_procedure(procedure_name='Sample',\n", " folder_path = data_directory,\n", " filename = 'sample_data_neware.parquet')\n", "\n", "print(cell.procedure)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The dashboard can be launched immediately (uncomment to run when outside docs environment):" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# pyprobe.launch_dashboard([cell])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The raw data is accessible as a dataframe with the data property:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(cell.procedure['Sample'].data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Individual columns can be returned as 1D numpy arrays with the `get()` method:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "current = cell.procedure['Sample'].experiment('Break-in Cycles').charge(0).get('Current [A]')\n", "print(type(current), current)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Multiple columns can be returned at once:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "current, voltage = cell.procedure['Sample'].experiment('Break-in Cycles').charge(0).get('Current [A]', 'Voltage [V]')\n", "print(\"Current = \", current)\n", "print(\"Voltage = \", voltage)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And different unit can be returned on command:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "current_mA = cell.procedure['Sample'].experiment('Break-in Cycles').charge(0).get('Current [mA]')\n", "print(\"Current [mA] = \", current_mA)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Any part of the procedure can be plotted quickly using the ```add_line``` method:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "figure = pyprobe.Plot()\n", "figure.add_line(cell.procedure['Sample'].experiment('Break-in Cycles'), 'Experiment Time [s]', 'Voltage [V]')\n", "figure.show_image()\n", "# figure.show() # This will show the plot interactively, it is commented out for the sake of the documentation\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can use the `analysis` to further analyse the data. For the `'Break-in Cycles'` we will use the `cycling` analysis module and the functions within. These functions return `Result` objects, so they can be interacted with in the same ways as raw data:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from pyprobe.analysis import cycling\n", "cycling_summary = cycling.summary(input_data = cell.procedure['Sample'].experiment('Break-in Cycles'))\n", "print(type(cycling_summary))\n", "\n", "print(cycling_summary.data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And it can be plotted as normal too:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "figure = pyprobe.Plot()\n", "figure.add_line(cycling_summary, \n", " x = 'Capacity Throughput [Ah]', \n", " y = 'Discharge Capacity [Ah]')\n", "figure.show_image()\n", "# figure.show() # This will show the plot interactively, it is commented out for the sake of the documentation" ] } ], "metadata": { "kernelspec": { "display_name": "pyprobe-dev", "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.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }