pyeasyspin
An unofficial Python port of EasySpin, the MATLAB toolbox for simulating
and analysing electron paramagnetic resonance (EPR) spectra. It follows EasySpin 6.0.12 function by
function: the same function names, the same Sys/Exp/Opt fields, the same units, and results
that agree with EasySpin to about 1e-6 of the peak (exceptions are listed in
docs/DEVIATIONS.md).
pyeasyspin is not affiliated with or endorsed by the EasySpin authors. If you use it in published work, please cite EasySpin:
S. Stoll, A. Schweiger, "EasySpin, a comprehensive software package for spectral simulation and analysis in EPR", J. Magn. Reson. 178, 42–55 (2006).
Installation
pip install pyeasyspin
or, for the latest version from GitHub:
pip install git+https://github.com/Sulaimaninator/pyeasyspin
Python 3.11 or later. Dependencies: NumPy, SciPy and Numba; Matplotlib for plotting
(pip install "pyeasyspin[plot]"). The first call of some functions takes a few seconds while
Numba compiles them.
Example
A script reads much like its MATLAB version:
from pyeasyspin import *
import matplotlib.pyplot as plt
# Nitroxide, rigid limit, X band
Sys = Struct()
Sys.g = [2.0088, 2.0061, 2.0027]
Sys.Nucs = '14N'
Sys.A = [16, 16, 86] # MHz
Sys.lwpp = [0, 0.3] # mT
Exp = Struct()
Exp.mwFreq = 9.5 # GHz
Exp.Range = [328, 349] # mT
B, spc = pepper(Sys, Exp) # field axis (mT) and first-derivative spectrum
plt.plot(B, spc)
import pyeasyspin as es (then es.pepper, es.Struct(g=2.0, lwpp=1.0), ...) works as well, and
pepper(Sys, Exp, plot=True) plots the spectrum the way MATLAB's pepper(Sys,Exp) does.
Speed
A single simulation runs at about the speed of EasySpin in MATLAB (median of five calls, Intel Core i7-1255U laptop):
| EasySpin 6.0.12 | pyeasyspin | |
|---|---|---|
Nitroxide powder (pepper) |
0.25 s | 0.13 s |
Cu(II) powder (pepper) |
0.047 s | 0.035 s |
Mn(II), S = 5/2 (pepper) |
0.23 s | 0.26 s |
Three-pulse ESEEM (saffron) |
0.043 s | 0.019 s |
Nitroxide, slow motion (chili) |
0.19 s | 0.58 s |
Work that consists of many independent simulations runs on all CPU cores, with no extra toolbox:
esfitcomputes the model points of each step in parallel (the particles of a swarm iteration, a genetic generation, grid points, finite-difference Jacobians, simplex candidates). The fit follows the same path and gives the same numbers as a serial run.peppersplits large orientation grids across cores.pyeasyspin.parallel_mapruns any batch of simulations, such as a parameter scan.
Fitting a Cu(II) powder spectrum (7 parameters; the same data, starting point and settings), on the same laptop:
| EasySpin 6.0.12 | pyeasyspin, 1 core | pyeasyspin, all cores | |
|---|---|---|---|
| Levenberg–Marquardt | 125 s | 126 s | 38 s |
| Particle swarm, 20 particles | 2186 s | 692 s |
Both fits end at EasySpin's result: the rmsd agrees to six digits, and the fitted parameters agree to 2e-6 (Levenberg–Marquardt) and 4e-11 (swarm, which followed EasySpin's random-number path). The speed-up depends on the number of cores.
pyeasyspin.config.Workers sets the number of worker processes ('auto', the default, uses all
cores; 1 turns parallel evaluation off). The first parallel call starts the workers, which takes
a few seconds; later calls reuse them.
What is included
All of EasySpin's simulation and analysis functions:
- cw EPR:
pepper(solids),garlic(isotropic and fast motion),chili(slow motion),cardamom(trajectory-based); - ENDOR (
salt), pulse EPR (saffron,spidyan), resonance fields and frequencies, energy levels; - fitting (
esfit, without the GUI); - spin operators and Hamiltonians, rotations and orientation grids, line shapes, isotope data,
physical constants, data import (
eprload) and processing.
Not included: EasySpin's interactive GUIs (the esfit window and the isotopes browser), the
deprecated esfit_legacy, and installation and update helpers.
Differences from MATLAB
- Structures are
pyeasyspin.Struct, adictwith attribute access (Sys.gandSys['g']). - Functions with several outputs return a tuple, in MATLAB's order. Where EasySpin's behaviour
depends on the number of requested outputs, the function takes a
nargoutkeyword. - Row and column vectors come back as 1-D NumPy arrays, so they plot and index like ordinary
vectors; matrices keep MATLAB's layout.
pyeasyspin.config.MatlabShapes = Truereturns MATLAB's exact 1 × N and N × 1 shapes instead. - EasySpin plots when a function is called without outputs; here that is
plot=True. - Indices that users see (transitions, sites, ...) stay 1-based, as in EasySpin.
- Random numbers come from NumPy, so most stochastic results (noise, trajectories) agree with EasySpin statistically rather than draw for draw.
- Some genuine errors in EasySpin 6.0.12 are corrected. Each correction is listed in
docs/DEVIATIONS.md. For many of them a module flag (for example
pyeasyspin.fn.chili.EASYSPIN_RESCALE = True) restores EasySpin's original behaviour.
docs/API.md lists every function with its Python signature.
How it was validated
EasySpin 6.0.12's own test suite was run in MATLAB with every function call recorded, and each
recorded call was replayed in Python and compared output by output: 1e-6 of the peak for spectra
and 1e-10 for exact mathematics. The recorded data are too large to distribute. The tests in this
repository check the package on its own, including a comparison with EasySpin reference spectra
for standard systems (tests/reference):
pip install "pyeasyspin[test]"
pytest
License
MIT, as EasySpin. See LICENSE.
Metadata
Release files for pyeasyspin 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyeasyspin-0.1.0.tar.gz | 783.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyeasyspin-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.4 MB
Release files / pyeasyspin-0.1.0.tar.gz
| Download URL | pyeasyspin-0.1.0.tar.gz |
|---|---|
| Size | 783.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e3ca4d86875dba0b49ad1faeb3fa501b72af2a956e469d6e8bce4109260cc15
|
|
BLAKE2b-256 checksum How to use checksums |
f54824b8e281893760657e667ba8d83405c4abd0a925d0f7ab1a5515987a27de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / pyeasyspin-0.1.0-py3-none-any.whl
| Download URL | pyeasyspin-0.1.0-py3-none-any.whl |
|---|---|
| Size | 635.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5454a63897e8c1292a75805414173094903dd80ebf26db77bbfee633db2821cf
|
|
BLAKE2b-256 checksum How to use checksums |
20d9aab2ae24b2d12b80287ad04cbee614b3e491c640f5e496b63c1c162dcad7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for pyeasyspin 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for pyeasyspin-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.