Skip to content

Commit

Permalink
Version bump + added setup.cfg file + bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
ppravatto committed Jul 13, 2023
1 parent aa99b46 commit d167ec7
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 24 deletions.
2 changes: 1 addition & 1 deletion docs/intro.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GES-echem-suite Documentation

Version: [0.2.1b](ReleaseNotes)
Version: [0.2.1b2](ReleaseNotes)

The `GES-echem-suite` library is a small collection of tools for the manipulation and analysis of electrochemical data. The library allows to load, organize, and process the data-files collected during electrochemical experiments such as battery cycling and cyclic voltammetries.

Expand Down
7 changes: 7 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
(ReleaseNotes)=
# Release notes

* Version 0.2.1b2
* Added classmethod to `RateExperiment` to load ARBIN `.csv` files.
* Added timestamp propery to `CellCycling` class to more easily track the start of the experiment.
* Added a `quickload_folder` method to the `cellcycling.read_input` module.
* Added classmethod to `RateExperiment` to load GAMRY standard folder format.
* Update to the documentation with more examples and new types of plot

* Version 0.2.1b
* Added a graphicaltools module to help the user in the creation of graphs and plots
* Defined a simple `Color` class to hold, manipulate and carry around RGB color values.
Expand Down
38 changes: 22 additions & 16 deletions echemsuite/cellcycling/experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,29 @@ def from_Biologic_battery_module(cls, path: str) -> RateExperiment:
return obj

@classmethod
def from_ARBIN_csv_file(cls, csv_path: str, variation_threshold: float = 1.) -> RateExperiment:
def from_ARBIN_csv_file(
cls,
csv_path: str,
variation_threshold: float = 1.0,
current_digits: int = 3,
) -> RateExperiment:
"""
Classmethod dedicated to the construction of a RateExperiment object starting from a ARBIN csv file. Please
notice that the ARBIN .csv files do not specify the current associated to each step explicitly, as such the
notice that the ARBIN .csv files do not specify the current associated to each step explicitly, as such the
average current per halfcycle will be used in the definition of the various rate steps. The division of
the cell-cyclicing objects in different rate steps is generated automatically by the method using a fixed
percentage threshold value. When the percentage variation threshold is exceeded the cell-cycling object is
moved to a new current step.
moved to a new current step. The current steps of the experiments are computed automatically as averages and
rounded to a user specified number of digits (default: 3)
Arguments
---------
csv_path: str
The path to the `.csv` file generated from the ARBIN battery cycler.
variation_threshold: float
The threshold (in percentage) to be used in the indetification of a new current step (default: 1%)
The threshold (in percentage) to be used in the indetification of a new current step (default: 1%).
current_digits: int
Number of digits to be kept in saving the average current values computed form the data-files (default: 3).
Raises
------
Expand Down Expand Up @@ -402,7 +410,7 @@ def parse_arbin_timestamp(timestamp_str: str) -> datetime:

# If the relative error exceeds the 1% threshold or we reached the end of the halfcycles list trigger the
# creation of the cell-cycling object corresponding to the current step
if relative_error > 1 or hidx == len(halfcycles) - 1:
if relative_error > variation_threshold or hidx == len(halfcycles) - 1:
# If a charge halfcycle is left in the buffer conclude the cycle buffer with the last charge
if charge is not None:
cycle = Cycle(number=len(cycles_buffer) + 1, charge=charge, discharge=None)
Expand All @@ -428,7 +436,7 @@ def parse_arbin_timestamp(timestamp_str: str) -> datetime:
charge = None

# Format the current steps list by rounding the current values to the third decimal place
current_steps = [round(i, 3) for i in current_steps]
current_steps = [round(i, current_digits) for i in current_steps]

# Creat a RateExperiment object with the obtained data ad return it
obj = cls(current_steps=current_steps, cellcycling_steps=cellcycling_steps)
Expand All @@ -438,7 +446,7 @@ def parse_arbin_timestamp(timestamp_str: str) -> datetime:
def from_GAMRY_folder_tree(cls, basefolder: str, current_digits: int = 3) -> RateExperiment:
"""
Classmethod dedicated to the construction of a RateExperiment object starting from a folder tree generated by
GAMRY instruments during multi-step cycling experiments. The folder structure expected is the following: a
GAMRY instruments during multi-step cycling experiments. The folder structure expected is the following: a
`basefolder` containing a set of step data-folders (with variable names) each of which contains a `CHARGE_DISCHARGE`
folder containing the desired .DTA files encoding the charge/discharge cell-cycling at a given current.
The current steps of the experiments are computed automatically as averages and rounded to a user specified
Expand All @@ -450,7 +458,7 @@ def from_GAMRY_folder_tree(cls, basefolder: str, current_digits: int = 3) -> Rat
The path to the `basefolder` containing the data-folders for each step.
current_digits: int
Number of digits to be kept in saving the average current values computed form the data-files (default: 3).
Raises
------
ValueError
Expand All @@ -461,20 +469,19 @@ def from_GAMRY_folder_tree(cls, basefolder: str, current_digits: int = 3) -> Rat
# Check if the specified basefolder exists
if not isdir(basefolder):
raise ValueError(f"The folder '{basefolder}' does not exist.")

# Define an empty list to store all the cell-cycling experimental data
cellcycling_steps: List[CellCycling] = []

# Cycle over the content of the basefolder
for folder_name in listdir(basefolder):

# Define an hypotetical search path for the CHARGE_DISCHARGE target folder
path = join(join(basefolder, folder_name), "CHARGE_DISCHARGE")

# Check if the folder containing the data is found
if not isdir(path):
continue

# Try to load the data from the CHARGE_DISCHARGE folder if the load fails (e.g. the folder is empty)
# return a warning messange to the user
cellcycling: CellCycling = None
Expand All @@ -484,27 +491,26 @@ def from_GAMRY_folder_tree(cls, basefolder: str, current_digits: int = 3) -> Rat
warn(f"Failed to load file from {path}. The folder will be skipped")
else:
cellcycling_steps.append(cellcycling)

# Check if data has been loaded, if not raise an exception
if cellcycling_steps == []:
raise RuntimeError("No valid GAMRY cell-cycling data has been found in the specified folder.")

# Sort the cell-cycling objects based on their timestamp
cellcycling_steps.sort(key=lambda x: x.timestamp)

# Evaluate the current value for each step computing the average current during the charge and discharge halfcyles
current_steps: List[float] = []
for cellcycling in cellcycling_steps:

iavg: float = 0
nsamples: int = 0
for cycle in cellcycling:
for halfcycle in [cycle.charge.current, cycle.discharge.current]:
for current in halfcycle:
iavg += abs(current)
nsamples += 1
iavg = round(iavg/nsamples, current_digits)

iavg = round(iavg / nsamples, current_digits)
current_steps.append(iavg)

# Create a RateExperiment object and return it
Expand Down
6 changes: 3 additions & 3 deletions meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% set name = "GES-echem-suite" %}
{% set version = "0.2.1b" %}
{% set version = "0.2.1b2" %}



Expand All @@ -20,12 +20,12 @@ build:

requirements:
host:
- python>=3.7
- python>=3.8
- pip
- setuptools

run:
- python>=3.7
- python>=3.8
- numpy
- pandas>=1.3.0
- scipy
Expand Down
30 changes: 30 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[metadata]
name = GES-echem-suite

[options]
packages =
echemsuite
echemsuite.cellcycling
echemsuite.cyclicvoltammetry
install_requires =
numpy
pandas>=1.3.0
scipy
matplotlib
openpyxl
palettable

python_requires = >=3.8
package_dir = =.
zip_safe = no

[options.extras_require]
testing =
pytest>=6.0
pytest-cov>=2.0
mypy>=0.910
flake8>=3.9
tox>=3.24

[flake8]
max-line-length = 160
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setuptools.setup(
name="GES-echem-suite",
version="0.2.1b",
version="0.2.1b2",
description="",
long_description="",
packages=["echemsuite"],
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[tox]
minversion = 3.7.0
envlist = py37, py38, py39, py310
minversion = 3.8.0
envlist = py38, py39, py310
isolated_build = true
skipsdist = True

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
Expand Down

0 comments on commit d167ec7

Please sign in to comment.