Commit Graph
108 Commits
Author SHA1 Message Date
allevitan 91db5b3c64 Update remaining models to new plot registration system 2026-03-20 19:01:22 +01:00
allevitan e7f943e254 Made a few more updates to some example scripts, to show the panel plot mode 2026-03-20 17:35:25 +01:00
allevitanandClaude Sonnet 4.6 f4260837bc Add title option to plot_image and wrappers; misc fixes
- Add title parameter to plot_image, plot_real, plot_imag, plot_amplitude,
  plot_phase, and plot_colorized
- Various fixes to base.py and fancy_ptycho.py

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 17:20:52 +01:00
allevitanandClaude Sonnet 4.6 dd744a00a4 Improve plotting infrastructure and fix various bugs
- Switch panel plots to use subfigures with constrained_layout for better layout management
- Add plot_loss_history method to CDIModel base class
- Fix matplotlib compatibility for older versions (interactive backend detection)
- Make CUDA usage conditional in examples
- Add panel_plot_mode and plot_level params to FancyPtycho constructor
- Default plot_level filtering to 1 instead of 0

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-20 15:33:49 +01:00
levita_a 44fe36d24f Kill a bunch of bugs and make the flow more sensible by hand 2026-03-20 11:09:13 +01:00
allevitan f3581b88db A first prototype from claude to test on Ra 2026-03-20 09:47:38 +01:00
levita_a 1dd116d277 Add the additional factor of R^2 2026-02-11 11:06:29 +01:00
levita_a e52c6e38aa Remove the spurious 'probe_shape' parameter 2026-02-10 11:46:14 +01:00
levita_a 65e4882fdd Merge remote-tracking branch 'origin/master' into near_field_ptycho 2026-01-14 17:09:17 +01:00
yoshikisd 69a94f0fe8 Bragg2DPtycho scattering_mode string values only inspected if scattering_mode is a string 2025-12-18 18:15:19 +00:00
Dayne Yoshiki Sasaki 126bfaa92c Merge pull request #62 from cdtools-developers/fix-divzero-error
Stop Ptycho2DDataset.inspec() from raising a divzero error in many situations
2025-12-08 10:08:13 -08:00
levita_a 8f3ad59c6d Suggested changes: Make surface_normal work with anything castable to an array with np.asarray, change the check for length-3 to cover all cases, and add a check to explicitly fail if the scattering_mode argument is improperly set, instead of silently falling back to default 2025-12-02 15:27:20 +01:00
yoshikisd 7286bad264 Added heirarchy of surface_normal definition in Bragg2DPtycho from_dataset 2025-12-01 22:20:28 +00:00
yoshikisd bac95b7636 Make it easier to change surface normal in Bragg2DPtycho.from_dataset 2025-11-20 21:42:19 +00:00
levita_a c78b528930 Change how the dataset mask is calculated, so that it only raises a divide by zero error if unmasked pixels have an issue. Add an option to ptycho_2d_dataset to plot the mask 2025-11-19 10:46:01 +01:00
levita_a ab7048e375 merge updates to master 2025-11-19 10:29:33 +01:00
levita_a 008fef6244 Add cdtools.__version__ and set it up so that there is a single source of truth for the version number. Still not done with setuptools_scm, but one step at a time) 2025-10-28 16:06:21 +01:00
levita_a e38ebd7372 Fix a high priority bug with the masking system which was introduced in the switch to reconstructors classes 2025-10-24 15:11:46 +02:00
levita_a 86e85e1853 Fix a bug where the x-axis was double flipped 2025-10-19 13:08:16 +02:00
levita_a 3eec9c0cec Add the original positions to the fancy_ptycho position plotting 2025-10-19 12:45:19 +02:00
Abe LevitanandDayne Yoshiki Sasaki 9d633074d8 Apply suggestions from code review
Co-authored-by: Dayne Yoshiki Sasaki <37006268+yoshikisd@users.noreply.github.com>
2025-10-17 18:37:38 -03:00
levita_a 8328b852d3 Update the docs to include the reconstructors class and discuss their use in the examples 2025-10-16 14:43:04 +02:00
levita_a aa684f27eb Change the pattern for Reconstructor so that the optimizer is defined at object creation, and move the dataloader creation logic to the base optimize() function as it was reused in all subclasses 2025-10-13 19:20:42 +02:00
levita_a a089dc3b72 Switch to a simpler pattern for the CDIModel.<algorithm>_optimize functions that preserves the old behavior when the old pattern is used 2025-10-13 14:26:07 +02:00
levita_a 766a7d1adf Move to better supported strategy for avoiding circular imports 2025-10-13 14:20:38 +02:00
yoshikisd 82ce845385 Changed the names of the reconstructors and updated the old optimizer class documentation 2025-08-04 16:51:24 +00:00
yoshikisd 404d03bbd3 Rebased CDIModel to use Reconstructors for reconstructions. 2025-08-01 21:51:52 +00:00
yoshikisd 76bc2fa75b Got rid of world_size attribute 2025-08-01 21:50:35 +00:00
yoshikisd 0785eae552 Created Reconstructors class to replace optimization methods in CDIModel 2025-08-01 21:37:05 +00:00
gnzng d7a1ea82c9 adjusted warn msg based on Daynes suggestion 2025-06-17 15:50:51 -07:00
gnzng b189c3c2af Add warning for 64-bit float conversion in Ptycho2DDataset and added to tests 2025-06-17 11:01:30 -07:00
Dayne Yoshiki Sasaki 31318819d0 Merge branch 'cdtools-developers:master' into bugfix/rpi_compare 2025-06-11 17:03:06 -07:00
yoshikisd 4c784de922 Fixed sim_data shape change in CDIModel.compare for RPI measurements 2025-06-12 00:02:32 +00:00
levita_a 4ecc782c28 Reply to Daynes comment's and slightly loosen a tolerance in one test that has been failing 2025-06-10 14:11:01 +02:00
levita_a b6bc7d95cc Change the behavior of FancyPtycho.center_probes to center the probe in real space even when fourier_probe is set to True 2025-06-10 13:57:03 +02:00
levita_a 2c5587cacf Fix an issue for datasets with colinear translations 2025-06-10 13:57:03 +02:00
levita_a 1dd389d08a Update the initialization for near field to work better with oversampling 2025-05-28 10:09:02 +02:00
levita_a 148b9f9865 Get a basic implementation of near-field ptycho working including initialization and oversampling 2025-05-26 16:58:27 +02:00
levita_a 2c2f2d2d93 Add a way to save and load the quantum efficiency masks, and add test coverage 2025-05-13 16:05:16 +02:00
levita_a c86e505ae5 Make it possible to add a quantum efficiency mask to a dataset, allow fancy_ptycho to load that and use it in the forward model 2025-05-13 14:06:02 +02:00
levita_a ac1499f511 get it running in principle, but it is not good 2025-05-12 16:55:26 +02:00
levita_a 2fd917350d response to Dayne's review 2025-03-20 10:46:24 +01:00
levita_a 5b6fd79b28 Add tests for nested_dict_to_numpy and nested_dict_to_torch 2025-03-18 13:13:47 +01:00
levita_a a30930b082 Fix bug with loading h5 files including strings, and add test coverage for h5_to_nested_dict and nested_dict_to_h5 2025-03-18 11:54:06 +01:00
gnzng f8bebd0436 typo, factor -> factors 2025-03-04 14:21:51 -08:00
gnzng efadaf807e Rename probe_size parameter to probe_shape in FancyPtycho and MultislicePtycho classes to match the gaussian_probe function 2025-03-04 14:20:09 -08:00
a7904491be Added a function to allow for deletion of translation positions with logical indexing (#16)
* Added a function to allow for deletion of translation positions via logical indexing
In ptycho_2d_dataset.py
- Created remove_translations_mask. This handles logical-indexing-based deletion of translation points
- Refactored crop_translations to be dependent on remove_translations_mask

* Add validation and tests for remove_translations_mask method in Ptycho2DDataset

* Switch mask to mask_remove

---------

Co-authored-by: gnzng <damian@guenzing.de>
Co-authored-by: Clemens Schmid <clemisch@tuta.io>
2025-02-26 06:52:04 +01:00
Dayne Sasaki 0020306dd5 Merge pull request #12 from cdtools-developers/bragg_oversampling
Fixing oversampling in Bragg2DPtycho
2025-01-06 09:24:20 -08:00
yoshikisd 1da20c8427 improvements: Implemented requested changes for PR13
For crop_translations in ptycho_2d_dataset.py
- crop_2d_translations is now crop_translations
- roi is now order-insensitive within the first and last pairs of elements.
- the definition of top, bottom, left, and right, are now consistent with figures generated by matplotlib.pyplot.imshow
- self.intensities is now updated

For tests_datasets.py
- the order-insensitivity of roi in crop_translation is tested, and tests for specific ordering of values in roi are removed.
2024-12-30 01:36:54 +00:00
levita_a c03d4284f2 Fix the issue with obj view padding in Bragg2DPtycho not working with a probe fourier crop 2024-12-23 10:10:40 +01:00