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
pip install contrasttransferfunction
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)")
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")
contrasttransferfunction
is distributed under the terms of the MIT license.