{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Sharing Data\n", "\n", "PyProBE makes sharing data simple and straightforward. This is a simple example to demonstrate the process.\n", "\n", "First we will import some sample data:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%%capture\n", "%pip install matplotlib" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "import shutil\n", "from pprint import pprint\n", "\n", "import pyprobe\n", "\n", "%matplotlib inline\n", "\n", "# Describe the cell. Required fields are 'Name'.\n", "info_dictionary = {\n", " \"Name\": \"Sample cell\",\n", " \"Chemistry\": \"NMC622\",\n", " \"Nominal Capacity [Ah]\": 0.04,\n", " \"Cycler number\": 1,\n", " \"Channel number\": 1,\n", "}\n", "\n", "# Create a cell object\n", "cell = pyprobe.Cell(info=info_dictionary)\n", "\n", "data_directory = \"../../../tests/sample_data/neware\"\n", "\n", "cell.add_procedure(\n", " procedure_name=\"Sample\",\n", " folder_path=data_directory,\n", " filename=\"sample_data_neware.parquet\",\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can then use the `archive()` method of the cell object. This stores all attributes of the `cell` object into a single folder. The data is stored as `.parquet` files and the metadata is stored in `.json` files." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cell.archive(path=\"sample_archive\")\n", "os.listdir(\".\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can choose to compress the folder by adding `.zip` to the path:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "cell.archive(path=\"sample_archive.zip\")\n", "os.listdir(\".\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can then retrieve the archived object with the `pyprobe.load_archive()` method:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "saved_cell = pyprobe.load_archive(\"sample_archive.zip\")\n", "pprint(saved_cell.info)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "saved_cell.procedure[\"Sample\"].plot(x=\"Time [hr]\", y=\"Voltage [V]\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Clean up after example" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "shutil.rmtree(\"sample_archive\")" ] } ], "metadata": { "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 }