diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 92c807f..409706d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,28 +1,21 @@ -name: Deploy Docs +name: Docs on: push: branches: - main + pull_request: + branches: + - main workflow_dispatch: permissions: contents: read - pages: write - id-token: write - -concurrency: - group: github-pages - cancel-in-progress: false jobs: - deploy: + build: runs-on: ubuntu-latest - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - steps: - name: Checkout uses: actions/checkout@v4 @@ -33,17 +26,36 @@ jobs: - name: Install documentation dependencies run: uv sync --extra docs - - name: Configure GitHub Pages - uses: actions/configure-pages@v5 - - name: Build documentation run: uv run mkdocs build --strict - name: Upload documentation + if: github.event_name != 'pull_request' uses: actions/upload-pages-artifact@v4 with: path: site + deploy: + needs: build + if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + + permissions: + pages: write + id-token: write + + concurrency: + group: github-pages + cancel-in-progress: false + + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + + steps: + - name: Configure GitHub Pages + uses: actions/configure-pages@v5 + - name: Deploy documentation id: deployment uses: actions/deploy-pages@v4 diff --git a/PtyLab/Engines/__init__.py b/PtyLab/Engines/__init__.py index 17ed5a0..c4c6c0b 100644 --- a/PtyLab/Engines/__init__.py +++ b/PtyLab/Engines/__init__.py @@ -25,13 +25,3 @@ from .OPR import OPR from .qNewton import qNewton from .zPIE import zPIE - - -import warnings - -warnings.warn( - "`pcPIE` is deprecated. Use `mPIE` with " - "`params.positionCorrectionSwitch = True` instead.", - DeprecationWarning, - stacklevel=2, -) \ No newline at end of file diff --git a/PtyLab/Engines/mPIE.py b/PtyLab/Engines/mPIE.py index a2a93c0..b677a32 100644 --- a/PtyLab/Engines/mPIE.py +++ b/PtyLab/Engines/mPIE.py @@ -11,6 +11,7 @@ import logging import sys +import warnings import tqdm @@ -577,6 +578,12 @@ def __init__( params: Params, monitor: Monitor, ): + warnings.warn( + "`pcPIE` is deprecated. Use `mPIE` with " + "`params.positionCorrectionSwitch = True` instead.", + DeprecationWarning, + stacklevel=2, + ) super().__init__( reconstruction, experimentalData, diff --git a/PtyLab/Monitor/TensorboardMonitor.py b/PtyLab/Monitor/TensorboardMonitor.py index af9706f..a011eff 100644 --- a/PtyLab/Monitor/TensorboardMonitor.py +++ b/PtyLab/Monitor/TensorboardMonitor.py @@ -257,7 +257,7 @@ def update_encoder( axes["O"].set_title("Original positions") axes["N"].set_title("Updated positions") - axes["S"].set_title(f"Diff. Mean: {meandiff} $\mu$m") + axes["S"].set_title(rf"Diff. Mean: {meandiff} $\mu$m") # plot the original one everywhere diff --git a/README.md b/README.md index 1ad6064..218dbfd 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ ![Python 3.10+](https://img.shields.io/badge/python-3.10+-green.svg) [![PyPI](https://img.shields.io/pypi/v/ptylab.svg)](https://pypi.org/project/ptylab/) ![Tests](https://github.com/PtyLab/PtyLab.py/actions/workflows/test.yml/badge.svg) +[![Docs](https://github.com/PtyLab/PtyLab.py/actions/workflows/docs.yml/badge.svg)](https://ptylab.github.io/PtyLab.py/) [**Getting Started**](#getting-started) | [**Installation**](#installation) | [**Development**](#development) | [**Documentation**](https://ptylab.github.io/PtyLab.py/) @@ -10,7 +11,7 @@ PtyLab is an inverse modeling toolbox for Conventional (CP) and Fourier (FP) pty ## Key Features - **Classic engines**: ePIE, mPIE, mqNewton, qNewton -- **Advanced corrections**: position correction (pcPIE), defocus correction (zPIE), angle correction (aPIE), orthogonal probe relaxation (OPR) +- **Advanced corrections**: position correction, defocus correction (zPIE), angle correction (aPIE), orthogonal probe relaxation (OPR) - **Multi-modal**: multi-slice, multi-wavelength, mixed-state object and probe - **Multiple propagators**: Fraunhofer, Fresnel, Angular Spectrum (ASP), scaled ASP, polychromatic variants - **GPU acceleration**: same code runs on CPU and GPU diff --git a/docs/advanced/position-correction.md b/docs/advanced/position-correction.md index d6a634e..8234b5f 100644 --- a/docs/advanced/position-correction.md +++ b/docs/advanced/position-correction.md @@ -4,9 +4,9 @@ Scan position errors are common in practice — mechanical stage imperfections, thermal drift, and vibration all introduce deviations between the nominal encoder positions and the true sample positions. Even small position errors (a fraction of a pixel) degrade reconstruction quality. Position-correcting ptychography estimates and corrects these errors as part of the reconstruction. -## Using `pcPIE` +## Enabling position correction -The `pcPIE` engine extends the standard PIE update with a cross-correlation based position correction step: +Position correction is a cross-correlation based step built into the engines (`mPIE`, `mqNewton`). Turn it on with `params.positionCorrectionSwitch`: ```python import PtyLab @@ -14,7 +14,7 @@ from PtyLab import Engines data, recon, params, monitor, engine = PtyLab.easyInitialize( "data.hdf5", - engine=Engines.pcPIE, + engine=Engines.mPIE, operationMode="CPM", ) @@ -35,6 +35,9 @@ recon.saveResults("corrected_result.hdf5") | `params.positionCorrectionSwitch` | `False` | Enable position correction | | `params.positionCorrectionSwitch_radius` | `1` | Search radius (pixels) around each nominal position | +!!! note + `Engines.pcPIE` is deprecated. It is kept as a thin wrapper around `mPIE` for backward compatibility. + !!! tip Start with a small radius (1–2 pixels). Large radii slow down reconstruction and can cause instabilities early in convergence. Run a few iterations without position correction first to let the object and probe stabilize. @@ -76,5 +79,5 @@ recon.positions0 # original pixel positions (before correction) ## Related -- [Engines](../cpm/engines.md) — `pcPIE` and other specialized engines +- [Engines](../cpm/engines.md) — engines that support position correction - [Configuration Reference](../cpm/configuration.md) — full parameter list diff --git a/docs/api/engines.md b/docs/api/engines.md index 659958a..bc68dbe 100644 --- a/docs/api/engines.md +++ b/docs/api/engines.md @@ -42,7 +42,7 @@ show_root_full_path: false inherited_members: false -::: PtyLab.Engines.pcPIE.pcPIE +::: PtyLab.Engines.mPIE.pcPIE options: show_root_heading: true show_root_full_path: false diff --git a/docs/cpm/engines.md b/docs/cpm/engines.md index f7b9671..aed66e1 100644 --- a/docs/cpm/engines.md +++ b/docs/cpm/engines.md @@ -13,7 +13,6 @@ Engines implement the iterative reconstruction algorithms. All engines inherit f | `multiPIE` | Multi-mode PIE | Multiple probe or object modes simultaneously | | `zPIE` | Defocus-correcting PIE | Unknown or uncertain sample-detector distance | | `aPIE` | Angle-correcting PIE | Reflection geometry with uncertain tilt angle | -| `pcPIE` | Position-correcting PIE | Corrects scan position errors during reconstruction | | `e3PIE` | Enhanced ePIE | Multislice (thick sample) reconstruction | | `OPR` | Orthogonal Probe Relaxation | Spatially varying probe (e.g. aberrations, drift) | @@ -45,7 +44,9 @@ engine.betaProbe = 0.25 # probe update step size (0 < beta ≤ 1) These engines use quasi-Newton updates and generally require fewer iterations than PIE-based methods. -### pcPIE (position correction) +### Position correction (mPIE, mqNewton) + +`pcPIE` is deprecated; enable position correction on `mPIE` or `mqNewton` instead: ```python params.positionCorrectionSwitch = True @@ -84,7 +85,7 @@ Is the sample thick (multislice)? No → continue Are scan positions unreliable? - Yes → pcPIE + Yes → mPIE with params.positionCorrectionSwitch = True No → continue Do you want the fastest convergence? diff --git a/docs/index.md b/docs/index.md index e345db7..c4e6031 100644 --- a/docs/index.md +++ b/docs/index.md @@ -10,7 +10,7 @@ For the original publication, see: [PtyLab.m/py/jl: a cross-platform, open-sourc ## Key features - **Classic engines**: ePIE, mPIE, mqNewton, qNewton -- **Advanced corrections**: position correction (pcPIE), defocus correction (zPIE), angle correction (aPIE), orthogonal probe relaxation (OPR) +- **Advanced corrections**: position correction, defocus correction (zPIE), angle correction (aPIE), orthogonal probe relaxation (OPR) - **Multi-modal**: multi-slice, multi-wavelength, mixed-state object and probe - **Multiple propagators**: Fraunhofer, Fresnel, Angular Spectrum (ASP), scaled ASP, polychromatic variants - **GPU acceleration**: same code runs on CPU and GPU diff --git a/mkdocs.yml b/mkdocs.yml index 9970650..3d1d838 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -112,6 +112,8 @@ plugins: show_root_heading: true show_source: true members_order: source + docstring_options: + returns_named_value: false - mkdocs-jupyter: include: ["*.ipynb"] execute: false diff --git a/pyproject.toml b/pyproject.toml index b1a5cc3..1aac642 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ptylab" -version = "0.3.2" +version = "0.3.3" description = "A cross-platform, open-source inverse modeling toolbox for conventional and Fourier ptychography" authors = [ { name = "Lars Loetgering", email = "lars.loetgering@fulbrightmail.org" },