diff --git a/.gitignore b/.gitignore index dd934a4..4f7f04f 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ Thumbs.db # Log files *.log +!runAllTests*.log logs/ !tests/runAllTests.log diff --git a/src/pyslice/multislice/calculators.py b/src/pyslice/multislice/calculators.py index 47dcec9..dc3952a 100644 --- a/src/pyslice/multislice/calculators.py +++ b/src/pyslice/multislice/calculators.py @@ -149,13 +149,6 @@ def setup( self.cache_levels = cache_levels self.max_kx = max_kx self.max_ky = max_ky - - # Generate cache key and setup output directory - cache_key = self._generate_cache_key(trajectory, aperture, voltage_eV, - slice_thickness, sampling, probe_positions) - #print(cache_key) - self.output_dir = Path("psi_data/" + ("torch" if TORCH_AVAILABLE else "numpy") + "_"+cache_key) - self.output_dir.mkdir(parents=True, exist_ok=True) # Set up spatial grids xs,ys,zs,lx,ly,lz=gridFromTrajectory(trajectory,sampling=sampling,slice_thickness=slice_thickness) @@ -187,6 +180,14 @@ def setup( self.probe_positions = [(lx/2, ly/2)] # Center probe self.probe_xs = [lx/2] ; self.probe_ys = [ly/2] + # Generate cache key and setup output directory + cache_key = self._generate_cache_key(trajectory, aperture, voltage_eV, + slice_thickness, sampling, self.probe_positions) + #print(cache_key) + self.output_dir = Path("psi_data/" + ("torch" if TORCH_AVAILABLE else "numpy") + "_"+cache_key) + self.output_dir.mkdir(parents=True, exist_ok=True) + + # Create probe on the correct device from the start self.base_probe = Probe(xs, ys, self.aperture, self.voltage_eV, device=self.device) diff --git a/src/pyslice/multislice/multislice.py b/src/pyslice/multislice/multislice.py index 8409d1a..5ac6337 100644 --- a/src/pyslice/multislice/multislice.py +++ b/src/pyslice/multislice/multislice.py @@ -276,7 +276,7 @@ def aberrate(self,aberrations): def aberrationFunction(kxs,kys,wavelength,aberrations): # aberrations should be a dict of Cnm following https://abtem.readthedocs.io/en/latest/user_guide/walkthrough/contrast_transfer_function.html dPhi = xp.zeros((len(kxs),len(kys))) ks = xp.sqrt( kxs[:,None]**2 + kys[None,:]**2 ) - theta = xp.atan2( kys[None,:] , kxs[:,None] ) + theta = xp.arctan2( kys[None,:] , kxs[:,None] ) for k in aberrations.keys(): n,m = int(k[1]),int(k[2]) # C03 --> 0,3 C = aberrations[k] ; phi0 = 0 diff --git a/src/pyslice/postprocessing/wf_data.py b/src/pyslice/postprocessing/wf_data.py index 33ed0ef..e6392ab 100644 --- a/src/pyslice/postprocessing/wf_data.py +++ b/src/pyslice/postprocessing/wf_data.py @@ -6,7 +6,7 @@ from ..multislice.multislice import Probe,aberrationFunction from ..data import Signal, Dimensions, Dimension, GeneralMetadata from pathlib import Path -from ..backend import mean +from ..backend import mean,zeros try: import torch ; xp = torch @@ -406,7 +406,7 @@ def propagate_free_space(self,dz): # UNITS OF ANGSTROM def applyMask(self, radius, realOrReciprocal="reciprocal"): if realOrReciprocal == "reciprocal": radii = xp.sqrt( self._kxs[:,None]**2 + self._kys[None,:]**2 ) - mask = xp.zeros(radii.shape, device=self._array.device if TORCH_AVAILABLE else None) + mask = zeros(radii.shape, device=self._array.device if TORCH_AVAILABLE else None) mask[radii - exitwaves = calculator.run() - ^^^^^^^^^^^^^^^^ - File "/media/qwe/Alexandria/ORNL/Various Code/multislice/PySlice/TWP20251230b/tests/../src/pyslice/multislice/calculators.py", line 244, in run - frame_idx_result, frame_data, was_cached = _process_frame_worker_torch(args) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "/media/qwe/Alexandria/ORNL/Various Code/multislice/PySlice/TWP20251230b/tests/../src/pyslice/multislice/calculators.py", line 372, in _process_frame_worker_torch - exit_waves_batch = Propagate(batched_probes, potential, worker_device, progress=(frame_idx==-1), onthefly=True, store_all_slices = ("slices" in cache_levels) ) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "/media/qwe/Alexandria/ORNL/Various Code/multislice/PySlice/TWP20251230b/tests/../src/pyslice/multislice/multislice.py", line 413, in Propagate - potential_slice = potential.calculateSlice(z) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "/media/qwe/Alexandria/ORNL/Various Code/multislice/PySlice/TWP20251230b/tests/../src/pyslice/multislice/potentials.py", line 348, in calculateSlice - shape_factor += xp.einsum('ax,ay->xy', expx, expy, **kwarg) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "/usr/lib/python3/dist-packages/numpy/core/einsumfunc.py", line 1419, in einsum - new_view = tensordot(*tmp_operands, axes=(tuple(left_pos), tuple(right_pos))) - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - File "/usr/lib/python3/dist-packages/numpy/core/numeric.py", line 1121, in tensordot - res = dot(at, bt) - ^^^^^^^^^^^ -KeyboardInterrupt diff --git a/tests/runAllTests.sh b/tests/runAllTests.sh index b2a1a25..42eb6b5 100644 --- a/tests/runAllTests.sh +++ b/tests/runAllTests.sh @@ -1,13 +1,10 @@ scripts=( "00_probe.py" "01_potentials.py" "02_propagate_otf=False.py" "02_propagate_otf=True.py" "03_manyprobes.py" "04_haadf.py" "05_tacaw.py" "05_tacaw_chunkFFT.py" "05_tacaw_cropped.py" "06_loaders.py" "07_defocus.py" "08_LACBED_iterative.py" "08_LACBED_onthefly.py" "10_midgley.py" "11_SED.py" "12_aberrations.py" ) -echo $(date) > runAllTests.log +echo $(date) > runAllTests-$1.log for s in ${scripts[@]} do - for version in 3 3.13 3.9 - do - echo python$version $s >> runAllTests.log - python$version $s >> runAllTests.log 2>> runAllTests.log - rm -rf psi_data/* - done + echo python3 $s >> runAllTests-$1.log + python3 $s >> runAllTests-$1.log 2>> runAllTests-$1.log + #rm -rf psi_data/* done diff --git a/tests/test-cpu.sberr b/tests/test-cpu.sberr new file mode 100644 index 0000000..7c0d424 --- /dev/null +++ b/tests/test-cpu.sberr @@ -0,0 +1,3 @@ + +CondaError: Run 'conda init' before 'conda activate' + diff --git a/tests/test-cpu.sbout b/tests/test-cpu.sbout new file mode 100644 index 0000000..e69de29