diff --git a/conda_requirements.txt b/conda_requirements.txt new file mode 100644 index 0000000..fd90733 --- /dev/null +++ b/conda_requirements.txt @@ -0,0 +1,8 @@ +numpy>=1.0 +scipy>=1.0 +matplotlib>=2.0 # 2.0 introduces better colormaps which are used by default +h5py>=2.1 +python-dateutil +pytest +sphinx + diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 69a57d9..cd69b26 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -17,22 +17,22 @@ The major dependency for CDTools is pytorch, and because the details of the inst .. _`the pytorch site`: https://pytorch.org/get-started/locally/ -If you manage your environment with conda, the remaining dependencies can be installe by running the following command in the top level directory of the package: +If you manage your environment with conda, the remaining dependencies can be installed by running the following command in the top level directory of the package: .. code:: bash - $ conda install --file conda_requirements.txt -c conda-forge + $ conda install --file conda_requirements.txt -This will install all dependencies, including optional dependencies for the tests and docs. For convenience, the full set of dependencies are noted below: +This will install all dependencies which are available from the main repos, including some optional dependencies for the tests and docs. Following this, any final remining dependencies can be installed from conda-forge or pip. For convenience, the full set of dependencies are noted below: CDTools depends on the following packages: - * `numpy `_ - * `scipy `_ - * `matplotlib `_ - * `pytorch `_ + * `numpy `_ >= 1.0 + * `scipy `_ >= 1.0 + * `matplotlib `_ >= 2.0 + * `pytorch `_ >= 1.9.0 * `python-dateutil `_ - * `h5py `_ + * `h5py `_ >= 2.1 And has optional dependencies on diff --git a/setup.py b/setup.py index 1785c45..2e29fae 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ setuptools.setup( 'docs': ["sphinx","sphinx-argparse","sphinx_rtd_theme"] }, package_dir={"": "src"}, - packages=setuptools.find_packages(), + packages=setuptools.find_packages("src"), classifiers=[ "Programming Language :: Python :: 3", "Operating System :: OS Independent", diff --git a/src/cdtools/models/fancy_ptycho.py b/src/cdtools/models/fancy_ptycho.py index 93edd02..a534014 100644 --- a/src/cdtools/models/fancy_ptycho.py +++ b/src/cdtools/models/fancy_ptycho.py @@ -146,6 +146,7 @@ class FancyPtycho(CDIModel): randomize_ang=0, padding=0, n_modes=1, + n_obj_modes=1, dm_rank=None, translation_scale=1, saturation=None, @@ -240,6 +241,8 @@ class FancyPtycho(CDIModel): probe = t.stack([probe, ] + probe_stack) obj = t.exp(1j * randomize_ang * (t.rand(obj_size)-0.5)) + if n_obj_modes != 1: + obj = t.stack([obj,] + [0.05*t.ones_like(obj),]*(n_obj_modes-1)) det_geo = dataset.detector_geometry diff --git a/src/cdtools/tools/interactions/interactions.py b/src/cdtools/tools/interactions/interactions.py index a092bf3..f290e9c 100644 --- a/src/cdtools/tools/interactions/interactions.py +++ b/src/cdtools/tools/interactions/interactions.py @@ -439,7 +439,7 @@ def ptycho_2D_sinc(probe, obj, translations, shift_probe=True, padding=10, multi subpixel_translations = translations - integer_translations integer_translations = integer_translations.to(dtype=t.int32) if not polarized: - selections = t.stack([obj[tr[0]:tr[0]+probe.shape[-2], + selections = t.stack([obj[..., tr[0]:tr[0]+probe.shape[-2], tr[1]:tr[1]+probe.shape[-1]] for tr in integer_translations]) else: @@ -474,9 +474,12 @@ def ptycho_2D_sinc(probe, obj, translations, shift_probe=True, padding=10, multi shifted_probe = t.fft.ifft2(t.fft.ifftshift(shifted_fft_probe, dim=(-1,-2))) if not polarized: - if multiple_modes: # Multi-mode probe + # TODO This is a kludge, I will fix this. I need to handle + # multiple incoherently mixing polarized objects + if multiple_modes and len(selections.shape) == 3: # Multi-mode probe output = shifted_probe * selections[...,None,:,:] else: + # This will only work if the output = shifted_probe * selections # selections: Nx2x2xMxL # probe: Nx(P)x2x1xMxL