CBF is a simple Python package (Python 3.x) for reading and writing cbf (Crystallographic Binary Format) files.
To install the package via pip use:
# install the latest tagged version (in this case 1.3.0)
pip install git+https://github.com/paulscherrerinstitute/cbf.git@1.3.0
# install the latest development version
pip install git+https://github.com/paulscherrerinstitute/cbf.git- Read CBF file
import cbf
content = cbf.read('example.cbf')
numpy_array_with_data = content.data
header_metadata = content.metadata
# Plot image with matplot lib
from matplotlib import pyplot as plt
plt.imshow(numpy_array_with_data, cmap='gray', vmax=50)
plt.show()- Write CBF file
import cbf
cbf.write('example.cbf', numpy_array)