Skip to main content

bayes_drt2

This maintained fork is published as the eisyfit-bayes-drt2 distribution for use by EIS Fitting. The Python import name remains bayes_drt2.

Changes in this maintained fork

The only functional source-code change from the upstream project is replacing NumPy's removed trapz function with trapezoid, which is required for NumPy 2.x. The other fork changes only add distribution metadata, preserve the Stan model files in built wheels, and provide PyPI release automation.

bayes_drt2 is a re-implementation of bayes_drt using the cmdstan interface to Stan instead of pystan. This addresses some issues with installation and the removal of optimization functionality in current versions of pystan. The functionality and structure of bayes_drt2 is virtually identical to that of bayes_drt. If you are using bayes_drt without issue, there is no reason to switch to bayes_drt2. See the tutorials for bayes_drt for tutorials on how to use this package (the API is the same).

bayes_drt2 is a Python package for inverting electrochemical impedance spectroscopy (EIS) data to obtain the distribution of relaxation times (DRT) and/or distribution of diffusion times (DDT).

bayes_drt2 implements a hierarchical Bayesian model to provide well-calibrated estimates of the DRT or DDT without ad-hoc tuning. The package offers two methods for solving the model:

  • Hamiltonian Monte Carlo (HMC) sampling to estimate the posterior distribution, providing both a point estimate of the distribution and a credible interval
  • L-BFGS optimization to maximize the posterior probability, providing a maximum a posteriori (MAP) point estimate of the distribution

It is also possible to perform multi-distribution inversions, e.g. to simultaneously fit both a DRT and a DDT, with these methods. This is an experimental feature and requires some manual tuning. See the tutorials for an example.

The package also provides ordinary and hyperparametric ridge regression methods, which may be useful for comparison or for obtaining initial estimates of the distribution. The hyperparametric ridge regression method is an implementation of the method developed by Ciucci and Chen (https://doi.org/10.1016/j.electacta.2015.03.123) and expanded by Effat and Ciucci (https://doi.org/10.1016/j.electacta.2017.07.050).

Electrochimica Acta article

The methods implemented in bayes_drt2 are the subject of an article in Electrochimica Acta (https://doi.org/10.1016/j.electacta.2020.137493). The theory behind the model is described in detail in the journal article.

Installation

See the installation.txt file for installation instructions.

Dependencies

bayes_drt2 requires:

  • numpy
  • scipy
  • matplotlib
  • pandas
  • cvxopt
  • cmdstan

Issues?

If you run into any issues using the package, please feel free to raise an issue, and I will do my best to help you solve it. Additionally, if you would like to apply the method for more complex analyses, please reach out - I would be happy to help get an appropriate model set up for your use case.

Citing bayes_drt2

If you use bayes_drt2 for published work, please consider citing the following paper:

  • Huang, J., Papac, M., and O'Hayre, R. (2020). Towards robust autonomous impedance spectroscopy analysis: a calibrated hierarchical Bayesian approach for electrochemical impedance spectroscopy (EIS) inversion. Electrochimica Acta, 367, 137493. https://doi.org/10.1016/j.electacta.2020.137493

Additionally, if you use the ridge_fit method with hyper_lambda=True or hyper_w=True, please cite the corresponding work below:

  • hyper_lambda=True: Ciucci, F., & Chen, C. (2015). Analysis of electrochemical impedance spectroscopy data using the distribution of relaxation times: A Bayesian and hierarchical Bayesian approach. Electrochimica Acta, 167, 439–454. https://doi.org/10.1016/j.electacta.2015.03.123
  • hyper_w=True: Effat, M. B., & Ciucci, F. (2017). Bayesian and Hierarchical Bayesian Based Regularization for Deconvolving the Distribution of Relaxation Times from Electrochemical Impedance Spectroscopy Data. Electrochimica Acta, 247, 1117–1129. https://doi.org/10.1016/J.ELECTACTA.2017.07.050

Download files

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

Source Distribution

eisyfit_bayes_drt2-0.2.tar.gz (87.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eisyfit_bayes_drt2-0.2-py3-none-any.whl (103.3 kB view details)

Uploaded Python 3

File details

Details for the file eisyfit_bayes_drt2-0.2.tar.gz.

File metadata

  • Download URL: eisyfit_bayes_drt2-0.2.tar.gz
  • Upload date:
  • Size: 87.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.14.7

File hashes

Hashes for eisyfit_bayes_drt2-0.2.tar.gz
Algorithm Hash digest
SHA256 7bde02c79abc93ee525bdd4b812b19e960596670abb082c03a5647f1699a3d74
MD5 e33756eb388c9e93725a347f0421413f
BLAKE2b-256 31512e824989440ab2d82de0483ee0727dd88a4006d463758f3845be44fd71a4

See more details on using hashes here.

File details

Details for the file eisyfit_bayes_drt2-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for eisyfit_bayes_drt2-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 667c873c19554b3cf23106f59a8dc316af9d14d34470f5d121e94c45990d2c76
MD5 600ab3a06c71cf32376795bfb46f89c6
BLAKE2b-256 4cce9d29b329bb83db9a6422be06758f58f69656c4506d41ae78db02b9bff6b0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page