Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
6f72492
merge previous work
stevehenke Oct 27, 2024
2d2aceb
begin updates
stevehenke Oct 27, 2024
ba93c9c
finish updates
stevehenke Oct 28, 2024
8d552c7
more renaming
stevehenke Oct 28, 2024
98ff764
add pty-chi reconstructor library and view controller factory
stevehenke Oct 28, 2024
f515f4e
prototype pty-chi view controllers
stevehenke Oct 30, 2024
a1e2d54
start implementing pty-chi view controllers
stevehenke Oct 31, 2024
81bfdd4
implement pty-chi reconstructor view-controller
stevehenke Oct 31, 2024
598a05b
implement most of pty-chi view-controllers
stevehenke Nov 1, 2024
a991d88
add new options to pty-chi interface
stevehenke Nov 1, 2024
d699b4a
reconstruct in separate thread
stevehenke Nov 2, 2024
0c2ceb8
rename scan to positions in toolbar
stevehenke Nov 4, 2024
2490798
reconstruct in thread; add progress dialog
stevehenke Nov 4, 2024
41bea52
more globus fixes
stevehenke Nov 5, 2024
f1ffd96
pty-chi enumerators
stevehenke Nov 5, 2024
0dab6cc
update pty-chi reconstructors
stevehenke Nov 5, 2024
84b77a3
testing fixes
stevehenke Nov 5, 2024
2824770
more testing fixes
stevehenke Nov 5, 2024
f49b266
remove ptychopack/pie
stevehenke Nov 5, 2024
5447ab2
update pty-chi reconstructor options
stevehenke Nov 6, 2024
510d74c
update pty-chi object options
stevehenke Nov 6, 2024
5cfccce
update pty-chi probe options
stevehenke Nov 6, 2024
75916d3
update pty-chi probe position options
stevehenke Nov 6, 2024
53f0546
expose ePIE and rPIE
stevehenke Nov 6, 2024
7ca6f56
hacks to make things work
stevehenke Nov 6, 2024
ddec3ae
add DM support and other minor fixes
stevehenke Nov 13, 2024
68eb970
remove ptychopack
stevehenke Nov 13, 2024
c9159de
start requested GUI changes
stevehenke Nov 13, 2024
2733a55
update pty-chi interface (almost everything)
stevehenke Nov 15, 2024
5923e2d
change product metadata dof from photon flux -> count
stevehenke Nov 18, 2024
a23f9be
refactor patterns controller
stevehenke Nov 19, 2024
b7cc14a
clean up patterns core
stevehenke Nov 19, 2024
3fe9de0
minimal OPR support
stevehenke Nov 25, 2024
b867cda
pty-chi position options
stevehenke Nov 26, 2024
9a9b121
draft Dockerfile; change multilayer object distance conventions; impr…
stevehenke Dec 2, 2024
2d0380d
fix empty sequence parameter init
stevehenke Dec 2, 2024
fb5ab94
update file readers: CXI, SLAC, ptychoshelves
stevehenke Dec 2, 2024
f88ec09
adapt to pty-chi coordinate conventions
stevehenke Dec 3, 2024
b1a292d
clear visualization when array is not finite
stevehenke Dec 3, 2024
1fb3722
improve ptychoshelves product reader; add cSAXS diffraction reader
stevehenke Dec 6, 2024
9652d16
fix extra probe modes
stevehenke Dec 8, 2024
506236b
nsls-ii data readers
stevehenke Dec 9, 2024
733f213
update packaging to support wheels
stevehenke Dec 10, 2024
d31b942
fix typo
stevehenke Dec 10, 2024
c643306
update pty-chi integration & add tool-tips
stevehenke Dec 11, 2024
36d66a9
add algorithm-specific options to model
stevehenke Dec 12, 2024
41ddb17
misc requested fixes
stevehenke Dec 12, 2024
0f60b9c
docker image works
stevehenke Dec 13, 2024
62ad6e6
updated docker image to include pty-chi and GPU support
stevehenke Dec 13, 2024
3ef9146
rescale model probe power when photon count > 0
stevehenke Dec 18, 2024
4451ee7
add OPR mode weights smoothing options
stevehenke Dec 18, 2024
67f6378
update pty-chi interface
stevehenke Jan 9, 2025
2e60d8a
FEAT: phase unwrapping and multislice object initializer (#105)
mdw771 Jan 17, 2025
9c0617f
merge misc improvements from another branch
stevehenke Jan 23, 2025
c1d1e8f
prototype argo integration
stevehenke Jan 24, 2025
3aefd09
break stuff
stevehenke Jan 27, 2025
950e60e
fix stuff
stevehenke Jan 28, 2025
8664581
fix tests
stevehenke Jan 28, 2025
b898173
update algorithm-specific options in model
stevehenke Jan 28, 2025
4f47504
add autodiff settings
stevehenke Jan 28, 2025
7cc5efd
Merge branch 'pty-chi' into agent
stevehenke Jan 28, 2025
d732d20
ArgoChatModel
stevehenke Jan 29, 2025
b55492a
update base options in view
stevehenke Jan 29, 2025
286053b
custom reconstructor options to view (partial)
stevehenke Jan 29, 2025
e6c06a5
finish algorithm-specific options
stevehenke Jan 30, 2025
ea9eb2e
chat repository
stevehenke Feb 1, 2025
18bb213
Merge branch 'pty-chi' into agent
stevehenke Feb 1, 2025
d0fe2b2
chat bubbles
stevehenke Feb 3, 2025
a0a731c
chat bubble fixes
stevehenke Feb 3, 2025
e76002e
implement chatModel
stevehenke Feb 4, 2025
ab40f83
call langchain chat model
stevehenke Feb 6, 2025
36fce1d
fix for python 3.10
stevehenke Feb 7, 2025
49b84d1
Phase unwrapping fixes (#106)
mdw771 Feb 11, 2025
2033f70
Merge branch 'pty-chi' into agent
stevehenke Feb 11, 2025
4d67a65
add argo embeddings
stevehenke Feb 12, 2025
9425192
create pattern processor; break stuff
stevehenke Feb 13, 2025
aa09194
Patterns refactor (#107)
stevehenke Mar 3, 2025
19e3e1d
update api
stevehenke Mar 3, 2025
b98a49f
add ability to estimate probe photon count from diffraction data
stevehenke Mar 4, 2025
a9a5e53
fix propagation distance option
stevehenke Mar 5, 2025
019c2a5
improve plugin sync with settings
stevehenke Mar 6, 2025
59d39aa
fix patterns file type bug
stevehenke Mar 6, 2025
72ece78
change memory widget; autoselect reconstruction result
stevehenke Mar 6, 2025
0857a41
create stitcher
stevehenke Mar 8, 2025
a6cd098
change default batch size to 100
stevehenke Mar 8, 2025
e5a8023
pep8 ptychodus.api
stevehenke Mar 12, 2025
8798aee
update array stitcher/interpolator
stevehenke Mar 17, 2025
d5e9cf5
update analysis dialogs
stevehenke Mar 17, 2025
9a77da2
add mass attenuation
stevehenke Mar 18, 2025
6205587
add mass attenuation to plugins
stevehenke Mar 19, 2025
be54200
update training outputs
stevehenke Mar 19, 2025
6e4ba12
merge
stevehenke Mar 20, 2025
6e9635a
make import optional
stevehenke Mar 20, 2025
4edbed9
fix bug when loading product from file
stevehenke Mar 21, 2025
2f58bc4
clean up
stevehenke Mar 23, 2025
daa455c
start plugin cleanup
stevehenke Mar 24, 2025
f8d320f
more clean up
stevehenke Mar 24, 2025
fa9c7d2
finish plugin cleanup
stevehenke Mar 25, 2025
012c506
prototype isn reader
stevehenke Mar 25, 2025
f6e562d
fix meshgrid indexing
stevehenke Mar 25, 2025
7307bcf
extract item_factory from product repository
stevehenke Mar 26, 2025
cee28f7
clean up
stevehenke Mar 26, 2025
a2934ea
update file reader plugins
stevehenke Mar 27, 2025
0ff8e12
mass attenuation to view; start fixing mutable items
stevehenke Mar 27, 2025
e22fa8c
diffraction pattern counts meter
stevehenke Mar 28, 2025
77dd016
create product metadata unique string parameter
stevehenke Mar 28, 2025
31377c6
clean up workflow
stevehenke Mar 28, 2025
7fff24c
more clean up
stevehenke Mar 28, 2025
4ac8ef8
attempt loading product file from settings; affine transform clean-up
stevehenke Mar 31, 2025
7eb810e
reformat tike module
stevehenke Apr 1, 2025
86012cb
reformat ptychi module
stevehenke Apr 2, 2025
6117219
PtychoPINN (#104)
stevehenke Apr 4, 2025
1d1ca55
Basic OPR support (#108)
stevehenke Apr 14, 2025
dde172c
cssi file readers
stevehenke Apr 18, 2025
8344ea2
cssi position file to mm
stevehenke Apr 18, 2025
ba2b647
update model to pty-chi 1.0 api
stevehenke Apr 23, 2025
bafcaee
update controller to pty-chi 1.0 api
stevehenke Apr 28, 2025
47a5652
testing fixes
stevehenke Apr 28, 2025
ba55485
descope fixes for next release
stevehenke Apr 29, 2025
411ea0b
update Dockerfile
stevehenke Apr 29, 2025
38fb315
support pty-chi affine dof
stevehenke May 1, 2025
1f50d65
enable/disable update magnitude limit
stevehenke May 2, 2025
c7238a6
update dockerfile
stevehenke May 2, 2025
5f32173
verify pty-chi tooltips
stevehenke May 2, 2025
cba0740
add tomography_angle_deg metadata; testing fixes
stevehenke May 5, 2025
8b7d37c
add product file adapters for positions/probes/objects
stevehenke May 5, 2025
16bb008
enable exporting ptychopinn data without package
stevehenke May 6, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.aider*
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#FROM python:3.12-slim-bullseye
FROM pytorch/pytorch:2.7.0-cuda12.6-cudnn9-runtime

# Set the working directory in the container
WORKDIR /app

# Copy the sources
COPY . /src

# Install & upgrade software
RUN apt-get update && \
apt-get install -y git libqt5gui5 && \
rm -rf /var/lib/apt/lists/* && \
python3 -m pip install --root-user-action=ignore --no-cache-dir --upgrade pip && \
python3 -m pip install --root-user-action=ignore --no-cache-dir /src[globus,gui,ptychi] && \
rm -rf /src

# Run ptychodus when the container launches
#ENV QT_DEBUG_PLUGINS=1
CMD ["python3", "-m", "ptychodus"]
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ Developer Installation
$ conda activate ptychodus
$ pip install -e ./ptychodus

* To install the `tike`_ backend:
* To install the `pty-chi`_ backend:

.. code-block:: shell

$ conda install -n ptychodus -c conda-forge tike
$ pip install ptychi

* To install the `PtychoNN`_ backend:

Expand All @@ -93,6 +93,6 @@ Reporting Bugs
Open a bug at https://github.com/AdvancedPhotonSource/ptychodus/issues.

.. _`ptychodus`: https://github.com/AdvancedPhotonSource/ptychodus
.. _`tike`: https://github.com/tomography/tike
.. _`pty-chi`: https://github.com/AdvancedPhotonSource/pty-chi
.. _`PtychoNN`: https://github.com/mcherukara/PtychoNN
.. _`PvaPy`: https://github.com/epics-base/pvaPy
26 changes: 0 additions & 26 deletions apptainer/ptychodus.def

This file was deleted.

12 changes: 12 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env python

from pathlib import Path
from ptychodus.model import ModelCore

def main() -> int:
settings_file = Path("path/to/settings.ini")

with ModelCore(settings_file) as model:
input_product_api = model.workflow_api.create_product("new_product_name")
output_product_api = input_product_api.reconstruct_local()
output_product_api.save_product("/path/to/file.h5", file_type="HDF5")
36 changes: 36 additions & 0 deletions doc/dist.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Distribution Instructions
=========================

Python Package Index (PyPI)
---------------------------

From the ptychodus directory, create wheel in ./dist/

.. code-block:: shell

$ python -m build .

Upload to PyPI

.. code-block:: shell

$ twine upload dist/*

Docker
------

Build Docker image

.. code-block:: shell

$ podman build -t ptychodus:latest .


Run container

.. code-block:: shell

$ xhost +local:podman
$ podman run -it --rm -e "DISPLAY=$DISPLAY" -v "$HOME/.Xauthority:/root/.Xauthority:ro" --network host \
--gpus all --ipc=host --ulimit memlock=-1 --ulimit stack=67108864 python-ptychodus
$ xhost -local:podman
40 changes: 40 additions & 0 deletions polaris.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
engine:
type: HighThroughputEngine
max_workers_per_node: 1

# Un-comment to give each worker exclusive access to a single GPU
# available_accelerators: 4

strategy:
type: SimpleStrategy
max_idletime: 3600

address:
type: address_by_interface
ifname: bond0

provider:
type: PBSProProvider

launcher:
type: MpiExecLauncher
# Ensures 1 manger per node, work on all 64 cores
bind_cmd: --cpu-bind
overrides: --depth=64 --ppn 1

account: APSDataAnalysis
queue: preemptable
cpus_per_node: 32
select_options: ngpus=4

# e.g., "#PBS -l filesystems=home:grand:eagle\n#PBS -k doe"
scheduler_options: "#PBS -l filesystems=home:grand:eagle"

# Node setup: activate necessary conda environment and such
worker_init: "source ~/miniconda3/etc/profile.d/conda.sh; conda activate ptychodus",

walltime: 01:00:00
nodes_per_block: 1
init_blocks: 0
min_blocks: 0
max_blocks: 2
32 changes: 23 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
requires = ["setuptools>=64", "setuptools_scm[toml]>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "ptychodus"
description = "Ptychodus is a ptychography data analysis application."
readme = "README.rst"
requires-python = ">=3.10"
license = {file = "LICENSE.txt"}
license = {file = "LICENSE"}
dependencies = [
"h5py",
"h5py>=3",
"hdf5plugin",
"matplotlib",
"numpy",
"psutil",
"requests",
"scikit-image",
"scipy",
"tables",
"tifffile",
"watchdog",
]
Expand All @@ -24,10 +27,17 @@ dynamic = ["version"]
ptychodus = "ptychodus.__main__:main"

[project.optional-dependencies]
globus = ["gladier", "gladier-tools"]
globus = ["gladier", "gladier-tools>=0.5.4"]
gui = ["PyQt5"]
ptychonn = ["ptychonn==0.3.*,>=0.3.7"]
tike = ["tike==0.25.*,>=0.25.3"]
ptychi = ["ptychi==1.*"]

[tool.setuptools.package-data]
"ptychodus" = ["py.typed"]

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools_scm]

Expand All @@ -44,6 +54,8 @@ module = [
"hdf5plugin",
"lightning.*",
"parsl.*",
"ptychi.*",
"ptycho.*",
"ptychonn.*",
"pvaccess",
"pvapy.*",
Expand All @@ -61,9 +73,11 @@ target-version = "py310"
[tool.ruff.format]
quote-style = "single"

[tool.setuptools.package-data]
"ptychodus" = ["py.typed"]

[tool.setuptools.packages.find]
where = ["src"]
[tool.ruff.lint]
select = [
"N",
"NPY",
]

[tool.pyright]
pythonVersion = "3.10"
5 changes: 3 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
h5py
build
h5py>=3
hdf5plugin
matplotlib
mypy
numpy
psutil
pyqt
pyqt-stubs
pytables
pytest
python>=3.10
ruff
Expand All @@ -16,4 +18,3 @@ setuptools_scm>=8
tifffile
toml
watchdog
wheel
2 changes: 1 addition & 1 deletion src/ptychodus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
pass

try:
from .ptychodusAdImageProcessor import PtychodusAdImageProcessor
from .ptychodus_stream_processor import PtychodusAdImageProcessor
except ModuleNotFoundError:
pass

Expand Down
66 changes: 35 additions & 31 deletions src/ptychodus/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@

from pathlib import Path
import argparse
import logging
import sys

from ptychodus.model import ModelCore
import ptychodus

logger = logging.getLogger(__name__)

def versionString() -> str:

def version_string() -> str:
return f'{ptychodus.__name__.title()} ({ptychodus.__version__})'


def verifyAllArgumentsParsed(parser: argparse.ArgumentParser, argv: list[str]) -> None:
def verify_all_arguments_parsed(parser: argparse.ArgumentParser, argv: list[str]) -> None:
if argv:
parser.error('unrecognized arguments: %s' % ' '.join(argv))

Expand Down Expand Up @@ -79,61 +82,62 @@ def main() -> int:
'-v',
'--version',
action='version',
version=versionString(),
version=version_string(),
)

parsedArgs, unparsedArgs = parser.parse_known_args()
settingsFile = Path(parsedArgs.settings.name) if parsedArgs.settings else None
parsed_args, unparsed_args = parser.parse_known_args()
settings_file = Path(parsed_args.settings.name) if parsed_args.settings else None

with ModelCore(settingsFile, isDeveloperModeEnabled=parsedArgs.dev) as model:
if parsedArgs.patterns is not None:
patternsFilePath = Path(parsedArgs.patterns.name)
model.workflowAPI.importProcessedPatterns(patternsFilePath)
with ModelCore(settings_file, is_developer_mode_enabled=parsed_args.dev) as model:
if parsed_args.patterns is not None:
patterns_file_path = Path(parsed_args.patterns.name)
model.workflow_api.import_assembled_patterns(patterns_file_path)

if parsedArgs.batch is not None:
verifyAllArgumentsParsed(parser, unparsedArgs)
if parsed_args.batch is not None:
verify_all_arguments_parsed(parser, unparsed_args)

if parsedArgs.input is None or parsedArgs.output is None:
if parsed_args.input is None or parsed_args.output is None:
parser.error('Batch mode requires input and output arguments!')
return -1

action = parsedArgs.batch
inputFilePath = Path(parsedArgs.input.name)
outputFilePath = Path(parsedArgs.output.name)
fluorescenceInputFilePath: Path | None = None
fluorescenceOutputFilePath: Path | None = None
action = parsed_args.batch
input_file_path = Path(parsed_args.input.name)
output_file_path = Path(parsed_args.output.name)
fluorescence_input_file_path: Path | None = None
fluorescence_output_file_path: Path | None = None

if parsedArgs.fluorescence_input is not None:
fluorescenceInputFilePath = Path(parsedArgs.fluorescence_input.name)
if parsed_args.fluorescence_input is not None:
fluorescence_input_file_path = Path(parsed_args.fluorescence_input.name)

if parsedArgs.fluorescence_output is not None:
fluorescenceOutputFilePath = Path(parsedArgs.fluorescence_output.name)
if parsed_args.fluorescence_output is not None:
fluorescence_output_file_path = Path(parsed_args.fluorescence_output.name)

return model.batchModeExecute(
return model.batch_mode_execute(
action,
inputFilePath,
outputFilePath,
fluorescenceInputFilePath=fluorescenceInputFilePath,
fluorescenceOutputFilePath=fluorescenceOutputFilePath,
input_file_path,
output_file_path,
fluorescence_input_file_path=fluorescence_input_file_path,
fluorescence_output_file_path=fluorescence_output_file_path,
)

try:
from PyQt5.QtWidgets import QApplication
except ModuleNotFoundError:
logger.warning('PyQt5 not found.')
return 0

# QApplication expects the first argument to be the program name
app = QApplication(sys.argv[:1] + unparsedArgs)
verifyAllArgumentsParsed(parser, app.arguments()[1:])
app = QApplication(sys.argv[:1] + unparsed_args)
verify_all_arguments_parsed(parser, app.arguments()[1:])

from ptychodus.view import ViewCore

view = ViewCore.createInstance(parsedArgs.dev)
view = ViewCore()

from ptychodus.controller import ControllerCore

controller = ControllerCore(model, view)
controller.showMainWindow(versionString())
controller = ControllerCore(model, view, is_developer_mode_enabled=parsed_args.dev)
controller.show_main_window(version_string())

return app.exec()

Expand Down
6 changes: 0 additions & 6 deletions src/ptychodus/api/constants.py

This file was deleted.

Loading
Loading