Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch install instructions and notebook examples #87

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/source/developer_guide/developer_installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ The steps to install PyProBE wih developer settings are as follows:
conda create -n pyprobe python=3.12
conda activate pyprobe

3. Install PyProBE as a package into your virtual environment:
3. Install the developer dependencies:

.. code-block:: bash

cd /path/to/your/directory/PyProBE
pip install -r requirements-dev.txt

4. Install PyProBE as a package into your virtual environment:

.. code-block:: bash

pip install -e .

The :code:`-e` flag installs in "editable" mode, which means changes that you
make to the code will be automatically reflected in the package inside your
virtual environment.

4. Install the developer dependencies:

.. code-block:: bash

pip install -r requirements-dev.txt

5. Install the pre-commit hooks:

.. code-block:: bash
Expand Down
20 changes: 13 additions & 7 deletions docs/source/examples/LEAN-differentiation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"metadata": {},
"source": [
"# Differentiating with the LEAN algorithm\n",
"This example shows how to differentiate cycler data using the LEAN algorithm developed by "
"This example shows how to differentiate cycler data using the LEAN algorithm developed in: Feng X, Merla Y, Weng C, Ouyang M, He X, Liaw BY, et al. A reliable approach of differentiating discrete sampled-data for battery diagnosis. eTransportation. 2020;3: 100051. https://doi.org/10.1016/j.etran.2020.100051.\n",
" "
]
},
{
Expand Down Expand Up @@ -53,7 +54,8 @@
"final_cycle= cell.procedure['Sample'].experiment('Break-in Cycles').cycle(-1)\n",
"fig = pyprobe.Plot()\n",
"fig.add_line(final_cycle, 'Time [hr]', 'Voltage [V]')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand Down Expand Up @@ -86,7 +88,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(discharge_dQdV, 'Capacity [Ah]', 'd(Capacity [Ah])/d(Voltage [V])', label='Discharge', color='blue')\n",
"fig.add_line(charge_dQdV, 'Capacity [Ah]', 'd(Capacity [Ah])/d(Voltage [V])', label='Charge', color='red')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -107,7 +110,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(discharge_dQdV, 'Capacity [mAh]', 'd(Capacity [mAh])/d(Voltage [V])', label='Discharge', color='blue')\n",
"fig.add_line(charge_dQdV, 'Capacity [mAh]', 'd(Capacity [mAh])/d(Voltage [V])', label='Charge', color='red')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -128,7 +132,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(discharge_dQdV, 'Cycle Capacity [Ah]', 'd(Cycle Capacity [Ah])/d(Voltage [V])', label='Discharge', color='blue')\n",
"fig.add_line(charge_dQdV, 'Cycle Capacity [Ah]', 'd(Cycle Capacity [Ah])/d(Voltage [V])', label='Charge', color='red')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -151,7 +156,8 @@
"\n",
"fig = pyprobe.Plot()\n",
"fig.add_line(pulse_rest, 'Time [s]', 'Voltage [V]')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
}
],
Expand All @@ -171,7 +177,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.12.4"
}
},
"nbformat": 4,
Expand Down
15 changes: 10 additions & 5 deletions docs/source/examples/filtering-data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"full_procedure = cell.procedure['Sample']\n",
"fig = pyprobe.Plot()\n",
"fig.add_line(full_procedure, 'Time [s]', 'Voltage [V]')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand Down Expand Up @@ -95,7 +96,8 @@
"fig.add_line(initial_charge, 'Procedure Time [s]', 'Voltage [V]', color = 'red', label='Initial Charge')\n",
"fig.add_line(break_in, 'Procedure Time [s]', 'Voltage [V]', color = 'blue', label='Break-in Cycles')\n",
"fig.add_line(pulses, 'Procedure Time [s]', 'Voltage [V]', color='purple', label='Discharge Pulses')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -116,7 +118,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(break_in, 'Experiment Time [s]', 'Voltage [V]', color = 'blue', label='Break-in Cycles')\n",
"fig.add_line(cycle_3, 'Experiment Time [s]', 'Voltage [V]', color='red', label='Cycle 3')\n",
"fig.show()\n"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -142,7 +145,8 @@
"fig.add_line(rest_0, 'Experiment Time [s]', 'Voltage [V]', color='red', label='Rest 0')\n",
"fig.add_line(charge, 'Experiment Time [s]', 'Voltage [V]', color='purple', label='Charge')\n",
"fig.add_line(rest_1, 'Experiment Time [s]', 'Voltage [V]', color='green', label='Rest 1')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -167,7 +171,8 @@
"fig.add_line(CC_discharge, 'Experiment Time [s]', 'Current [A]', color='green', label='CC Discharge')\n",
"fig.add_line(CC_charge, 'Experiment Time [s]', 'Current [A]', color='red', label='CC Charge')\n",
"fig.add_line(CV_hold, 'Experiment Time [s]', 'Current [A]', color='purple', label='CV Hold')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
}
],
Expand Down
6 changes: 4 additions & 2 deletions docs/source/examples/getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@
"source": [
"figure = pyprobe.Plot()\n",
"figure.add_line(cell.procedure['Sample'].experiment('Break-in Cycles'), 'Experiment Time [s]', 'Voltage [V]')\n",
"figure.show()"
"figure.show_image()\n",
"# figure.show() # This will show the plot interactively, it is commented out for the sake of the documentation\n"
]
},
{
Expand Down Expand Up @@ -230,7 +231,8 @@
"figure.add_line(cycling.summary(), \n",
" x = 'Capacity Throughput [Ah]', \n",
" y = 'Discharge Capacity [Ah]')\n",
"figure.show()"
"figure.show_image()\n",
"# figure.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
}
],
Expand Down
6 changes: 4 additions & 2 deletions docs/source/examples/ocv-fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(fitted_curve, x='SOC', y='Input Voltage [V]',label = \"Input\")\n",
"fig.add_line(fitted_curve, x='SOC', y='Fitted Voltage [V]', color='red', label = 'Fit', dash='dash')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -183,7 +184,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(fitted_curve, x='SOC', y='Input dSOCdV [1/V]',label = \"Input\")\n",
"fig.add_line(fitted_curve, x='SOC', y='Fitted dSOCdV [1/V]', color='red', label = 'Fit', dash='dash')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
}
],
Expand Down
6 changes: 4 additions & 2 deletions docs/source/examples/providing-valid-inputs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,8 @@
"fig = pyprobe.Plot()\n",
"fig.add_line(pOCV_cycle.discharge(0).constant_current(0), x='SOC', y='Voltage [V]', label='Discharge', color='blue')\n",
"fig.add_line(pOCV_cycle.charge(0).constant_current(0), x='SOC', y='Voltage [V]', label='Charge', color='purple')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
},
{
Expand All @@ -257,7 +258,8 @@
"averaged_ocv_dma = DMA.average_ocvs(input_data = pOCV_cycle, charge_filter=\"charge(0).constant_current(0)\", discharge_filter=\"discharge(0).constant_current(0)\")\n",
"\n",
"fig.add_line(averaged_ocv_dma.input_data, x='SOC', y='Voltage [V]', label='Average', color='red')\n",
"fig.show()"
"fig.show_image()\n",
"# fig.show() # This will show the plot interactively, it is commented out for the sake of the documentation"
]
}
],
Expand Down
12 changes: 9 additions & 3 deletions docs/source/user_guide/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,20 @@ The steps to install PyProBE are as follows:
conda create -n pyprobe python=3.12
conda activate pyprobe

3. Install PyProBE as a package into your virtual environment:
3. Install PyProBE's dependencies:

.. code-block:: bash
.. code-block:: bash

cd /path/to/your/directory/PyProBE
pip install -r requirements.txt

4. Install PyProBE as a package into your virtual environment:

.. code-block:: bash

pip install .

4. In your working directory you can create a new python script or jupyter notebook to
5. In your working directory you can create a new python script or jupyter notebook to
process your data. You can import PyProBE into your script as follows:

.. code-block:: python
Expand Down
6 changes: 6 additions & 0 deletions pyprobe/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import plotly.graph_objects as go
import polars as pl
from IPython.display import Image, display
from numpy.typing import NDArray
from plotly.express.colors import sample_colorscale
from plotly.subplots import make_subplots
Expand Down Expand Up @@ -57,6 +58,11 @@ def show(self) -> None:
"""Show the plot."""
self.fig.show()

def show_image(self) -> None:
"""Show the plot as an image."""
img_bytes = self.fig.to_image(format="png")
display(Image(img_bytes))

def add_line(
self,
result: "Result",
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ dependencies = [
"distinctipy",
"streamlit",
"PyYAML",
"nbformat",
"ordered-set",
"pydantic",
"kaleido",
"IPython"
]

[project.optional-dependencies]
Expand Down
Loading
Loading