Skip to main content

Pty-chi is a package of ptychography reconstruction engines

Project description

Pty-chi Logo

Welcome to the repository of Pty-chi, a PyTorch-based ptychography reconstruction library!

https://zenodo.org/badge/858453195.svg

Installation

Standard installation

The easiest way to install the latest release is through PyPI.

First, create a new conda environment with Python 3.11:

conda create -n ptychi python=3.11

Then install Pty-Chi using:

pip install ptychi

Developer installation

Use developer installation when you want to modify the code and test the changes, or when you run into build issues that drive you to install the package from source. We recommend using Conda/pip or uv for environment and package management.

Option 1: Installation with uv

Uv is a modern lightweight package manager for Python featuring fast speed and deterministic builds. When creating a uv virtual environment, the environment directory and all the packages inatalled in it are kept in the current working directory – unlike Conda, where the environments are centrally managed. Therefore, first cd into the root level of your local clone of Pty-Chi, and then create a new uv virtual environment with Python 3.11:

uv venv --python 3.11

Then install Pty-Chi and its dependencies using:

uv sync

You can now run scripts inside the project directory with:

uv run <script.py>

without activating the environment. Alternatively, you can activate the environment with:

source .venv/bin/activate

and then run scripts with:

python <script.py>

This allows you to run scripts located anywhere in your system.

Option 2: Installation with Conda and pip

To install the latest code in the main branch, clone the repository to your workspace, and create a new conda environment using:

conda create -n ptychi python=3.11

Then install the package and its dependencies using:

pip install -r requirements.txt
pip install -e .

How to run test scripts

  1. Contact the developers to be given access to the APS GitLab repository that holds test data. You need to have an account on APS GitLab.

  2. After gaining access, clone the GitLab data repository to your hard drive.

  3. Set PTYCHO_CI_DATA_DIR to the ci_data directory of the data repository: export PTYCHO_CI_DATA_DIR="path_to_data_repo/ci_data".

  4. Run any test scripts in tests with Python.

To use non-Nvidia GPUs

Pty-Chi works on GPUs from different vendors than NVidia. For example, Intel. To run Pty-Chi with Intel GPUs, add these lines right after importing torch and ptychi:

torch.set_default_device("xpu")
ptychi.device.set_torch_accelerator_module(torch.xpu)

Reading documentations

Pty-Chi’s documentation is hosted on Read the Docs.

You can also build the docs and view them in your browser locally. To build the docs, install the dependencies as the first step:

pip install -r docs/requirements.txt

Then:

cd docs
make html

You can then view the docs by opening docs/build/html/index.html in your browser.

Developer’s Guide

Please refer to the developer’s guide in the Wiki page for more information on how to contribute to the project.

🛑 For major changes such as adding a new reconstructor or those involving extensive structural changes to the codebase, please first discuss with the maintainers by creating an issue. Consider creating a new package inheriting Pty-Chi’s reconstructors and data structures for experimental features and algorithms. See Developer’s guide: Extending Pty-Chi with external algorithm packages.

Citation

If Pty-Chi is useful for your research, please consider citing the following paper:

@misc{ptychi_2025_arxiv,
    title = {Pty-Chi: A PyTorch-based modern ptychographic data analysis package},
    author = {Ming Du and Hanna Ruth and Steven Henke and Yi Jiang and Viktor Nikitin and Ashish Tripathi and Junjing Deng and Jeffrey Klug and Peco Myint and Tao Zhou and Nicholas Schwarz and Mathew Cherukara and Alec Sandy and Stefan Vogt},
    year = {2025},
    eprint = {2510.20929},
    archivePrefix = {arXiv},
    primaryClass = {physics.optics},
    url = {https://arxiv.org/abs/2510.20929},
}

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

ptychi-1.3.0.tar.gz (364.8 kB view details)

Uploaded Source

Built Distribution

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

ptychi-1.3.0-py3-none-any.whl (165.4 kB view details)

Uploaded Python 3

File details

Details for the file ptychi-1.3.0.tar.gz.

File metadata

  • Download URL: ptychi-1.3.0.tar.gz
  • Upload date:
  • Size: 364.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ptychi-1.3.0.tar.gz
Algorithm Hash digest
SHA256 fa28e0f915b3e74699da400772458a121d34a45840ec5a16bc09c7e6dc1be8dc
MD5 59949a03cfeb99dd6b4a682c8568e252
BLAKE2b-256 53804855507e2dcff3bf2c6a586776f2fcf19ac0970668a3ebfc3a5abd81812a

See more details on using hashes here.

File details

Details for the file ptychi-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: ptychi-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 165.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ptychi-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8593588ab3db5a3c80def939a19e28a84803b612bf1953dfb37fde8c0c24b60e
MD5 0bd6638616c3061d05fe5a141737a764
BLAKE2b-256 659e2425d5016872b0cafae9167665f1b7f34f4e2d7f4e07610b8a2365f87377

See more details on using hashes here.

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