CDTools
CDTools is a python library for ptychography and CDI reconstructions, using an Automatic Differentiation based approach.
from matplotlib import pyplot as plt
from cdtools.datasets import Ptycho2DDataset
from cdtools.models import FancyPtycho
# Load a data file
dataset = Ptycho2DDataset.from_cxi('ptycho_data.cxi')
# Initialize a model from the data
model = FancyPtycho.from_dataset(dataset)
# Run a reconstruction
for loss in model.Adam_optimize(10, dataset):
print(model.report())
# Save the results
model.save_to_h5('ptycho_results.h5')
# And look at them!
model.inspect() # See the reconstructed object, probe, etc.
model.compare(dataset) # See how the simulated and measured patterns compare
plt.show()
Further documentation is found here.
Installation
CDTools can be installed in several ways depending on your needs. For most users, installation from pypi is recommended. For developers or those who want the latest features, installation from source is available.
Installation from pypi
CDTools can be installed via pip as the cdtools-py package on PyPI:
$ pip install cdtools-py
or using uv:
$ uv pip install cdtools-py
Installation from Source
For development or to access the latest features, CDTools can be installed directly from source:
$ git clone https://github.com/cdtools-developers/cdtools.git
$ cd cdtools
$ pip install -e .
or using uv:
$ git clone https://github.com/cdtools-developers/cdtools.git
$ cd cdtools
$ uv pip install -e .
Installing for Contributors (with tests and docs dependencies)
If you want to run the test suite or build the documentation, install with the extra dependencies:
$ pip install -e ."[tests,docs]"
or with uv:
$ uv pip install -e ."[tests,docs]"
CDTools was developed in the photon scattering lab at MIT, and further development took place within the computational x-ray imaging group at PSI. The code is distributed under an MIT (a.k.a. Expat) license. If you would like to publish any work that uses CDTools, please contact Abe Levitan.
Have a wonderful day!
Metadata
Release files for cdtools-py 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cdtools_py-0.3.2.tar.gz | 146.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cdtools_py-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 303.7 kB
Release files / cdtools_py-0.3.2.tar.gz
| Download URL | cdtools_py-0.3.2.tar.gz |
|---|---|
| Size | 146.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20752cfab3a103e9701d53179b8cb38e53b9a43911e552af6ae0c14d640bd189
|
|
BLAKE2b-256 checksum How to use checksums |
6e9f8a05a98964738392adea04303def62db5235a490f7596c979fad51484dfe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 16, 2026.
Transparency logRelease files / cdtools_py-0.3.2-py3-none-any.whl
| Download URL | cdtools_py-0.3.2-py3-none-any.whl |
|---|---|
| Size | 156.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b4d5899c9e2e4b70abca7dba67f7b4222ec3674bdb1ca6f1399de666714d7d0e
|
|
BLAKE2b-256 checksum How to use checksums |
170502bb928dc333d6cec808cefd2eaff4867010620b2bc42e02a6d9390c8f71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 16, 2026.
Transparency log