Skip to main content

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!

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cdtools_py-0.3.2.tar.gz (146.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cdtools_py-0.3.2-py3-none-any.whl (156.8 kB view details)

Uploaded Python 3

File details

Details for the file cdtools_py-0.3.2.tar.gz.

File metadata

  • Download URL: cdtools_py-0.3.2.tar.gz
  • Upload date:
  • Size: 146.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cdtools_py-0.3.2.tar.gz
Algorithm Hash digest
SHA256 20752cfab3a103e9701d53179b8cb38e53b9a43911e552af6ae0c14d640bd189
MD5 c5ba28328b06b13b343491cae03d35b4
BLAKE2b-256 6e9f8a05a98964738392adea04303def62db5235a490f7596c979fad51484dfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdtools_py-0.3.2.tar.gz:

Publisher: publish.yml on cdtools-developers/cdtools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cdtools_py-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: cdtools_py-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 156.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for cdtools_py-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b4d5899c9e2e4b70abca7dba67f7b4222ec3674bdb1ca6f1399de666714d7d0e
MD5 975ed6be7fb2ae0fbedbf1a76d70940b
BLAKE2b-256 170502bb928dc333d6cec808cefd2eaff4867010620b2bc42e02a6d9390c8f71

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdtools_py-0.3.2-py3-none-any.whl:

Publisher: publish.yml on cdtools-developers/cdtools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 files

0.3.1

2 files

0.3.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page