Skip to main content

Tools for coherent diffractive imaging and ptychography

Project description

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', dataset)

# And look at them!
model.inspect(dataset) # See the reconstructed object, probe, etc.
model.compare(dataset) # See how the simulated and measured patterns compare
plt.show()

Further documentation is found here.

Instructions for building custom documentation based on a specific version or commit can be 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!

Project details


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.1.tar.gz (130.8 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.1-py3-none-any.whl (143.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cdtools_py-0.3.1.tar.gz
  • Upload date:
  • Size: 130.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cdtools_py-0.3.1.tar.gz
Algorithm Hash digest
SHA256 672de1d367167fe3a84a200a7a39173d3d155bd610a72676d0add5c8490662b7
MD5 ca4d3f0eeb2368d10c27ca77955d98e1
BLAKE2b-256 8e6cd064f14a8d0cfa9f918b0d6553e4403333b8971a82aca12f6ad14e7ad32e

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdtools_py-0.3.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: cdtools_py-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 143.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cdtools_py-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05e8b5eead5e190d4078ec525e28f9e2d6ba6a7c27fc988af4857840e27532a9
MD5 e0f16a46cdf74424f06f2052c5293dcd
BLAKE2b-256 d41748f6a3f62d9cb8e478ac4e3ddbb31c2fcc5c2eb575fe32ea833575d2ba7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for cdtools_py-0.3.1-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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page