Metadata-Version: 2.4
Name: cdtools-py
Version: 0.3.1
Summary: Tools for coherent diffractive imaging and ptychography
Author: Dayne Y. Sasaki, Damian Guenzing, Madelyn Cain, Anastasiia Kutakh
Author-email: Abe Levitan <abraham.levitan@psi.ch>
Maintainer-email: Abe Levitan <abraham.levitan@psi.ch>
License: Copyright (c) 2019-2023 Massachusetts Institute of Technology
        Author: Abraham Levitan, abraham.levitan@psi.ch
        Additional Contributors:
        Madelyn Cain
        Anastasiia Kutakh
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://github.com/cdtools-developers/cdtools
Project-URL: Documentation, https://cdtools-developers.github.io/cdtools/
Keywords: ptychography,CDI,imaging,torch,differentiable
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: MIT License
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: numpy>=1.0
Requires-Dist: scipy>=1.0
Requires-Dist: matplotlib>=2.0
Requires-Dist: torch>=2.3.0
Requires-Dist: h5py>=2.1
Requires-Dist: python-dateutil
Provides-Extra: tests
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pooch; extra == "tests"
Provides-Extra: docs
Requires-Dist: sphinx>=4.3.0; extra == "docs"
Requires-Dist: sphinx-argparse; extra == "docs"
Requires-Dist: sphinx_rtd_theme>=0.5.1; extra == "docs"
Dynamic: license-file

# CDTools

CDTools is a python library for ptychography and CDI reconstructions, using an Automatic Differentiation based approach.

```python
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](https://cdtools-developers.github.io/cdtools/).

Instructions for building custom documentation based on a specific version or commit can be found [here](https://github.com/cdtools-developers/cdtools/blob/master/docs/build_custom_docs.md).

# 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](https://pypi.org/project/cdtools-py/) package on [PyPI](https://pypi.org/):

```bash
$ pip install cdtools-py
```

or using [uv](https://github.com/astral-sh/uv):

```bash
$ uv pip install cdtools-py
```

## Installation from Source

For development or to access the latest features, CDTools can be installed directly from source:


```bash
$ git clone https://github.com/cdtools-developers/cdtools.git
$ cd cdtools
$ pip install -e .
```


or using [uv](https://github.com/astral-sh/uv):

```bash
$ 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:

```bash
$ pip install -e ."[tests,docs]"
```
or with uv:
```bash
$ uv pip install -e ."[tests,docs]"
```

CDTools was developed in the [photon scattering lab](https://scattering.mit.edu/) at MIT, and further development took place within the [computational x-ray imaging group](https://www.psi.ch/en/cxi) 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](mailto:abraham.levitan@psi.ch).

Have a wonderful day!
