# ImpedanceFitter

**URL:** <https://discourse.julialang.org/t/impedancefitter/90103>\
**Category:** General Usage\
**Tags:** pycall, conda, equivalent-circuit, eis\
**Created:** [November 11, 2022, 8:52am UTC](https://discourse.julialang.org/t/impedancefitter/90103 "2022-11-11T08:52:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [November 11, 2022, 8:52am UTC](https://discourse.julialang.org/t/impedancefitter/90103/1 "2022-11-11T08:52:59Z")

</div>

I have the impression that currently only one Julia package exists for the purpose of equivalent-circuit fitting, which is: [`EquivalentCircuits`](https://github.com/MaximeVH/EquivalentCircuits.jl)  
And there some around in the Python world. One of them is [`impedancefitter`](https://pypi.org/project/impedancefitter/).  
What I like is its ability to facilitate the parameter estimation for arbitrary equivalent circuit models.  
Unfortunately, the installation via:

```julia
using Conda; Conda.add("impedancefitter")

```

fails.  
And a search under:

```julia
https://anaconda.org/search?q=impedancefitter

```

fails as well.  
Is there a chance to get this package into operation under `Julia`?

---

<div class="post-metadata">

**Author:** ![ellocco](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ellocco/32/31331_2.png) [@ellocco](https://discourse.julialang.org/u/ellocco)\
**Post date:** [September 14, 2023, 1:42pm UTC](https://discourse.julialang.org/t/impedancefitter/90103/2 "2023-09-14T13:42:07Z")

</div>

I manged to use the package by means of `PyCall` under Linux (Ubuntu 22.04.3),  
unfortunatly I failed to install it via `[PythonCall](https://github.com/JuliaPy/PythonCall.jl/issues/245)`:

# Installation

```julia
if Sys.iswindows()
    dir_conda = raw"C:\Users\user_accout_name\.julia\Conda\3"
else
    dir_conda = "/home/user_accout_name/.julia/conda/3"
end
ENV["CONDA_JL_HOME"] = dir_conda
using Conda; const Conda.ROOTENV = dir_conda
Conda.pip("uninstall", "impedancefitter")
Conda.pip_interop(true)
Conda.pip("install", "impedancefitter")
import Pkg; Pkg.build("PyCall") # this will (re-)build as well "Conda"
exit() # restart julia

```

Note:  
It might be that the configuration of `CONDA_JL_HOME` and `Conda.ROOTENV` can be omitted,  
in my installation `Conda.ROOTENV` had a strange content.  
If you need to configure both variables the folder `dir_conda` is the root folder of conda  
which is part of your Julia installation.  
The executables `python` and `python3` should be located in the sub-folder “bin”  
of that folder.

# Sample Script:

And here a small sample script to plot the scheme of an equivalent circuit diagram:

```julia
using PyCall
impfit = PyCall.pyimport("impedancefitter")
# --- circuit_model_preset = "R1-[C2,R3-[C4,R5]]" ("EquivalentCircuits.jl"-notation)
model = "R_f1 + parallel(C_f2 + parallel(C_f4, R_f5), R_f3)"

# --- draw / plot equivalent circuit diagram via impedancefitter.py
impfit.draw_scheme(model)

```
