Skip to main content

Package for parsing the contents of Gamry EXPLAIN data (DTA) files.

Project description

gamry-parser

PyPI PyPI - Python Version PyPI - License

Python package for parsing the contents of Gamry EXPLAIN data (DTA) files. This package is meant to convert flat-file EXPLAIN data into pandas DataFrames for easy analysis and visualization.

Getting Started

Dependencies

  • pandas

Installation

Package from PyPi

$ pip install gamry-parser

Local Installation

  1. Check out the latest code:
$ git clone git@github.com:bcliang/gamry-parser.git
  1. Use setuptools to install the package
$ python setup.py install

Usage

The provided Usage example loads a CV DTA file two ways, and demonstrates the utility of custom functions within the CyclicVoltammetry subclass (get_v_range, get_scan_rate)

$ python usage.py

GamryParser Example

The following snippet loads a DTA file and prints to screen: (1) experiment type, (2) # of curves, and (3) a random curve in the form of a pandas DataFrame.

import gamry_parser as parser
import random

file = '/enter/the/file/path.dta'
gp = parser.GamryParser()
gp.load(filename=file)

print("experiment type: {}".format(gp.get_experiment_type()))
print("loaded curves: {}".format(gp.get_curve_count()))

curve_index = random.randint(1,gp.get_curve_count())
print("showing curve #{}".format(curve_index))
print(gp.get_curve_data(curve_index))

ChronoAmperometry Example

The ChronoAmperometry class is a subclass of GamryParser. Executing the method get_curve_data() will return a DataFrame with three columns: (1) T, (2) Vf, and (3) Im

In the example, the file is expected to be a simple chronoamperometry experiment (single step, no preconditioning); there will only be a single curve of data contained within the file. In addition, note the use of the to_timestamp property, which allows the user to request get_curve_data to return a DataFrame with a T column containing DateTime objects (as opposed to the default: float seconds since start).

import gamry_parser as parser
import random

file = '/enter/the/file/path.dta'
ca = parser.ChronoAmperometry(to_timestamp=True)
ca.load(filename=file)
print(ca.get_curve_data())

Demos

A simple demonstration is provided in usage.py.

python usage.py

ipython notebook demonstration scripts are included in the demo folder.

  • notebook_gamry_parser.ipynb: Simple example loading data from ChronoA experiment output. Instead of gamry_parser.GamryParser(), the parser could be instantiated with gamry_parser.ChronoAmperometry()
  • notebook_cyclicvoltammetry.ipynb: Example loading data from a CV (cyclic voltammetry) experiment output. Uses the gamry_parser.CyclicVoltammetry() subclass.
  • notebook_cyclicvoltammetry_peakdetect.ipynb: Another example that demonstrates loading CV data and detecting peaks in the data using scipy.signal.find_peaks()
  • notebook_potentiostatic_eis.ipynb: Example loading data from an EIS (electrochemical impedance spectroscopy) experiment. Uses the gamry_parser.Impedance() subclass.

Additional Examples

Similar procedure should be followed for using the gamry_parser.CyclicVoltammetry(), gamry_parser.Impedance(), gamry_parser.OpenCircuitPotential(), and gamry_parser.VFP600() parser subclasses. Take a look at usage.py and in tests/ for some additional usage examples.

Development

Project Tree

  .
  ├── gamry_parser              # source files
  │   ├── ...          
  │   ├── chronoa.py            # ChronoAmperometry() experiment parser
  │   ├── cv.py                 # CyclicVoltammetry() experiment parser
  │   ├── eispot.py             # Impedance() experiment parser
  |   ├── gamryparser.py        # GamryParser: generic DTA file parser
  │   ├── ocp.py                # OpenCircuitPotential() experiment parser
  |   └── vfp600.py             # VFP600() parses experiment data generated by the Gamry VFP600 LabView Frontend. 
  ├── tests                     # unit tests and test data
  |   └── ...
  ├── setup.py                  # setuptools configuration
  └── ...                

Roadmap

Documentation! Loading of data is straightforward, and hopefully the examples provided in this README provide enough context for any of the subclasses to be used/extended.

In the future, it would be nice to add support for things like equivalent circuit modeling, though at the moment there are other projects focused specifically on building out models and fitting EIS data (e.g. kbknudsen/PyEIS, ECSHackWeek/impedance.py).

Changelog

See CHANGELOG

Tests

Unit Tests

Tests extending unittest.TestCase may be found in /tests/.

Unit tests are triggered as part of every pull request, but users can run tests locally as well:

$ tox

Alternatively, run pytest from your virtualenv (use the -k flag to filter tests)

$ pytest
$ pytest -v -k "test_getters"

Code Guidelines

Lint

  • GitHub flow for proposing changes (i.e. create a feature branch and submit a PR against the master branch).
  • Coding style: Pycodestyle formatting (PEP8). Linting via black is run on each push to github.
  • Tests: maintain > 90% line coverage, per file

Versioning

SemVer for versioning.

  1. Matching major version numbers are guaranteed to work together.
  2. Any change to the public API (breaking change) will increase a major version.

Publishing

Publish

The package relies on Github Actions to automatically build and upload artifacts to pypi upon published release.

Manual publishing (deprecated)

Use setuptools to build, twine to publish to pypi.

$ rm -rf dist
$ python setup.py build
$ python setup.py sdist bdist_wheel
$ twine upload dist/*

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gamry_parser-0.4.6.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

gamry_parser-0.4.6-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file gamry_parser-0.4.6.tar.gz.

File metadata

  • Download URL: gamry_parser-0.4.6.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for gamry_parser-0.4.6.tar.gz
Algorithm Hash digest
SHA256 3653104535e052771eebd648e8cb4439ac00621fea3b9e9c45b4777da281d461
MD5 fde35ccb4bb00d03669a0bfdc767152e
BLAKE2b-256 9be11de9ef76b4505b73f23432094f98758cae60e0de653a8b6ae482f7a67808

See more details on using hashes here.

File details

Details for the file gamry_parser-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: gamry_parser-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for gamry_parser-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ed69045e9470c8af26b91985c091386eb9817e0410766a958efadedb11e2db80
MD5 03083278e18663553232265c2aff34b4
BLAKE2b-256 104226f58d8898fcc9ad2236f0c93999095d264a563b9aaa0014828ac3c95e46

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page