Metadata-Version: 2.1
Name: contrasttransferfunction
Version: 0.0.1
Summary: Tools to model and estimate the contrast transfer function for transmission electron microscopy data
Project-URL: Documentation, https://github.com/unknown/contrasttransferfunction#readme
Project-URL: Issues, https://github.com/unknown/contrasttransferfunction/issues
Project-URL: Source, https://github.com/unknown/contrasttransferfunction
Author-email: Johannes Elferich <jojotux123@hotmail.com>
License-Expression: MIT
License-File: LICENSE.txt
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Python: >=3.7
Requires-Dist: numpy
Requires-Dist: pydantic
Requires-Dist: scipy
Description-Content-Type: text/markdown

# contrasttransferfunction

[![PyPI - Version](https://img.shields.io/pypi/v/contrasttransferfunction.svg)](https://pypi.org/project/contrasttransferfunction)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/contrasttransferfunction.svg)](https://pypi.org/project/contrasttransferfunction)

-----

`contrasttransferfunction` is a python library to model and estimate the contrast transfer function for transmission electron microscopy data. The library is designed to:

- Follow CTFFIND conventions and algorithms as much as possible
- Be highly compatible by using pure python, no compiled code
- Stay fast by using numpy vectorization

## Installation

```console
pip install contrasttransferfunction
```

## Examples

### Plot 1D powerspectrum

```python
from contrasttransferfunction import ContrastTransferFunction
import matplotlib.pyplot as plt

myctf = ContrastTransferFunction(
    defocus1_angstroms = 8000,
    pixel_size_angstroms = 2.3
)

plt.plot(myctf.frequency_angstroms_1d, myctf.powerspectrum_1d)
plt.gca().xaxis.set_major_formatter(lambda x, pos: f"{1/x:.1f}Å")
plt.xlabel("Spatial resultion (A)")
```
![](assets/1dplot.png)

### Plot 2D powerspectrum

```python
myctf = ContrastTransferFunction(
    defocus1_angstroms = 8000,
    defocus2_angstroms= 6000,
    defocus_angle_degrees=25.3,
    pixel_size_angstroms = 2.3
)
plt.imshow(myctf.powerspectrum_2d,cmap="Greys")
```
![](assets/2dplot.png)

## License

`contrasttransferfunction` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
