Skip to main content

Fit exponential and harmonic functions using Chebyshev polynomials

Project description

Chebyfit is a Python library that implements the algorithms described in:

Analytic solutions to modelling exponential and harmonic functions using Chebyshev polynomials: fitting frequency-domain lifetime images with photobleaching. G C Malachowski, R M Clegg, and G I Redford. J Microsc. 2007; 228(3): 282-295. doi: 10.1111/j.1365-2818.2007.01846.x

Author:

Christoph Gohlke

License:

BSD 3-Clause

Version:

2023.4.22

Quickstart

Install the chebyfit package and all dependencies from the Python Package Index:

python -m pip install -U chebyfit

See Examples for using the programming interface.

Source code and support are available on GitHub.

Requirements

This revision was tested with the following requirements and dependencies (other versions may work):

Revisions

2023.4.22

  • Drop support for Python 3.8 and numpy < 1.21 (NEP29).

2022.9.29

  • Add type hints.

  • Convert to Google style docstrings.

2022.8.26

  • Update metadata.

  • Remove support for Python 3.7 (NEP 29).

2021.6.6

  • Fix compile error on Python 3.10.

  • Remove support for Python 3.6 (NEP 29).

2020.1.1

  • Remove support for Python 2.7 and 3.5.

2019.10.14

  • Support Python 3.8.

  • Fix numpy 1type FutureWarning.

2019.4.22

  • Fix setup requirements.

2019.1.28

  • Move modules into chebyfit package.

  • Add Python wrapper for _chebyfit C extension module.

  • Fix static analysis issues in _chebyfit.c.

Examples

Fit two-exponential decay function:

>>> deltat = 0.5
>>> t = numpy.arange(0, 128, deltat)
>>> data = 1.1 + 2.2 * numpy.exp(-t / 33.3) + 4.4 * numpy.exp(-t / 55.5)
>>> params, fitted = fit_exponentials(data, numexps=2, deltat=deltat)
>>> numpy.allclose(data, fitted)
True
>>> params['offset']
array([1.1])
>>> params['amplitude']
array([[4.4, 2.2]])
>>> params['rate']
array([[55.5, 33.3]])

Fit harmonic function with exponential decay:

>>> tt = t * (2 * math.pi / (t[-1] + deltat))
>>> data = 1.1 + numpy.exp(-t / 22.2) * (3.3 - 4.4 * numpy.sin(tt)
...                                          + 5.5 * numpy.cos(tt))
>>> params, fitted = fit_harmonic_decay(data, deltat=0.5)
>>> numpy.allclose(data, fitted)
True
>>> params['offset']
array([1.1])
>>> params['rate']
array([22.2])
>>> params['amplitude']
array([[3.3, 4.4, 5.5]])

Fit experimental time-domain image:

>>> data = numpy.fromfile('test.b&h', dtype='float32').reshape((256, 256, 256))
>>> data = data[64:64+64]
>>> params, fitted = fit_exponentials(data, numexps=1, numcoef=16, axis=0)
>>> numpy.allclose(data.sum(axis=0), fitted.sum(axis=0))
True

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

chebyfit-2023.4.22.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distributions

chebyfit-2023.4.22-pp39-pypy39_pp73-win_amd64.whl (28.8 kB view hashes)

Uploaded PyPy Windows x86-64

chebyfit-2023.4.22-cp311-cp311-win_arm64.whl (22.5 kB view hashes)

Uploaded CPython 3.11 Windows ARM64

chebyfit-2023.4.22-cp311-cp311-win_amd64.whl (27.9 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

chebyfit-2023.4.22-cp311-cp311-win32.whl (24.5 kB view hashes)

Uploaded CPython 3.11 Windows x86

chebyfit-2023.4.22-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (68.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chebyfit-2023.4.22-cp311-cp311-macosx_11_0_arm64.whl (28.7 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

chebyfit-2023.4.22-cp311-cp311-macosx_10_9_x86_64.whl (32.2 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

chebyfit-2023.4.22-cp310-cp310-win_amd64.whl (27.9 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

chebyfit-2023.4.22-cp310-cp310-win32.whl (24.5 kB view hashes)

Uploaded CPython 3.10 Windows x86

chebyfit-2023.4.22-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (67.6 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chebyfit-2023.4.22-cp310-cp310-macosx_11_0_arm64.whl (28.7 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

chebyfit-2023.4.22-cp310-cp310-macosx_10_9_x86_64.whl (32.2 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

chebyfit-2023.4.22-cp39-cp39-win_amd64.whl (27.9 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

chebyfit-2023.4.22-cp39-cp39-win32.whl (24.5 kB view hashes)

Uploaded CPython 3.9 Windows x86

chebyfit-2023.4.22-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (67.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.5+ x86-64

chebyfit-2023.4.22-cp39-cp39-macosx_11_0_arm64.whl (28.7 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

chebyfit-2023.4.22-cp39-cp39-macosx_10_9_x86_64.whl (32.2 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

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