Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

probe from numpy array will not be rescaled to photon count #596

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

kahntm
Copy link
Contributor

@kahntm kahntm commented Jan 7, 2025

When a probe was initalized from a numpy array, the _process(ing) applied to that loaded wavefront always scaled it to the number of photons estimated from the loaded diffraction patterns. This happened even when illumiantion.photons was specifically set to None:

p.scans.scan00.illumination.photons = None

A similar bug was fixed when loading probes from previous reconstruction (.ptyr) files by specifically setting p.photons to None again. The same "fix" can be used here as well.

The loaded numpy array now remains unchanged.
But now it is also impossible to scale a loaded np.array if the users specifically wishes for it.

@kahntm
Copy link
Contributor Author

kahntm commented Jan 8, 2025

Currently the options for illumination.photons are to type None (default) or a number of photons. This feature however works only for a probe that is generated from a model and not for probes initialized from a .ptyr file or a numpy array.
image

With those two options (None or a number) it is not possible to clearly extend the scaling functionality to probes initialized from a .ptyr file or a numpy array. I suggest a new accepted string for illumination.photons (something like "maxdiff") to specifically choose to

  • None - do not scale the probe, no matter how it is created
  • any number - scale the probe to that intensity / number of photons, no matter how it is created
  • "maxdiff" - scale the probe to the intensity of the brightest diffraction pattern, no matter how it is created

image

It is fairly simple to implement and would unify the features functionality across all methods of loading / creating the initial probe.

With "maxdiff" as default any old script that did not specifically set illumination.photons to None to achieve the scaling to the brightest diffraction pattern would still work as before. Only scripts that for some reason did set illumination.photons=None would change their behavior, as in the suggested case, no more scaling would be applied.

Any opinions from the ptypy guardians are welcome.

@kahntm
Copy link
Contributor Author

kahntm commented Jan 8, 2025

python 3.8 tests fail when installing dependencies... not in the changed bits of the code

@daurer
Copy link
Contributor

daurer commented Jan 8, 2025

python 3.8 tests fail when installing dependencies... not in the changed bits of the code

Tests should work if you create the PR against dev. Should also male sure your branch is rebased against dev.

ptim0626 and others added 3 commits January 8, 2025 14:57
* Drop Python <= 3.8 support

* Add py 3.13 in CI tests

* Use conda-incubator to set up conda env

* Ensure correct activation throughout the tests

* Migrate to importlib in script2rst

* Migrate to importlib in resources

* Migrate to packaging.version
* Include accelerate base tests by default

* Change expected output in FFT filter tests to reflect support for single precision in Numpy > 2.0

* Adjust tolerance in pycuda fft filter tests
@daurer daurer changed the base branch from master to dev January 13, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants