From 284e0bc82a1dae9fb4e4c0c8191cb0761d09d098 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Fri, 6 Jun 2025 10:01:41 -0400 Subject: [PATCH 1/7] initial MicrographSource/Image extension to rect shapes --- src/aspire/image/image.py | 50 ++++++++++++++++----- src/aspire/source/micrograph.py | 69 ++++++++++++++++------------- tests/test_array_image_source.py | 2 +- tests/test_image.py | 6 +-- tests/test_micrograph_simulation.py | 10 ++--- tests/test_micrograph_source.py | 5 +-- 6 files changed, 87 insertions(+), 55 deletions(-) diff --git a/src/aspire/image/image.py b/src/aspire/image/image.py index 071437a1ef..820da0a9c5 100644 --- a/src/aspire/image/image.py +++ b/src/aspire/image/image.py @@ -203,20 +203,19 @@ def __init__(self, data, pixel_size=None, dtype=None): else: self.dtype = np.dtype(dtype) - if not data.shape[-1] == data.shape[-2]: - raise ValueError("Only square ndarrays are supported.") - self._data = data.astype(self.dtype, copy=False) self.ndim = self._data.ndim self.shape = self._data.shape self.stack_ndim = self._data.ndim - 2 self.stack_shape = self._data.shape[:-2] self.n_images = np.prod(self.stack_shape) - self.resolution = self._data.shape[-1] self.pixel_size = None if pixel_size is not None: self.pixel_size = float(pixel_size) + self._is_square = data.shape[-1] == data.shape[-2] + self.resolution = self._data.shape[-1] # XXXXX + # Numpy interop # https://numpy.org/devdocs/user/basics.interoperability.html#the-array-interface-protocol self.__array_interface__ = self._data.__array_interface__ @@ -234,6 +233,12 @@ def project(self, angles): :return: Radon transform of the Image Stack. :rtype: Ndarray (stack size, number of angles, image resolution) """ + + if not self._is_square: + raise NotImplementedError( + "`Image.project` is not currently implemented for non-square images." + ) + # number of points to sample on radial line in polar grid n_points = self.resolution original_stack = self.stack_shape @@ -309,19 +314,19 @@ def stack_reshape(self, *args): ) def __add__(self, other): - if isinstance(other, Image): + if isinstance(other, self.__class__): other = other._data return self.__class__(self._data + other, pixel_size=self.pixel_size) def __sub__(self, other): - if isinstance(other, Image): + if isinstance(other, self.__class__): other = other._data return self.__class__(self._data - other, pixel_size=self.pixel_size) def __mul__(self, other): - if isinstance(other, Image): + if isinstance(other, self.__class__): other = other._data return self.__class__(self._data * other, pixel_size=self.pixel_size) @@ -385,7 +390,7 @@ def __repr__(self): px_msg = f" with pixel_size={self.pixel_size} angstroms." msg = f"{self.n_images} {self.dtype} images arranged as a {self.stack_shape} stack" - msg += f" each of size {self.resolution}x{self.resolution}{px_msg}" + msg += f" each of size {self.shape[-2:]}{px_msg}" return msg def asnumpy(self): @@ -442,6 +447,12 @@ def legacy_whiten(self, psd, delta): and which to set to zero. By default all `sqrt(psd)` values less than `delta` are zeroed out in the whitening filter. """ + + if not self._is_square: + raise NotImplementedError( + "`Image.legacy_whiten` is not currently implemented for non-square images." + ) + n = self.n_images L = self.resolution L_half = L // 2 @@ -607,6 +618,11 @@ def filter(self, filter): :param filter: An object of type `Filter`. :return: A new filtered `Image` object. """ + if not self._is_square: + raise NotImplementedError( + "`Image.filter` is not currently implemented for non-square images." + ) + original_stack_shape = self.stack_shape im = self.stack_reshape(-1) @@ -777,8 +793,8 @@ def _load_raw(filepath, dtype=None): return im, pixel_size - @staticmethod - def load(filepath, dtype=None): + @classmethod + def load(cls, filepath, dtype=None): """ Load raw data from supported files. @@ -793,7 +809,7 @@ def load(filepath, dtype=None): im, pixel_size = Image._load_raw(filepath, dtype=dtype) # Return as Image instance - return Image(im, pixel_size=pixel_size) + return cls(im, pixel_size=pixel_size) def _im_translate(self, shifts): """ @@ -809,6 +825,10 @@ def _im_translate(self, shifts): Alternatively, it can be a row vector of length 2, in which case the same shifts is applied to each image. :return: The images translated by the shifts, with periodic boundaries. """ + if not self._is_square: + raise NotImplementedError( + "`Image._im_translate` is not currently implemented for non-square images." + ) if shifts.ndim == 1: shifts = shifts[np.newaxis, :] @@ -879,6 +899,10 @@ def backproject(self, rot_matrices, symmetry_group=None, zero_nyquist=True): :return: Volume instance corresonding to the backprojected images. """ + if not self._is_square: + raise NotImplementedError( + "`Image.legacy_whiten` is not currently implemented for non-square images." + ) if self.stack_ndim > 1: raise NotImplementedError( @@ -996,6 +1020,10 @@ def frc(self, other, cutoff=None, method="fft", plot=False): where `estimated_resolution` is in angstrom and FRC is a Numpy array of correlations. """ + if not self._is_square: + raise NotImplementedError( + "`Image.frc` is not currently implemented for non-square images." + ) if not isinstance(other, Image): raise TypeError( diff --git a/src/aspire/source/micrograph.py b/src/aspire/source/micrograph.py index e6c8e6a3bc..e005e8910c 100644 --- a/src/aspire/source/micrograph.py +++ b/src/aspire/source/micrograph.py @@ -1,5 +1,6 @@ import logging import os +import warnings from abc import ABC, abstractmethod from glob import glob from pathlib import Path @@ -20,7 +21,12 @@ class MicrographSource(ABC): def __init__(self, micrograph_count, micrograph_size, dtype, pixel_size=None): """ """ self.micrograph_count = int(micrograph_count) - self.micrograph_size = int(micrograph_size) + # Expand single integer to 2-tuple + if isinstance(micrograph_size, int): + micrograph_size = (micrograph_size,) * 2 + if len(micrograph_size) != 2: + raise ValueError("`micrograph_size` should be a integer or 2-tuple") + self.micrograph_size = tuple(micrograph_size) self.dtype = np.dtype(dtype) if pixel_size is not None: pixel_size = float(pixel_size) @@ -34,7 +40,7 @@ def __repr__(self): :return: Returns a string description of instance. """ - return f"{self.__class__.__name__} with {self.micrograph_count} {self.dtype.name} micrographs of size {self.micrograph_size}x{self.micrograph_size}" + return f"{self.__class__.__name__} with {self.micrograph_count} {self.dtype.name} micrographs of size {self.micrograph_size}" def __len__(self): """ @@ -142,14 +148,14 @@ def __init__(self, micrographs, dtype=None, pixel_size=None): if micrographs.ndim == 2: micrographs = micrographs[None, :, :] - if micrographs.ndim != 3 or (micrographs.shape[-2] != micrographs.shape[-1]): + if micrographs.ndim != 3: raise NotImplementedError( - f"Incompatible `micrographs` shape {micrographs.shape}, expects (count, L, L)" + f"Incompatible `micrographs` shape {micrographs.shape}, expects 2D or 3D array." ) super().__init__( micrograph_count=micrographs.shape[0], - micrograph_size=micrographs.shape[-1], + micrograph_size=micrographs.shape[-2:], dtype=dtype or micrographs.dtype, pixel_size=pixel_size, ) @@ -201,15 +207,15 @@ def __init__(self, micrographs_path, dtype=None, pixel_size=None): # Load the first micrograph to infer shape/type # Size will be checked during on-the-fly loading of subsequent micrographs. - micrograph0 = Image.load(self.micrograph_files[0]) - if micrograph0.pixel_size is not None and micrograph0.pixel_size != pixel_size: - raise ValueError( - f"Mismatched pixel size. {micrograph0.pixel_size} angstroms defined in {self.micrograph_files[0]}, but provided {pixel_size} angstroms." - ) + micrograph0, _pixel_size = Image._load_raw(self.micrograph_files[0]) + # Compare with user provided pixel size + if pixel_size is not None and _pixel_size != pixel_size: + msg = f"Mismatched pixel size. {_pixel_size} angstroms defined in {self.micrograph_files[0]}, but provided {pixel_size} angstroms." + warnings.warn(msg, UserWarning, stacklevel=2) super().__init__( micrograph_count=len(self.micrograph_files), - micrograph_size=micrograph0.resolution, + micrograph_size=micrograph0.shape[-2:], dtype=dtype or micrograph0.dtype, pixel_size=pixel_size, ) @@ -265,28 +271,27 @@ def _images(self, indices): # Initialize empty result n_micrographs = len(indices) micrographs = np.empty( - (n_micrographs, self.micrograph_size, self.micrograph_size), + (n_micrographs, *self.micrograph_size), dtype=self.dtype, ) for i, ind in enumerate(indices): # Load the micrograph image from file - micrograph = Image.load(self.micrograph_files[ind]) + micrograph, _pixel_size = Image._load_raw(self.micrograph_files[ind]) + # Assert size - if micrograph.resolution != self.micrograph_size: + if micrograph.shape != self.micrograph_size: raise NotImplementedError( f"Micrograph {ind} has inconsistent shape {micrograph.shape}," - f" expected {(self.micrograph_size, self.micrograph_size)}." + f" expected {self.micrograph_size}." ) + + # Continually compare with initial pixel_size + if _pixel_size is not None and _pixel_size != self.pixel_size: + msg = f"Mismatched pixel size. {micrograph.pixel_size} angstroms defined in {self.micrograph_files[ind]}, but provided {self.pixel_size} angstroms." + warnings.warn(msg, UserWarning, stacklevel=2) + # Assign to array, implicitly performs casting to dtype - micrographs[i] = micrograph.asnumpy() - # Assert pixel_size - if ( - micrograph.pixel_size is not None - and micrograph.pixel_size != self.pixel_size - ): - raise ValueError( - f"Mismatched pixel size. {micrograph.pixel_size} angstroms defined in {self.micrograph_files[ind]}, but provided {self.pixel_size} angstroms." - ) + micrographs[i] = micrograph return Image(micrographs, pixel_size=self.pixel_size) @@ -314,7 +319,7 @@ def __init__( :param volume: `Volume` instance to be used in `Simulation`. An `(L,L,L)` `Volume` will generate `(L,L)` particle images. - :param micrograph_size: Size of micrograph in pixels, defaults to 4096. + :param micrograph_size: Size of micrograph in pixels as integer or 2-tuple. Defaults to 4096. :param micrograph_count: Number of micrographs to generate (integer). Defaults to 1. :param particles_per_micrograph: The amount of particles generated for each micrograph. Defaults to 10. :param particle_amplitudes: Optional, amplitudes to pass to `Simulation`. @@ -366,7 +371,7 @@ def __init__( self.noise_adder = noise_adder - if self.particle_box_size > micrograph_size: + if self.particle_box_size > max(self.micrograph_size): raise ValueError( "The micrograph size must be larger or equal to the `particle_box_size`." ) @@ -428,7 +433,7 @@ def __init__( else: if ( boundary < (-self.particle_box_size // 2) - or boundary > self.micrograph_size // 2 + or boundary > max(self.micrograph_size) // 2 ): raise ValueError("Illegal boundary value.") self.boundary = boundary @@ -518,8 +523,8 @@ def _set_mask(self): """ self._mask = np.full( ( - int(self.micrograph_size + 2 * self.pad), - int(self.micrograph_size + 2 * self.pad), + int(self.micrograph_size[0] + 2 * self.pad), + int(self.micrograph_size[1] + 2 * self.pad), ), False, dtype=bool, @@ -560,7 +565,7 @@ def _clean_images(self, indices): # Initialize empty micrograph n_micrographs = len(indices) clean_micrograph = np.zeros( - (n_micrographs, self.micrograph_size, self.micrograph_size), + (n_micrographs, *self.micrograph_size), dtype=self.dtype, ) # Pad the micrograph @@ -592,8 +597,8 @@ def _clean_images(self, indices): ) clean_micrograph = clean_micrograph[ :, - self.pad : self.micrograph_size + self.pad, - self.pad : self.micrograph_size + self.pad, + self.pad : self.micrograph_size[0] + self.pad, + self.pad : self.micrograph_size[1] + self.pad, ] return Image(clean_micrograph, pixel_size=self.pixel_size) diff --git a/tests/test_array_image_source.py b/tests/test_array_image_source.py index a2c3ee4f0c..cc0ca6b2d9 100644 --- a/tests/test_array_image_source.py +++ b/tests/test_array_image_source.py @@ -81,7 +81,7 @@ def testArrayImageSourceNumpyError(self): # Test we raise with expected message from getter. with raises(RuntimeError, match=r"Creating Image object from Numpy.*"): - _ = ArrayImageSource(np.empty((3, 2, 1))) + _ = ArrayImageSource(np.empty((1))) def testArrayImageSourceAngGetterError(self): """ diff --git a/tests/test_image.py b/tests/test_image.py index 009be52364..bf8e2eb3a5 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -88,9 +88,9 @@ def testRepr(get_mdim_images): def testNonSquare(): - """Test that an irregular Image array raises.""" - with raises(ValueError, match=r".* square .*"): - _ = Image(np.empty((4, 5))) + """Test that an irregular Image array does not raise.""" + _ = Image(np.empty((4, 5))) + _ = Image(np.empty((3, 4, 5))) def testImShift(get_images, dtype): diff --git a/tests/test_micrograph_simulation.py b/tests/test_micrograph_simulation.py index 2e81d7326f..61d5114e1d 100644 --- a/tests/test_micrograph_simulation.py +++ b/tests/test_micrograph_simulation.py @@ -85,11 +85,11 @@ def test_micrograph_source_has_correct_values(vol_fixture, micrograph_fixture): assert v.resolution == m.particle_box_size assert v == m.simulation.vols assert len(m) == m.micrograph_count - assert m.clean_images[0].shape[1] == m.micrograph_size - assert m.clean_images[0].shape[2] == m.micrograph_size + assert m.clean_images[0].shape[1] == m.micrograph_size[0] + assert m.clean_images[0].shape[2] == m.micrograph_size[1] assert ( repr(m) - == f"{m.__class__.__name__} with {m.micrograph_count} {m.dtype.name} micrographs of size {m.micrograph_size}x{m.micrograph_size}" + == f"{m.__class__.__name__} with {m.micrograph_count} {m.dtype.name} micrographs of size {m.micrograph_size}" ) _ = m.clean_images[:] _ = m.images[:] @@ -188,9 +188,9 @@ def test_micrograph_centers_match(micrograph_fixture): for i, center in enumerate(centers): if ( center[0] >= 0 - and center[0] < m.micrograph_size + and center[0] < m.micrograph_size[0] and center[1] >= 0 - and center[1] < m.micrograph_size + and center[1] < m.micrograph_size[1] ): assert m.clean_images[i // m.particles_per_micrograph].asnumpy()[0][ tuple(center) diff --git a/tests/test_micrograph_source.py b/tests/test_micrograph_source.py index d4793cf61f..ba8d25af46 100644 --- a/tests/test_micrograph_source.py +++ b/tests/test_micrograph_source.py @@ -271,12 +271,11 @@ def test_wrong_dim_micrograph_source(): def test_rectangular_micrograph_source_array(): """ - Test non-square micrograph source raises. + Test non-square micrograph source does not raises. """ # Test with Numpy array input imgs_np = np.empty((3, 7, 8)) - with pytest.raises(RuntimeError, match=r"Incompatible.*"): - ArrayMicrographSource(imgs_np) + _ = ArrayMicrographSource(imgs_np) def test_rectangular_micrograph_source_files(): From aa483d5ca20abfbb97f9a08a7c95f771c317dd6a Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Tue, 10 Jun 2025 11:47:20 -0400 Subject: [PATCH 2/7] draft extension of grid_2d and image.filter to rectangle --- src/aspire/image/image.py | 14 +- src/aspire/utils/coor_trans.py | 11 +- tests/test_filters.py | 40 +- tests/test_grids.py | 2563 ++++++++++++++++---------------- 4 files changed, 1346 insertions(+), 1282 deletions(-) diff --git a/src/aspire/image/image.py b/src/aspire/image/image.py index 820da0a9c5..65bbe0e254 100644 --- a/src/aspire/image/image.py +++ b/src/aspire/image/image.py @@ -618,10 +618,6 @@ def filter(self, filter): :param filter: An object of type `Filter`. :return: A new filtered `Image` object. """ - if not self._is_square: - raise NotImplementedError( - "`Image.filter` is not currently implemented for non-square images." - ) original_stack_shape = self.stack_shape @@ -634,12 +630,14 @@ def filter(self, filter): # Second note, filter and grid dtype may not match image dtype, # upcast both here for most accurate convolution. filter_values = xp.asarray( - filter.evaluate_grid( - self.resolution, dtype=np.float64, pixel_size=self.pixel_size - ), - dtype=np.float64, + filter.evaluate_grid(self.shape[-2:]), dtype=self.dtype, pixel_size=self.pixel_size ) + # sanity check + assert ( + filter_values.shape == im._data.shape[-2:] + ), f"{filter_values.shape} != {im._data.shape[:-2]}" + # Convolve _im = xp.asarray(im._data, dtype=np.float64) im_f = fft.centered_fft2(_im) diff --git a/src/aspire/utils/coor_trans.py b/src/aspire/utils/coor_trans.py index 600d8355b1..f308f91147 100644 --- a/src/aspire/utils/coor_trans.py +++ b/src/aspire/utils/coor_trans.py @@ -98,6 +98,7 @@ def grid_2d(n, shifted=False, normalized=True, indexing="yx", dtype=np.float32): Generate two dimensional grid. :param n: the number of grid points in each dimension. + May be a single integer value or 2-tuple of integers. :param shifted: shifted by half of grid or not when n is even. :param normalized: normalize the grid in the range of (-1, 1) or not. :param indexing: 'yx' (C) or 'xy' (F), defaulting to 'yx'. @@ -105,8 +106,14 @@ def grid_2d(n, shifted=False, normalized=True, indexing="yx", dtype=np.float32): :return: the rectangular and polar coordinates of all grid points. """ - grid = _mgrid_slice(n, shifted, normalized) - y, x = np.mgrid[grid, grid].astype(dtype) + if isinstance(n, int): + n = (n, n) + rows, cols = n + + rows = _mgrid_slice(rows, shifted, normalized) + cols = _mgrid_slice(cols, shifted, normalized) + + y, x = np.mgrid[rows, cols].astype(dtype) if indexing == "xy": x, y = y, x elif indexing != "yx": diff --git a/tests/test_filters.py b/tests/test_filters.py index b96bc6dff3..c9f16ece34 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -5,6 +5,7 @@ import numpy as np import pytest +from aspire.image import Image from aspire.operators import ( ArrayFilter, CTFFilter, @@ -16,7 +17,7 @@ ScaledFilter, ZeroFilter, ) -from aspire.utils import utest_tolerance +from aspire.utils import gaussian_2d, grid_2d, utest_tolerance DATA_DIR = os.path.join(os.path.dirname(__file__), "saved_test_data") @@ -245,3 +246,40 @@ def test_ctf_reference(): # Test match all significant digits above np.testing.assert_allclose(h, ref_h, atol=5e-5) + +def test_rectangular_ctf(): + """ + Compare a truncated rectangular CTF application with the + application of CTF to a full square image. + """ + # Configure square and truncated rectangle size + L = 128 + rows, cols = 96, L + assert rows <= L and cols <= L and min(rows, cols) < L + + # Create a test image of a disk + # A = gaussian_2d(size=L, mu=(0,-L//10), sigma=L//8, dtype=np.float64) + A = gaussian_2d(size=L, mu=(0, -L // 10), sigma=L // 32, dtype=np.float64) + + full_img = Image(A) + truncated_img = Image(A[:rows, :cols]) + + # Create a CTFFilter + ctf_filter = CTFFilter(pixel_size=2) + + # Apply to both Image instances + full_img_with_ctf = full_img.filter(ctf_filter) + truncated_img_with_ctf = truncated_img.filter(ctf_filter) + + # Truncate the full square result + full_img_with_ctf_truncated = full_img_with_ctf.asnumpy()[:, :rows, :cols] + + # Create mask for circular convolution effects + mask = (grid_2d(L, normalized=True)["r"] < 0.5)[:rows, :cols] + + # Compare, we should be the same up to masked off differences in + # circular convolution wrap around. + np.testing.assert_allclose( + truncated_img_with_ctf * mask, full_img_with_ctf_truncated * mask, atol=1e-6 + ) + diff --git a/tests/test_grids.py b/tests/test_grids.py index 1b156d1179..e668c8632c 100644 --- a/tests/test_grids.py +++ b/tests/test_grids.py @@ -10,1403 +10,1403 @@ class LegacyGridsTestCase(TestCase): - def setUp(self): - # Keys are of form (n,shift,normalized) - self.ns = [3, 4] - self.shifts = [False, True] - self.norms = [False, True] + # Note: Hard-coded references for (4, True, True) changed to reflect alteration + # in normalization factor for even/shifted/normalized grids (see PR #1258). + legacy_references_2d = { + (3, False, False): { + "x": np.array( + [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], + dtype=np.float32, + ), + "y": np.array( + [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -3.1415925, 2.3561945], + [-1.5707964, -3.1415925, 1.5707964], + [-0.7853982, -0.0, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [1.4142135, 1.0, 1.4142135], + [1.0, 0.0, 1.0], + [1.4142135, 1.0, 1.4142135], + ], + dtype=np.float32, + ), + }, + (3, False, True): { + "x": np.array( + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.0, -0.0, -0.0], + [0.6666667, 0.6666667, 0.6666667], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -3.1415925, 2.3561945], + [-1.5707964, -3.1415925, 1.5707964], + [-0.7853982, -0.0, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [0.94280905, 0.6666667, 0.94280905], + [0.6666667, 0.0, 0.6666667], + [0.94280905, 0.6666667, 0.94280905], + ], + dtype=np.float32, + ), + }, + (3, True, False): { + "x": np.array( + [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], + dtype=np.float32, + ), + "y": np.array( + [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -3.1415925, 2.3561945], + [-1.5707964, -3.1415925, 1.5707964], + [-0.7853982, -0.0, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [1.4142135, 1.0, 1.4142135], + [1.0, 0.0, 1.0], + [1.4142135, 1.0, 1.4142135], + ], + dtype=np.float32, + ), + }, + (3, True, True): { + "x": np.array( + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.0, -0.0, -0.0], + [0.6666667, 0.6666667, 0.6666667], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -3.1415925, 2.3561945], + [-1.5707964, -3.1415925, 1.5707964], + [-0.7853982, -0.0, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [0.94280905, 0.6666667, 0.94280905], + [0.6666667, 0.0, 0.6666667], + [0.94280905, 0.6666667, 0.94280905], + ], + dtype=np.float32, + ), + }, + (4, False, False): { + "x": np.array( + [ + [-2.0, -2.0, -2.0, -2.0], + [-1.0, -1.0, -1.0, -1.0], + [0.0, 0.0, 0.0, 0.0], + [1.0, 1.0, 1.0, 1.0], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -2.6779451, 3.1415925, 2.6779451], + [-2.0344439, -2.3561945, 3.1415925, 2.3561945], + [-1.5707964, -1.5707964, 0.0, 1.5707964], + [-1.1071488, -0.7853982, 0.0, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [2.828427, 2.236068, 2.0, 2.236068], + [2.236068, 1.4142135, 1.0, 1.4142135], + [2.0, 1.0, 0.0, 1.0], + [2.236068, 1.4142135, 1.0, 1.4142135], + ], + dtype=np.float32, + ), + }, + (4, False, True): { + "x": np.array( + [ + [-1.0, -1.0, -1.0, -1.0], + [-0.5, -0.5, -0.5, -0.5], + [0.0, 0.0, 0.0, 0.0], + [0.5, 0.5, 0.5, 0.5], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -2.6779451, 3.1415925, 2.6779451], + [-2.0344439, -2.3561945, 3.1415925, 2.3561945], + [-1.5707964, -1.5707964, 0.0, 1.5707964], + [-1.1071488, -0.7853982, 0.0, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [1.4142135, 1.118034, 1.0, 1.118034], + [1.118034, 0.70710677, 0.5, 0.70710677], + [1.0, 0.5, 0.0, 0.5], + [1.118034, 0.70710677, 0.5, 0.70710677], + ], + dtype=np.float32, + ), + }, + (4, True, False): { + "x": np.array( + [ + [-1.5, -1.5, -1.5, -1.5], + [-0.5, -0.5, -0.5, -0.5], + [0.5, 0.5, 0.5, 0.5], + [1.5, 1.5, 1.5, 1.5], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -2.819842, 2.819842, 2.3561945], + [-1.8925469, -2.3561945, 2.3561945, 1.8925469], + [-1.2490457, -0.7853982, 0.7853982, 1.2490457], + [-0.7853982, -0.32175055, 0.32175055, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [2.1213202, 1.5811388, 1.5811388, 2.1213202], + [1.5811388, 0.70710677, 0.70710677, 1.5811388], + [1.5811388, 0.70710677, 0.70710677, 1.5811388], + [2.1213202, 1.5811388, 1.5811388, 2.1213202], + ], + dtype=np.float32, + ), + }, + (4, True, True): { + "x": np.array( + [ + [-0.75, -0.75, -0.75, -0.75], + [-0.25, -0.25, -0.25, -0.25], + [0.25, 0.25, 0.25, 0.25], + [0.75, 0.75, 0.75, 0.75], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [-2.3561945, -2.819842, 2.819842, 2.3561945], + [-1.8925469, -2.3561945, 2.3561945, 1.8925469], + [-1.2490457, -0.7853982, 0.7853982, 1.2490457], + [-0.7853982, -0.32175055, 0.32175055, 0.7853982], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [1.0606601, 0.7905694, 0.7905694, 1.0606601], + [0.7905694, 0.35355338, 0.35355338, 0.7905694], + [0.7905694, 0.35355338, 0.35355338, 0.7905694], + [1.0606601, 0.7905694, 0.7905694, 1.0606601], + ], + dtype=np.float32, + ), + }, + } - # Note: Hard-coded references for (4, True, True) changed to reflect alteration - # in normalization factor for even/shifted/normalized grids (see PR #1258). - self.legacy_references_2d = { - (3, False, False): { - "x": np.array( + legacy_references_3d = { + (3, False, False): { + "x": np.array( + [ + [[-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0]], + [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], + [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - dtype=np.float32, - ), - "y": np.array( + [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], + ], + dtype=np.float32, + ), + "z": np.array( + [ + [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - dtype=np.float32, - ), - "phi": np.array( + [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945], + [-3.1415925, -3.1415925, -3.1415925], + [2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.5707964, -1.5707964, -1.5707964], + [-3.1415925, -3.1415925, -3.1415925], + [1.5707964, 1.5707964, 1.5707964], + ], + [ + [-0.7853982, -0.7853982, -0.7853982], + [-0.0, -0.0, -0.0], + [0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + [ + [2.3561945, 1.5707964, 0.7853982], + [3.1415927, 1.5707964, 0.0], + [2.3561945, 1.5707964, 0.7853982], + ], + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ [ - [-2.3561945, -3.1415925, 2.3561945], - [-1.5707964, -3.1415925, 1.5707964], - [-0.7853982, -0.0, 0.7853982], + [1.7320508, 1.4142135, 1.7320508], + [1.4142135, 1.0, 1.4142135], + [1.7320508, 1.4142135, 1.7320508], ], - dtype=np.float32, - ), - "r": np.array( [ [1.4142135, 1.0, 1.4142135], [1.0, 0.0, 1.0], [1.4142135, 1.0, 1.4142135], ], - dtype=np.float32, - ), - }, - (3, False, True): { - "x": np.array( + [ + [1.7320508, 1.4142135, 1.7320508], + [1.4142135, 1.0, 1.4142135], + [1.7320508, 1.4142135, 1.7320508], + ], + ], + dtype=np.float32, + ), + }, + (3, False, True): { + "x": np.array( + [ + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.6666667, -0.6666667, -0.6666667], + [-0.6666667, -0.6666667, -0.6666667], + ], + [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], + [ + [0.6666667, 0.6666667, 0.6666667], + [0.6666667, 0.6666667, 0.6666667], + [0.6666667, 0.6666667, 0.6666667], + ], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.0, -0.0, -0.0], + [0.6666667, 0.6666667, 0.6666667], + ], + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.0, -0.0, -0.0], + [0.6666667, 0.6666667, 0.6666667], + ], [ [-0.6666667, -0.6666667, -0.6666667], [-0.0, -0.0, -0.0], [0.6666667, 0.6666667, 0.6666667], ], - dtype=np.float32, - ), - "y": np.array( + ], + dtype=np.float32, + ), + "z": np.array( + [ + [ + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + ], [ [-0.6666667, -0.0, 0.6666667], [-0.6666667, -0.0, 0.6666667], [-0.6666667, -0.0, 0.6666667], ], - dtype=np.float32, - ), - "phi": np.array( [ - [-2.3561945, -3.1415925, 2.3561945], - [-1.5707964, -3.1415925, 1.5707964], - [-0.7853982, -0.0, 0.7853982], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + ], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945], + [-3.1415925, -3.1415925, -3.1415925], + [2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.5707964, -1.5707964, -1.5707964], + [-3.1415925, -3.1415925, -3.1415925], + [1.5707964, 1.5707964, 1.5707964], + ], + [ + [-0.7853982, -0.7853982, -0.7853982], + [-0.0, -0.0, -0.0], + [0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + [ + [2.3561945, 1.5707964, 0.7853982], + [3.1415927, 1.5707964, 0.0], + [2.3561945, 1.5707964, 0.7853982], + ], + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [ + [1.1547005, 0.94280905, 1.1547005], + [0.94280905, 0.6666667, 0.94280905], + [1.1547005, 0.94280905, 1.1547005], ], - dtype=np.float32, - ), - "r": np.array( [ [0.94280905, 0.6666667, 0.94280905], [0.6666667, 0.0, 0.6666667], [0.94280905, 0.6666667, 0.94280905], ], - dtype=np.float32, - ), - }, - (3, True, False): { - "x": np.array( + [ + [1.1547005, 0.94280905, 1.1547005], + [0.94280905, 0.6666667, 0.94280905], + [1.1547005, 0.94280905, 1.1547005], + ], + ], + dtype=np.float32, + ), + }, + (3, True, False): { + "x": np.array( + [ + [[-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0]], + [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], + [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]], + ], + dtype=np.float32, + ), + "y": np.array( + [ [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - dtype=np.float32, - ), - "y": np.array( + [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], + [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], + ], + dtype=np.float32, + ), + "z": np.array( + [ + [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - dtype=np.float32, - ), - "phi": np.array( + [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945], + [-3.1415925, -3.1415925, -3.1415925], + [2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.5707964, -1.5707964, -1.5707964], + [-3.1415925, -3.1415925, -3.1415925], + [1.5707964, 1.5707964, 1.5707964], + ], + [ + [-0.7853982, -0.7853982, -0.7853982], + [-0.0, -0.0, -0.0], + [0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ [ - [-2.3561945, -3.1415925, 2.3561945], - [-1.5707964, -3.1415925, 1.5707964], - [-0.7853982, -0.0, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + [ + [2.3561945, 1.5707964, 0.7853982], + [3.1415927, 1.5707964, 0.0], + [2.3561945, 1.5707964, 0.7853982], + ], + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [ + [1.7320508, 1.4142135, 1.7320508], + [1.4142135, 1.0, 1.4142135], + [1.7320508, 1.4142135, 1.7320508], ], - dtype=np.float32, - ), - "r": np.array( [ [1.4142135, 1.0, 1.4142135], [1.0, 0.0, 1.0], [1.4142135, 1.0, 1.4142135], ], - dtype=np.float32, - ), - }, - (3, True, True): { - "x": np.array( + [ + [1.7320508, 1.4142135, 1.7320508], + [1.4142135, 1.0, 1.4142135], + [1.7320508, 1.4142135, 1.7320508], + ], + ], + dtype=np.float32, + ), + }, + (3, True, True): { + "x": np.array( + [ + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.6666667, -0.6666667, -0.6666667], + [-0.6666667, -0.6666667, -0.6666667], + ], + [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], + [ + [0.6666667, 0.6666667, 0.6666667], + [0.6666667, 0.6666667, 0.6666667], + [0.6666667, 0.6666667, 0.6666667], + ], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.0, -0.0, -0.0], + [0.6666667, 0.6666667, 0.6666667], + ], + [ + [-0.6666667, -0.6666667, -0.6666667], + [-0.0, -0.0, -0.0], + [0.6666667, 0.6666667, 0.6666667], + ], [ [-0.6666667, -0.6666667, -0.6666667], [-0.0, -0.0, -0.0], [0.6666667, 0.6666667, 0.6666667], ], - dtype=np.float32, - ), - "y": np.array( + ], + dtype=np.float32, + ), + "z": np.array( + [ + [ + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + ], + [ + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + [-0.6666667, -0.0, 0.6666667], + ], [ [-0.6666667, -0.0, 0.6666667], [-0.6666667, -0.0, 0.6666667], [-0.6666667, -0.0, 0.6666667], ], - dtype=np.float32, - ), - "phi": np.array( + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945], + [-3.1415925, -3.1415925, -3.1415925], + [2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.5707964, -1.5707964, -1.5707964], + [-3.1415925, -3.1415925, -3.1415925], + [1.5707964, 1.5707964, 1.5707964], + ], + [ + [-0.7853982, -0.7853982, -0.7853982], + [-0.0, -0.0, -0.0], + [0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + [ + [2.3561945, 1.5707964, 0.7853982], + [3.1415927, 1.5707964, 0.0], + [2.3561945, 1.5707964, 0.7853982], + ], + [ + [2.186276, 1.5707964, 0.95531666], + [2.3561945, 1.5707964, 0.7853982], + [2.186276, 1.5707964, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ [ - [-2.3561945, -3.1415925, 2.3561945], - [-1.5707964, -3.1415925, 1.5707964], - [-0.7853982, -0.0, 0.7853982], + [1.1547005, 0.94280905, 1.1547005], + [0.94280905, 0.6666667, 0.94280905], + [1.1547005, 0.94280905, 1.1547005], ], - dtype=np.float32, - ), - "r": np.array( [ [0.94280905, 0.6666667, 0.94280905], [0.6666667, 0.0, 0.6666667], [0.94280905, 0.6666667, 0.94280905], ], - dtype=np.float32, - ), - }, - (4, False, False): { - "x": np.array( + [ + [1.1547005, 0.94280905, 1.1547005], + [0.94280905, 0.6666667, 0.94280905], + [1.1547005, 0.94280905, 1.1547005], + ], + ], + dtype=np.float32, + ), + }, + (4, False, False): { + "x": np.array( + [ + [ + [-2.0, -2.0, -2.0, -2.0], + [-2.0, -2.0, -2.0, -2.0], + [-2.0, -2.0, -2.0, -2.0], + [-2.0, -2.0, -2.0, -2.0], + ], + [ + [-1.0, -1.0, -1.0, -1.0], + [-1.0, -1.0, -1.0, -1.0], + [-1.0, -1.0, -1.0, -1.0], + [-1.0, -1.0, -1.0, -1.0], + ], + [ + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + ], + [ + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + [1.0, 1.0, 1.0, 1.0], + ], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [ + [-2.0, -2.0, -2.0, -2.0], + [-1.0, -1.0, -1.0, -1.0], + [0.0, 0.0, 0.0, 0.0], + [1.0, 1.0, 1.0, 1.0], + ], + [ + [-2.0, -2.0, -2.0, -2.0], + [-1.0, -1.0, -1.0, -1.0], + [0.0, 0.0, 0.0, 0.0], + [1.0, 1.0, 1.0, 1.0], + ], + [ + [-2.0, -2.0, -2.0, -2.0], + [-1.0, -1.0, -1.0, -1.0], + [0.0, 0.0, 0.0, 0.0], + [1.0, 1.0, 1.0, 1.0], + ], [ [-2.0, -2.0, -2.0, -2.0], [-1.0, -1.0, -1.0, -1.0], [0.0, 0.0, 0.0, 0.0], [1.0, 1.0, 1.0, 1.0], ], - dtype=np.float32, - ), - "y": np.array( + ], + dtype=np.float32, + ), + "z": np.array( + [ + [ + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + ], + [ + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + ], + [ + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + [-2.0, -1.0, 0.0, 1.0], + ], [ [-2.0, -1.0, 0.0, 1.0], [-2.0, -1.0, 0.0, 1.0], [-2.0, -1.0, 0.0, 1.0], [-2.0, -1.0, 0.0, 1.0], ], - dtype=np.float32, - ), - "phi": np.array( + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [-2.6779451, -2.6779451, -2.6779451, -2.6779451], + [3.1415925, 3.1415925, 3.1415925, 3.1415925], + [2.6779451, 2.6779451, 2.6779451, 2.6779451], + ], + [ + [-2.0344439, -2.0344439, -2.0344439, -2.0344439], + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [3.1415925, 3.1415925, 3.1415925, 3.1415925], + [2.3561945, 2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.5707964, -1.5707964, -1.5707964, -1.5707964], + [-1.5707964, -1.5707964, -1.5707964, -1.5707964], + [0.0, 0.0, 0.0, 0.0], + [1.5707964, 1.5707964, 1.5707964, 1.5707964], + ], + [ + [-1.1071488, -1.1071488, -1.1071488, -1.1071488], + [-0.7853982, -0.7853982, -0.7853982, -0.7853982], + [0.0, 0.0, 0.0, 0.0], + [0.7853982, 0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ [ - [-2.3561945, -2.6779451, 3.1415925, 2.6779451], - [-2.0344439, -2.3561945, 3.1415925, 2.3561945], - [-1.5707964, -1.5707964, 0.0, 1.5707964], - [-1.1071488, -0.7853982, 0.0, 0.7853982], + [2.186276, 1.9106333, 1.5707964, 1.2309594], + [2.300524, 1.9913307, 1.5707964, 1.150262], + [2.3561945, 2.0344439, 1.5707964, 1.1071488], + [2.300524, 1.9913307, 1.5707964, 1.150262], + ], + [ + [2.300524, 1.9913307, 1.5707964, 1.150262], + [2.526113, 2.186276, 1.5707964, 0.95531666], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + [2.526113, 2.186276, 1.5707964, 0.95531666], + ], + [ + [2.3561945, 2.0344439, 1.5707964, 1.1071488], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + [3.1415927, 3.1415927, 1.5707964, 0.0], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + ], + [ + [2.300524, 1.9913307, 1.5707964, 1.150262], + [2.526113, 2.186276, 1.5707964, 0.95531666], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + [2.526113, 2.186276, 1.5707964, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [ + [3.4641016, 3.0, 2.828427, 3.0], + [3.0, 2.4494898, 2.236068, 2.4494898], + [2.828427, 2.236068, 2.0, 2.236068], + [3.0, 2.4494898, 2.236068, 2.4494898], + ], + [ + [3.0, 2.4494898, 2.236068, 2.4494898], + [2.4494898, 1.7320508, 1.4142135, 1.7320508], + [2.236068, 1.4142135, 1.0, 1.4142135], + [2.4494898, 1.7320508, 1.4142135, 1.7320508], ], - dtype=np.float32, - ), - "r": np.array( [ [2.828427, 2.236068, 2.0, 2.236068], [2.236068, 1.4142135, 1.0, 1.4142135], [2.0, 1.0, 0.0, 1.0], [2.236068, 1.4142135, 1.0, 1.4142135], ], - dtype=np.float32, - ), - }, - (4, False, True): { - "x": np.array( + [ + [3.0, 2.4494898, 2.236068, 2.4494898], + [2.4494898, 1.7320508, 1.4142135, 1.7320508], + [2.236068, 1.4142135, 1.0, 1.4142135], + [2.4494898, 1.7320508, 1.4142135, 1.7320508], + ], + ], + dtype=np.float32, + ), + }, + (4, False, True): { + "x": np.array( + [ + [ + [-1.0, -1.0, -1.0, -1.0], + [-1.0, -1.0, -1.0, -1.0], + [-1.0, -1.0, -1.0, -1.0], + [-1.0, -1.0, -1.0, -1.0], + ], + [ + [-0.5, -0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5, -0.5], + ], + [ + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + [0.0, 0.0, 0.0, 0.0], + ], + [ + [0.5, 0.5, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5], + ], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [ + [-1.0, -1.0, -1.0, -1.0], + [-0.5, -0.5, -0.5, -0.5], + [0.0, 0.0, 0.0, 0.0], + [0.5, 0.5, 0.5, 0.5], + ], [ [-1.0, -1.0, -1.0, -1.0], [-0.5, -0.5, -0.5, -0.5], [0.0, 0.0, 0.0, 0.0], [0.5, 0.5, 0.5, 0.5], ], - dtype=np.float32, - ), - "y": np.array( + [ + [-1.0, -1.0, -1.0, -1.0], + [-0.5, -0.5, -0.5, -0.5], + [0.0, 0.0, 0.0, 0.0], + [0.5, 0.5, 0.5, 0.5], + ], + [ + [-1.0, -1.0, -1.0, -1.0], + [-0.5, -0.5, -0.5, -0.5], + [0.0, 0.0, 0.0, 0.0], + [0.5, 0.5, 0.5, 0.5], + ], + ], + dtype=np.float32, + ), + "z": np.array( + [ + [ + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + ], + [ + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + ], + [ + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + [-1.0, -0.5, 0.0, 0.5], + ], [ [-1.0, -0.5, 0.0, 0.5], [-1.0, -0.5, 0.0, 0.5], [-1.0, -0.5, 0.0, 0.5], [-1.0, -0.5, 0.0, 0.5], ], - dtype=np.float32, - ), - "phi": np.array( + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [-2.6779451, -2.6779451, -2.6779451, -2.6779451], + [3.1415925, 3.1415925, 3.1415925, 3.1415925], + [2.6779451, 2.6779451, 2.6779451, 2.6779451], + ], + [ + [-2.0344439, -2.0344439, -2.0344439, -2.0344439], + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [3.1415925, 3.1415925, 3.1415925, 3.1415925], + [2.3561945, 2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.5707964, -1.5707964, -1.5707964, -1.5707964], + [-1.5707964, -1.5707964, -1.5707964, -1.5707964], + [0.0, 0.0, 0.0, 0.0], + [1.5707964, 1.5707964, 1.5707964, 1.5707964], + ], + [ + [-1.1071488, -1.1071488, -1.1071488, -1.1071488], + [-0.7853982, -0.7853982, -0.7853982, -0.7853982], + [0.0, 0.0, 0.0, 0.0], + [0.7853982, 0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ + [ + [2.186276, 1.9106333, 1.5707964, 1.2309594], + [2.300524, 1.9913307, 1.5707964, 1.150262], + [2.3561945, 2.0344439, 1.5707964, 1.1071488], + [2.300524, 1.9913307, 1.5707964, 1.150262], + ], + [ + [2.300524, 1.9913307, 1.5707964, 1.150262], + [2.526113, 2.186276, 1.5707964, 0.95531666], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + [2.526113, 2.186276, 1.5707964, 0.95531666], + ], + [ + [2.3561945, 2.0344439, 1.5707964, 1.1071488], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + [3.1415927, 3.1415927, 1.5707964, 0.0], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + ], + [ + [2.300524, 1.9913307, 1.5707964, 1.150262], + [2.526113, 2.186276, 1.5707964, 0.95531666], + [2.6779451, 2.3561945, 1.5707964, 0.7853982], + [2.526113, 2.186276, 1.5707964, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [ + [1.7320508, 1.5, 1.4142135, 1.5], + [1.5, 1.2247449, 1.118034, 1.2247449], + [1.4142135, 1.118034, 1.0, 1.118034], + [1.5, 1.2247449, 1.118034, 1.2247449], + ], [ - [-2.3561945, -2.6779451, 3.1415925, 2.6779451], - [-2.0344439, -2.3561945, 3.1415925, 2.3561945], - [-1.5707964, -1.5707964, 0.0, 1.5707964], - [-1.1071488, -0.7853982, 0.0, 0.7853982], + [1.5, 1.2247449, 1.118034, 1.2247449], + [1.2247449, 0.8660254, 0.70710677, 0.8660254], + [1.118034, 0.70710677, 0.5, 0.70710677], + [1.2247449, 0.8660254, 0.70710677, 0.8660254], ], - dtype=np.float32, - ), - "r": np.array( [ [1.4142135, 1.118034, 1.0, 1.118034], [1.118034, 0.70710677, 0.5, 0.70710677], [1.0, 0.5, 0.0, 0.5], [1.118034, 0.70710677, 0.5, 0.70710677], ], - dtype=np.float32, - ), - }, - (4, True, False): { - "x": np.array( + [ + [1.5, 1.2247449, 1.118034, 1.2247449], + [1.2247449, 0.8660254, 0.70710677, 0.8660254], + [1.118034, 0.70710677, 0.5, 0.70710677], + [1.2247449, 0.8660254, 0.70710677, 0.8660254], + ], + ], + dtype=np.float32, + ), + }, + (4, True, False): { + "x": np.array( + [ + [ + [-1.5, -1.5, -1.5, -1.5], + [-1.5, -1.5, -1.5, -1.5], + [-1.5, -1.5, -1.5, -1.5], + [-1.5, -1.5, -1.5, -1.5], + ], + [ + [-0.5, -0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5, -0.5], + [-0.5, -0.5, -0.5, -0.5], + ], + [ + [0.5, 0.5, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5], + [0.5, 0.5, 0.5, 0.5], + ], + [ + [1.5, 1.5, 1.5, 1.5], + [1.5, 1.5, 1.5, 1.5], + [1.5, 1.5, 1.5, 1.5], + [1.5, 1.5, 1.5, 1.5], + ], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [ + [-1.5, -1.5, -1.5, -1.5], + [-0.5, -0.5, -0.5, -0.5], + [0.5, 0.5, 0.5, 0.5], + [1.5, 1.5, 1.5, 1.5], + ], + [ + [-1.5, -1.5, -1.5, -1.5], + [-0.5, -0.5, -0.5, -0.5], + [0.5, 0.5, 0.5, 0.5], + [1.5, 1.5, 1.5, 1.5], + ], + [ + [-1.5, -1.5, -1.5, -1.5], + [-0.5, -0.5, -0.5, -0.5], + [0.5, 0.5, 0.5, 0.5], + [1.5, 1.5, 1.5, 1.5], + ], [ [-1.5, -1.5, -1.5, -1.5], [-0.5, -0.5, -0.5, -0.5], [0.5, 0.5, 0.5, 0.5], [1.5, 1.5, 1.5, 1.5], ], - dtype=np.float32, - ), - "y": np.array( + ], + dtype=np.float32, + ), + "z": np.array( + [ + [ + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + ], + [ + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + ], [ [-1.5, -0.5, 0.5, 1.5], [-1.5, -0.5, 0.5, 1.5], [-1.5, -0.5, 0.5, 1.5], [-1.5, -0.5, 0.5, 1.5], ], - dtype=np.float32, - ), - "phi": np.array( [ - [-2.3561945, -2.819842, 2.819842, 2.3561945], - [-1.8925469, -2.3561945, 2.3561945, 1.8925469], - [-1.2490457, -0.7853982, 0.7853982, 1.2490457], - [-0.7853982, -0.32175055, 0.32175055, 0.7853982], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + [-1.5, -0.5, 0.5, 1.5], + ], + ], + dtype=np.float32, + ), + "phi": np.array( + [ + [ + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [-2.819842, -2.819842, -2.819842, -2.819842], + [2.819842, 2.819842, 2.819842, 2.819842], + [2.3561945, 2.3561945, 2.3561945, 2.3561945], + ], + [ + [-1.8925469, -1.8925469, -1.8925469, -1.8925469], + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [2.3561945, 2.3561945, 2.3561945, 2.3561945], + [1.8925469, 1.8925469, 1.8925469, 1.8925469], + ], + [ + [-1.2490457, -1.2490457, -1.2490457, -1.2490457], + [-0.7853982, -0.7853982, -0.7853982, -0.7853982], + [0.7853982, 0.7853982, 0.7853982, 0.7853982], + [1.2490457, 1.2490457, 1.2490457, 1.2490457], + ], + [ + [-0.7853982, -0.7853982, -0.7853982, -0.7853982], + [-0.32175055, -0.32175055, -0.32175055, -0.32175055], + [0.32175055, 0.32175055, 0.32175055, 0.32175055], + [0.7853982, 0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ + [ + [2.186276, 1.8022738, 1.339319, 0.95531666], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.186276, 1.8022738, 1.339319, 0.95531666], + ], + [ + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + ], + [ + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + ], + [ + [2.186276, 1.8022738, 1.339319, 0.95531666], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.186276, 1.8022738, 1.339319, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [ + [2.598076, 2.1794493, 2.1794493, 2.598076], + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + [2.598076, 2.1794493, 2.1794493, 2.598076], + ], + [ + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + [1.6583124, 0.8660254, 0.8660254, 1.6583124], + [1.6583124, 0.8660254, 0.8660254, 1.6583124], + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + ], + [ + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + [1.6583124, 0.8660254, 0.8660254, 1.6583124], + [1.6583124, 0.8660254, 0.8660254, 1.6583124], + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + ], + [ + [2.598076, 2.1794493, 2.1794493, 2.598076], + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + [2.1794496, 1.6583124, 1.6583124, 2.1794496], + [2.598076, 2.1794493, 2.1794493, 2.598076], + ], + ], + dtype=np.float32, + ), + }, + (4, True, True): { + "x": np.array( + [ + [ + [-0.75, -0.75, -0.75, -0.75], + [-0.75, -0.75, -0.75, -0.75], + [-0.75, -0.75, -0.75, -0.75], + [-0.75, -0.75, -0.75, -0.75], + ], + [ + [-0.25, -0.25, -0.25, -0.25], + [-0.25, -0.25, -0.25, -0.25], + [-0.25, -0.25, -0.25, -0.25], + [-0.25, -0.25, -0.25, -0.25], + ], + [ + [0.25, 0.25, 0.25, 0.25], + [0.25, 0.25, 0.25, 0.25], + [0.25, 0.25, 0.25, 0.25], + [0.25, 0.25, 0.25, 0.25], + ], + [ + [0.75, 0.75, 0.75, 0.75], + [0.75, 0.75, 0.75, 0.75], + [0.75, 0.75, 0.75, 0.75], + [0.75, 0.75, 0.75, 0.75], + ], + ], + dtype=np.float32, + ), + "y": np.array( + [ + [ + [-0.75, -0.75, -0.75, -0.75], + [-0.25, -0.25, -0.25, -0.25], + [0.25, 0.25, 0.25, 0.25], + [0.75, 0.75, 0.75, 0.75], + ], + [ + [-0.75, -0.75, -0.75, -0.75], + [-0.25, -0.25, -0.25, -0.25], + [0.25, 0.25, 0.25, 0.25], + [0.75, 0.75, 0.75, 0.75], ], - dtype=np.float32, - ), - "r": np.array( [ - [2.1213202, 1.5811388, 1.5811388, 2.1213202], - [1.5811388, 0.70710677, 0.70710677, 1.5811388], - [1.5811388, 0.70710677, 0.70710677, 1.5811388], - [2.1213202, 1.5811388, 1.5811388, 2.1213202], + [-0.75, -0.75, -0.75, -0.75], + [-0.25, -0.25, -0.25, -0.25], + [0.25, 0.25, 0.25, 0.25], + [0.75, 0.75, 0.75, 0.75], ], - dtype=np.float32, - ), - }, - (4, True, True): { - "x": np.array( [ [-0.75, -0.75, -0.75, -0.75], [-0.25, -0.25, -0.25, -0.25], [0.25, 0.25, 0.25, 0.25], [0.75, 0.75, 0.75, 0.75], ], - dtype=np.float32, - ), - "y": np.array( + ], + dtype=np.float32, + ), + "z": np.array( + [ + [ + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + ], + [ + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + ], + [ + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + [-0.75, -0.25, 0.25, 0.75], + ], [ [-0.75, -0.25, 0.25, 0.75], [-0.75, -0.25, 0.25, 0.75], [-0.75, -0.25, 0.25, 0.75], [-0.75, -0.25, 0.25, 0.75], ], - dtype=np.float32, - ), - "phi": np.array( + ], + dtype=np.float32, + ), + "phi": np.array( + [ [ - [-2.3561945, -2.819842, 2.819842, 2.3561945], - [-1.8925469, -2.3561945, 2.3561945, 1.8925469], - [-1.2490457, -0.7853982, 0.7853982, 1.2490457], - [-0.7853982, -0.32175055, 0.32175055, 0.7853982], + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [-2.819842, -2.819842, -2.819842, -2.819842], + [2.819842, 2.819842, 2.819842, 2.819842], + [2.3561945, 2.3561945, 2.3561945, 2.3561945], ], - dtype=np.float32, - ), - "r": np.array( [ - [1.0606601, 0.7905694, 0.7905694, 1.0606601], - [0.7905694, 0.35355338, 0.35355338, 0.7905694], - [0.7905694, 0.35355338, 0.35355338, 0.7905694], - [1.0606601, 0.7905694, 0.7905694, 1.0606601], + [-1.8925469, -1.8925469, -1.8925469, -1.8925469], + [-2.3561945, -2.3561945, -2.3561945, -2.3561945], + [2.3561945, 2.3561945, 2.3561945, 2.3561945], + [1.8925469, 1.8925469, 1.8925469, 1.8925469], ], - dtype=np.float32, - ), - }, - } + [ + [-1.2490457, -1.2490457, -1.2490457, -1.2490457], + [-0.7853982, -0.7853982, -0.7853982, -0.7853982], + [0.7853982, 0.7853982, 0.7853982, 0.7853982], + [1.2490457, 1.2490457, 1.2490457, 1.2490457], + ], + [ + [-0.7853982, -0.7853982, -0.7853982, -0.7853982], + [-0.32175055, -0.32175055, -0.32175055, -0.32175055], + [0.32175055, 0.32175055, 0.32175055, 0.32175055], + [0.7853982, 0.7853982, 0.7853982, 0.7853982], + ], + ], + dtype=np.float32, + ), + "theta": np.array( + [ + [ + [2.186276, 1.8022738, 1.339319, 0.95531666], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.186276, 1.8022738, 1.339319, 0.95531666], + ], + [ + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + ], + [ + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.701082, 2.186276, 0.95531666, 0.44051075], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + ], + [ + [2.186276, 1.8022738, 1.339319, 0.95531666], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.3298666, 1.8770738, 1.264519, 0.81172615], + [2.186276, 1.8022738, 1.339319, 0.95531666], + ], + ], + dtype=np.float32, + ), + "r": np.array( + [ + [ + [1.299038, 1.0897247, 1.0897247, 1.299038], + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + [1.299038, 1.0897247, 1.0897247, 1.299038], + ], + [ + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + [0.8291562, 0.4330127, 0.4330127, 0.8291562], + [0.8291562, 0.4330127, 0.4330127, 0.8291562], + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + ], + [ + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + [0.8291562, 0.4330127, 0.4330127, 0.8291562], + [0.8291562, 0.4330127, 0.4330127, 0.8291562], + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + ], + [ + [1.299038, 1.0897247, 1.0897247, 1.299038], + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + [1.0897248, 0.8291562, 0.8291562, 1.0897248], + [1.299038, 1.0897247, 1.0897247, 1.299038], + ], + ], + dtype=np.float32, + ), + }, + } - self.legacy_references_3d = { - (3, False, False): { - "x": np.array( - [ - [[-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0]], - [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], - [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945], - [-3.1415925, -3.1415925, -3.1415925], - [2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.5707964, -1.5707964, -1.5707964], - [-3.1415925, -3.1415925, -3.1415925], - [1.5707964, 1.5707964, 1.5707964], - ], - [ - [-0.7853982, -0.7853982, -0.7853982], - [-0.0, -0.0, -0.0], - [0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - [ - [2.3561945, 1.5707964, 0.7853982], - [3.1415927, 1.5707964, 0.0], - [2.3561945, 1.5707964, 0.7853982], - ], - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [1.7320508, 1.4142135, 1.7320508], - [1.4142135, 1.0, 1.4142135], - [1.7320508, 1.4142135, 1.7320508], - ], - [ - [1.4142135, 1.0, 1.4142135], - [1.0, 0.0, 1.0], - [1.4142135, 1.0, 1.4142135], - ], - [ - [1.7320508, 1.4142135, 1.7320508], - [1.4142135, 1.0, 1.4142135], - [1.7320508, 1.4142135, 1.7320508], - ], - ], - dtype=np.float32, - ), - }, - (3, False, True): { - "x": np.array( - [ - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.6666667, -0.6666667, -0.6666667], - [-0.6666667, -0.6666667, -0.6666667], - ], - [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], - [ - [0.6666667, 0.6666667, 0.6666667], - [0.6666667, 0.6666667, 0.6666667], - [0.6666667, 0.6666667, 0.6666667], - ], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.0, -0.0, -0.0], - [0.6666667, 0.6666667, 0.6666667], - ], - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.0, -0.0, -0.0], - [0.6666667, 0.6666667, 0.6666667], - ], - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.0, -0.0, -0.0], - [0.6666667, 0.6666667, 0.6666667], - ], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [ - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - ], - [ - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - ], - [ - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - ], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945], - [-3.1415925, -3.1415925, -3.1415925], - [2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.5707964, -1.5707964, -1.5707964], - [-3.1415925, -3.1415925, -3.1415925], - [1.5707964, 1.5707964, 1.5707964], - ], - [ - [-0.7853982, -0.7853982, -0.7853982], - [-0.0, -0.0, -0.0], - [0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - [ - [2.3561945, 1.5707964, 0.7853982], - [3.1415927, 1.5707964, 0.0], - [2.3561945, 1.5707964, 0.7853982], - ], - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [1.1547005, 0.94280905, 1.1547005], - [0.94280905, 0.6666667, 0.94280905], - [1.1547005, 0.94280905, 1.1547005], - ], - [ - [0.94280905, 0.6666667, 0.94280905], - [0.6666667, 0.0, 0.6666667], - [0.94280905, 0.6666667, 0.94280905], - ], - [ - [1.1547005, 0.94280905, 1.1547005], - [0.94280905, 0.6666667, 0.94280905], - [1.1547005, 0.94280905, 1.1547005], - ], - ], - dtype=np.float32, - ), - }, - (3, True, False): { - "x": np.array( - [ - [[-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0], [-1.0, -1.0, -1.0]], - [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], - [[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - [[-1.0, -1.0, -1.0], [-0.0, -0.0, -0.0], [1.0, 1.0, 1.0]], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - [[-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0], [-1.0, -0.0, 1.0]], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945], - [-3.1415925, -3.1415925, -3.1415925], - [2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.5707964, -1.5707964, -1.5707964], - [-3.1415925, -3.1415925, -3.1415925], - [1.5707964, 1.5707964, 1.5707964], - ], - [ - [-0.7853982, -0.7853982, -0.7853982], - [-0.0, -0.0, -0.0], - [0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - [ - [2.3561945, 1.5707964, 0.7853982], - [3.1415927, 1.5707964, 0.0], - [2.3561945, 1.5707964, 0.7853982], - ], - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [1.7320508, 1.4142135, 1.7320508], - [1.4142135, 1.0, 1.4142135], - [1.7320508, 1.4142135, 1.7320508], - ], - [ - [1.4142135, 1.0, 1.4142135], - [1.0, 0.0, 1.0], - [1.4142135, 1.0, 1.4142135], - ], - [ - [1.7320508, 1.4142135, 1.7320508], - [1.4142135, 1.0, 1.4142135], - [1.7320508, 1.4142135, 1.7320508], - ], - ], - dtype=np.float32, - ), - }, - (3, True, True): { - "x": np.array( - [ - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.6666667, -0.6666667, -0.6666667], - [-0.6666667, -0.6666667, -0.6666667], - ], - [[-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0], [-0.0, -0.0, -0.0]], - [ - [0.6666667, 0.6666667, 0.6666667], - [0.6666667, 0.6666667, 0.6666667], - [0.6666667, 0.6666667, 0.6666667], - ], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.0, -0.0, -0.0], - [0.6666667, 0.6666667, 0.6666667], - ], - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.0, -0.0, -0.0], - [0.6666667, 0.6666667, 0.6666667], - ], - [ - [-0.6666667, -0.6666667, -0.6666667], - [-0.0, -0.0, -0.0], - [0.6666667, 0.6666667, 0.6666667], - ], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [ - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - ], - [ - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - ], - [ - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - [-0.6666667, -0.0, 0.6666667], - ], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945], - [-3.1415925, -3.1415925, -3.1415925], - [2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.5707964, -1.5707964, -1.5707964], - [-3.1415925, -3.1415925, -3.1415925], - [1.5707964, 1.5707964, 1.5707964], - ], - [ - [-0.7853982, -0.7853982, -0.7853982], - [-0.0, -0.0, -0.0], - [0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - [ - [2.3561945, 1.5707964, 0.7853982], - [3.1415927, 1.5707964, 0.0], - [2.3561945, 1.5707964, 0.7853982], - ], - [ - [2.186276, 1.5707964, 0.95531666], - [2.3561945, 1.5707964, 0.7853982], - [2.186276, 1.5707964, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [1.1547005, 0.94280905, 1.1547005], - [0.94280905, 0.6666667, 0.94280905], - [1.1547005, 0.94280905, 1.1547005], - ], - [ - [0.94280905, 0.6666667, 0.94280905], - [0.6666667, 0.0, 0.6666667], - [0.94280905, 0.6666667, 0.94280905], - ], - [ - [1.1547005, 0.94280905, 1.1547005], - [0.94280905, 0.6666667, 0.94280905], - [1.1547005, 0.94280905, 1.1547005], - ], - ], - dtype=np.float32, - ), - }, - (4, False, False): { - "x": np.array( - [ - [ - [-2.0, -2.0, -2.0, -2.0], - [-2.0, -2.0, -2.0, -2.0], - [-2.0, -2.0, -2.0, -2.0], - [-2.0, -2.0, -2.0, -2.0], - ], - [ - [-1.0, -1.0, -1.0, -1.0], - [-1.0, -1.0, -1.0, -1.0], - [-1.0, -1.0, -1.0, -1.0], - [-1.0, -1.0, -1.0, -1.0], - ], - [ - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - ], - [ - [1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0], - [1.0, 1.0, 1.0, 1.0], - ], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [ - [-2.0, -2.0, -2.0, -2.0], - [-1.0, -1.0, -1.0, -1.0], - [0.0, 0.0, 0.0, 0.0], - [1.0, 1.0, 1.0, 1.0], - ], - [ - [-2.0, -2.0, -2.0, -2.0], - [-1.0, -1.0, -1.0, -1.0], - [0.0, 0.0, 0.0, 0.0], - [1.0, 1.0, 1.0, 1.0], - ], - [ - [-2.0, -2.0, -2.0, -2.0], - [-1.0, -1.0, -1.0, -1.0], - [0.0, 0.0, 0.0, 0.0], - [1.0, 1.0, 1.0, 1.0], - ], - [ - [-2.0, -2.0, -2.0, -2.0], - [-1.0, -1.0, -1.0, -1.0], - [0.0, 0.0, 0.0, 0.0], - [1.0, 1.0, 1.0, 1.0], - ], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [ - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - ], - [ - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - ], - [ - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - ], - [ - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - [-2.0, -1.0, 0.0, 1.0], - ], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [-2.6779451, -2.6779451, -2.6779451, -2.6779451], - [3.1415925, 3.1415925, 3.1415925, 3.1415925], - [2.6779451, 2.6779451, 2.6779451, 2.6779451], - ], - [ - [-2.0344439, -2.0344439, -2.0344439, -2.0344439], - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [3.1415925, 3.1415925, 3.1415925, 3.1415925], - [2.3561945, 2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.5707964, -1.5707964, -1.5707964, -1.5707964], - [-1.5707964, -1.5707964, -1.5707964, -1.5707964], - [0.0, 0.0, 0.0, 0.0], - [1.5707964, 1.5707964, 1.5707964, 1.5707964], - ], - [ - [-1.1071488, -1.1071488, -1.1071488, -1.1071488], - [-0.7853982, -0.7853982, -0.7853982, -0.7853982], - [0.0, 0.0, 0.0, 0.0], - [0.7853982, 0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.9106333, 1.5707964, 1.2309594], - [2.300524, 1.9913307, 1.5707964, 1.150262], - [2.3561945, 2.0344439, 1.5707964, 1.1071488], - [2.300524, 1.9913307, 1.5707964, 1.150262], - ], - [ - [2.300524, 1.9913307, 1.5707964, 1.150262], - [2.526113, 2.186276, 1.5707964, 0.95531666], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - [2.526113, 2.186276, 1.5707964, 0.95531666], - ], - [ - [2.3561945, 2.0344439, 1.5707964, 1.1071488], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - [3.1415927, 3.1415927, 1.5707964, 0.0], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - ], - [ - [2.300524, 1.9913307, 1.5707964, 1.150262], - [2.526113, 2.186276, 1.5707964, 0.95531666], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - [2.526113, 2.186276, 1.5707964, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [3.4641016, 3.0, 2.828427, 3.0], - [3.0, 2.4494898, 2.236068, 2.4494898], - [2.828427, 2.236068, 2.0, 2.236068], - [3.0, 2.4494898, 2.236068, 2.4494898], - ], - [ - [3.0, 2.4494898, 2.236068, 2.4494898], - [2.4494898, 1.7320508, 1.4142135, 1.7320508], - [2.236068, 1.4142135, 1.0, 1.4142135], - [2.4494898, 1.7320508, 1.4142135, 1.7320508], - ], - [ - [2.828427, 2.236068, 2.0, 2.236068], - [2.236068, 1.4142135, 1.0, 1.4142135], - [2.0, 1.0, 0.0, 1.0], - [2.236068, 1.4142135, 1.0, 1.4142135], - ], - [ - [3.0, 2.4494898, 2.236068, 2.4494898], - [2.4494898, 1.7320508, 1.4142135, 1.7320508], - [2.236068, 1.4142135, 1.0, 1.4142135], - [2.4494898, 1.7320508, 1.4142135, 1.7320508], - ], - ], - dtype=np.float32, - ), - }, - (4, False, True): { - "x": np.array( - [ - [ - [-1.0, -1.0, -1.0, -1.0], - [-1.0, -1.0, -1.0, -1.0], - [-1.0, -1.0, -1.0, -1.0], - [-1.0, -1.0, -1.0, -1.0], - ], - [ - [-0.5, -0.5, -0.5, -0.5], - [-0.5, -0.5, -0.5, -0.5], - [-0.5, -0.5, -0.5, -0.5], - [-0.5, -0.5, -0.5, -0.5], - ], - [ - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - [0.0, 0.0, 0.0, 0.0], - ], - [ - [0.5, 0.5, 0.5, 0.5], - [0.5, 0.5, 0.5, 0.5], - [0.5, 0.5, 0.5, 0.5], - [0.5, 0.5, 0.5, 0.5], - ], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [ - [-1.0, -1.0, -1.0, -1.0], - [-0.5, -0.5, -0.5, -0.5], - [0.0, 0.0, 0.0, 0.0], - [0.5, 0.5, 0.5, 0.5], - ], - [ - [-1.0, -1.0, -1.0, -1.0], - [-0.5, -0.5, -0.5, -0.5], - [0.0, 0.0, 0.0, 0.0], - [0.5, 0.5, 0.5, 0.5], - ], - [ - [-1.0, -1.0, -1.0, -1.0], - [-0.5, -0.5, -0.5, -0.5], - [0.0, 0.0, 0.0, 0.0], - [0.5, 0.5, 0.5, 0.5], - ], - [ - [-1.0, -1.0, -1.0, -1.0], - [-0.5, -0.5, -0.5, -0.5], - [0.0, 0.0, 0.0, 0.0], - [0.5, 0.5, 0.5, 0.5], - ], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [ - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - ], - [ - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - ], - [ - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - ], - [ - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - [-1.0, -0.5, 0.0, 0.5], - ], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [-2.6779451, -2.6779451, -2.6779451, -2.6779451], - [3.1415925, 3.1415925, 3.1415925, 3.1415925], - [2.6779451, 2.6779451, 2.6779451, 2.6779451], - ], - [ - [-2.0344439, -2.0344439, -2.0344439, -2.0344439], - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [3.1415925, 3.1415925, 3.1415925, 3.1415925], - [2.3561945, 2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.5707964, -1.5707964, -1.5707964, -1.5707964], - [-1.5707964, -1.5707964, -1.5707964, -1.5707964], - [0.0, 0.0, 0.0, 0.0], - [1.5707964, 1.5707964, 1.5707964, 1.5707964], - ], - [ - [-1.1071488, -1.1071488, -1.1071488, -1.1071488], - [-0.7853982, -0.7853982, -0.7853982, -0.7853982], - [0.0, 0.0, 0.0, 0.0], - [0.7853982, 0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.9106333, 1.5707964, 1.2309594], - [2.300524, 1.9913307, 1.5707964, 1.150262], - [2.3561945, 2.0344439, 1.5707964, 1.1071488], - [2.300524, 1.9913307, 1.5707964, 1.150262], - ], - [ - [2.300524, 1.9913307, 1.5707964, 1.150262], - [2.526113, 2.186276, 1.5707964, 0.95531666], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - [2.526113, 2.186276, 1.5707964, 0.95531666], - ], - [ - [2.3561945, 2.0344439, 1.5707964, 1.1071488], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - [3.1415927, 3.1415927, 1.5707964, 0.0], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - ], - [ - [2.300524, 1.9913307, 1.5707964, 1.150262], - [2.526113, 2.186276, 1.5707964, 0.95531666], - [2.6779451, 2.3561945, 1.5707964, 0.7853982], - [2.526113, 2.186276, 1.5707964, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [1.7320508, 1.5, 1.4142135, 1.5], - [1.5, 1.2247449, 1.118034, 1.2247449], - [1.4142135, 1.118034, 1.0, 1.118034], - [1.5, 1.2247449, 1.118034, 1.2247449], - ], - [ - [1.5, 1.2247449, 1.118034, 1.2247449], - [1.2247449, 0.8660254, 0.70710677, 0.8660254], - [1.118034, 0.70710677, 0.5, 0.70710677], - [1.2247449, 0.8660254, 0.70710677, 0.8660254], - ], - [ - [1.4142135, 1.118034, 1.0, 1.118034], - [1.118034, 0.70710677, 0.5, 0.70710677], - [1.0, 0.5, 0.0, 0.5], - [1.118034, 0.70710677, 0.5, 0.70710677], - ], - [ - [1.5, 1.2247449, 1.118034, 1.2247449], - [1.2247449, 0.8660254, 0.70710677, 0.8660254], - [1.118034, 0.70710677, 0.5, 0.70710677], - [1.2247449, 0.8660254, 0.70710677, 0.8660254], - ], - ], - dtype=np.float32, - ), - }, - (4, True, False): { - "x": np.array( - [ - [ - [-1.5, -1.5, -1.5, -1.5], - [-1.5, -1.5, -1.5, -1.5], - [-1.5, -1.5, -1.5, -1.5], - [-1.5, -1.5, -1.5, -1.5], - ], - [ - [-0.5, -0.5, -0.5, -0.5], - [-0.5, -0.5, -0.5, -0.5], - [-0.5, -0.5, -0.5, -0.5], - [-0.5, -0.5, -0.5, -0.5], - ], - [ - [0.5, 0.5, 0.5, 0.5], - [0.5, 0.5, 0.5, 0.5], - [0.5, 0.5, 0.5, 0.5], - [0.5, 0.5, 0.5, 0.5], - ], - [ - [1.5, 1.5, 1.5, 1.5], - [1.5, 1.5, 1.5, 1.5], - [1.5, 1.5, 1.5, 1.5], - [1.5, 1.5, 1.5, 1.5], - ], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [ - [-1.5, -1.5, -1.5, -1.5], - [-0.5, -0.5, -0.5, -0.5], - [0.5, 0.5, 0.5, 0.5], - [1.5, 1.5, 1.5, 1.5], - ], - [ - [-1.5, -1.5, -1.5, -1.5], - [-0.5, -0.5, -0.5, -0.5], - [0.5, 0.5, 0.5, 0.5], - [1.5, 1.5, 1.5, 1.5], - ], - [ - [-1.5, -1.5, -1.5, -1.5], - [-0.5, -0.5, -0.5, -0.5], - [0.5, 0.5, 0.5, 0.5], - [1.5, 1.5, 1.5, 1.5], - ], - [ - [-1.5, -1.5, -1.5, -1.5], - [-0.5, -0.5, -0.5, -0.5], - [0.5, 0.5, 0.5, 0.5], - [1.5, 1.5, 1.5, 1.5], - ], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [ - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - ], - [ - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - ], - [ - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - ], - [ - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - [-1.5, -0.5, 0.5, 1.5], - ], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [-2.819842, -2.819842, -2.819842, -2.819842], - [2.819842, 2.819842, 2.819842, 2.819842], - [2.3561945, 2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.8925469, -1.8925469, -1.8925469, -1.8925469], - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [2.3561945, 2.3561945, 2.3561945, 2.3561945], - [1.8925469, 1.8925469, 1.8925469, 1.8925469], - ], - [ - [-1.2490457, -1.2490457, -1.2490457, -1.2490457], - [-0.7853982, -0.7853982, -0.7853982, -0.7853982], - [0.7853982, 0.7853982, 0.7853982, 0.7853982], - [1.2490457, 1.2490457, 1.2490457, 1.2490457], - ], - [ - [-0.7853982, -0.7853982, -0.7853982, -0.7853982], - [-0.32175055, -0.32175055, -0.32175055, -0.32175055], - [0.32175055, 0.32175055, 0.32175055, 0.32175055], - [0.7853982, 0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.8022738, 1.339319, 0.95531666], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.186276, 1.8022738, 1.339319, 0.95531666], - ], - [ - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - ], - [ - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - ], - [ - [2.186276, 1.8022738, 1.339319, 0.95531666], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.186276, 1.8022738, 1.339319, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [2.598076, 2.1794493, 2.1794493, 2.598076], - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - [2.598076, 2.1794493, 2.1794493, 2.598076], - ], - [ - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - [1.6583124, 0.8660254, 0.8660254, 1.6583124], - [1.6583124, 0.8660254, 0.8660254, 1.6583124], - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - ], - [ - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - [1.6583124, 0.8660254, 0.8660254, 1.6583124], - [1.6583124, 0.8660254, 0.8660254, 1.6583124], - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - ], - [ - [2.598076, 2.1794493, 2.1794493, 2.598076], - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - [2.1794496, 1.6583124, 1.6583124, 2.1794496], - [2.598076, 2.1794493, 2.1794493, 2.598076], - ], - ], - dtype=np.float32, - ), - }, - (4, True, True): { - "x": np.array( - [ - [ - [-0.75, -0.75, -0.75, -0.75], - [-0.75, -0.75, -0.75, -0.75], - [-0.75, -0.75, -0.75, -0.75], - [-0.75, -0.75, -0.75, -0.75], - ], - [ - [-0.25, -0.25, -0.25, -0.25], - [-0.25, -0.25, -0.25, -0.25], - [-0.25, -0.25, -0.25, -0.25], - [-0.25, -0.25, -0.25, -0.25], - ], - [ - [0.25, 0.25, 0.25, 0.25], - [0.25, 0.25, 0.25, 0.25], - [0.25, 0.25, 0.25, 0.25], - [0.25, 0.25, 0.25, 0.25], - ], - [ - [0.75, 0.75, 0.75, 0.75], - [0.75, 0.75, 0.75, 0.75], - [0.75, 0.75, 0.75, 0.75], - [0.75, 0.75, 0.75, 0.75], - ], - ], - dtype=np.float32, - ), - "y": np.array( - [ - [ - [-0.75, -0.75, -0.75, -0.75], - [-0.25, -0.25, -0.25, -0.25], - [0.25, 0.25, 0.25, 0.25], - [0.75, 0.75, 0.75, 0.75], - ], - [ - [-0.75, -0.75, -0.75, -0.75], - [-0.25, -0.25, -0.25, -0.25], - [0.25, 0.25, 0.25, 0.25], - [0.75, 0.75, 0.75, 0.75], - ], - [ - [-0.75, -0.75, -0.75, -0.75], - [-0.25, -0.25, -0.25, -0.25], - [0.25, 0.25, 0.25, 0.25], - [0.75, 0.75, 0.75, 0.75], - ], - [ - [-0.75, -0.75, -0.75, -0.75], - [-0.25, -0.25, -0.25, -0.25], - [0.25, 0.25, 0.25, 0.25], - [0.75, 0.75, 0.75, 0.75], - ], - ], - dtype=np.float32, - ), - "z": np.array( - [ - [ - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - ], - [ - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - ], - [ - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - ], - [ - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - [-0.75, -0.25, 0.25, 0.75], - ], - ], - dtype=np.float32, - ), - "phi": np.array( - [ - [ - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [-2.819842, -2.819842, -2.819842, -2.819842], - [2.819842, 2.819842, 2.819842, 2.819842], - [2.3561945, 2.3561945, 2.3561945, 2.3561945], - ], - [ - [-1.8925469, -1.8925469, -1.8925469, -1.8925469], - [-2.3561945, -2.3561945, -2.3561945, -2.3561945], - [2.3561945, 2.3561945, 2.3561945, 2.3561945], - [1.8925469, 1.8925469, 1.8925469, 1.8925469], - ], - [ - [-1.2490457, -1.2490457, -1.2490457, -1.2490457], - [-0.7853982, -0.7853982, -0.7853982, -0.7853982], - [0.7853982, 0.7853982, 0.7853982, 0.7853982], - [1.2490457, 1.2490457, 1.2490457, 1.2490457], - ], - [ - [-0.7853982, -0.7853982, -0.7853982, -0.7853982], - [-0.32175055, -0.32175055, -0.32175055, -0.32175055], - [0.32175055, 0.32175055, 0.32175055, 0.32175055], - [0.7853982, 0.7853982, 0.7853982, 0.7853982], - ], - ], - dtype=np.float32, - ), - "theta": np.array( - [ - [ - [2.186276, 1.8022738, 1.339319, 0.95531666], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.186276, 1.8022738, 1.339319, 0.95531666], - ], - [ - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - ], - [ - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.701082, 2.186276, 0.95531666, 0.44051075], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - ], - [ - [2.186276, 1.8022738, 1.339319, 0.95531666], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.3298666, 1.8770738, 1.264519, 0.81172615], - [2.186276, 1.8022738, 1.339319, 0.95531666], - ], - ], - dtype=np.float32, - ), - "r": np.array( - [ - [ - [1.299038, 1.0897247, 1.0897247, 1.299038], - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - [1.299038, 1.0897247, 1.0897247, 1.299038], - ], - [ - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - [0.8291562, 0.4330127, 0.4330127, 0.8291562], - [0.8291562, 0.4330127, 0.4330127, 0.8291562], - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - ], - [ - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - [0.8291562, 0.4330127, 0.4330127, 0.8291562], - [0.8291562, 0.4330127, 0.4330127, 0.8291562], - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - ], - [ - [1.299038, 1.0897247, 1.0897247, 1.299038], - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - [1.0897248, 0.8291562, 0.8291562, 1.0897248], - [1.299038, 1.0897247, 1.0897247, 1.299038], - ], - ], - dtype=np.float32, - ), - }, - } + def setUp(self): + # Keys are of form (n,shift,normalized) + self.ns = [3, 4] + self.shifts = [False, True] + self.norms = [False, True] def test_grid_2d(self): for k in product(self.ns, self.shifts, self.norms): @@ -1430,3 +1430,24 @@ def test_grid_3d(self): np.testing.assert_allclose(a, b, atol=utest_tolerance(np.float32)) else: np.testing.assert_allclose(a, b, atol=utest_tolerance(np.float32)) + + +def test_rectangular_2d(): + """ + Sanity check 2d rectangular grid. + """ + opts = (False, True) # shifted, normalized + rows, cols = 3, 4 + + # Get square case references + g2d_3 = LegacyGridsTestCase.legacy_references_2d[(rows, *opts)] + g2d_4 = LegacyGridsTestCase.legacy_references_2d[(cols, *opts)] + + # Create a rectangular grid + g = grid_2d((rows, cols), indexing="xy") # xy to match leg references + np.testing.assert_equal(g["r"].shape, (rows, cols)) + + # Check + # Take the first column and row from references, tile to rect shape + np.testing.assert_allclose(g["x"], np.tile(g2d_3["x"][:, 0:1], (1, cols))) + np.testing.assert_allclose(g["y"], np.tile(g2d_4["y"][0:1, :], (rows, 1))) From ff05390e82ff0c212368e069107f0fdda8da97f8 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Fri, 20 Jun 2025 15:24:14 -0400 Subject: [PATCH 3/7] add draft of `phase_flip` to `MicrographSource` [skip ci] --- src/aspire/source/micrograph.py | 46 +++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/aspire/source/micrograph.py b/src/aspire/source/micrograph.py index e005e8910c..1ae6e11b37 100644 --- a/src/aspire/source/micrograph.py +++ b/src/aspire/source/micrograph.py @@ -11,7 +11,13 @@ from aspire.source import Simulation from aspire.source.image import _ImageAccessor from aspire.storage import StarFile -from aspire.utils import Random, check_pixel_size, grid_2d, rename_with_timestamp +from aspire.utils import ( + Random, + check_pixel_size, + grid_2d, + rename_with_timestamp, + trange, +) from aspire.volume import Volume logger = logging.getLogger(__name__) @@ -121,6 +127,42 @@ def _images(self, indices): :return: An `Image` object representing the micrographs for `indices`. """ + def phase_flip(self, filters): + """ + Perform phase flip on micrographs in the source object using CTF information. + If no CTFFilters exist this will emit a warning and otherwise no-op. + """ + + logger.info("Perform phase flip on source object") + filters = list(filters) # unpack any generators + + if len(filters) >= 1: + assert len(filters) == self.micrograph_count + + logger.info("Phaseflipping") + phase_flipped_micrographs = np.empty( + (self.micrograph_count, *self.micrograph_size), dtype=self.dtype + ) + for i in trange(self.micrograph_count, desc=f"Phaseflipping micrograph"): + # micrograph = self.images[i] + # f = filters[i].sign + # ... = micrograph.filter(f) + phase_flipped_micrographs[i] = self.images[i].filter(filters[i].sign) + + return ArrayMicrographSource( + micrographs=phase_flipped_micrographs, pixel_size=self.pixel_size + ) + + else: + # No CTF filters found + logger.warning( + "No Filters found." + " `phase_flip` is a no-op without Filters." + " Confirm you have correctly populated CTFFilters." + ) + + return self + class ArrayMicrographSource(MicrographSource): def __init__(self, micrographs, dtype=None, pixel_size=None): @@ -287,7 +329,7 @@ def _images(self, indices): # Continually compare with initial pixel_size if _pixel_size is not None and _pixel_size != self.pixel_size: - msg = f"Mismatched pixel size. {micrograph.pixel_size} angstroms defined in {self.micrograph_files[ind]}, but provided {self.pixel_size} angstroms." + msg = f"Mismatched pixel size. {_pixel_size} angstroms defined in {self.micrograph_files[ind]}, but provided {self.pixel_size} angstroms." warnings.warn(msg, UserWarning, stacklevel=2) # Assign to array, implicitly performs casting to dtype From 139dce7688b4558e8e9607ae759bdd2841866f64 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 25 Sep 2025 15:45:39 -0400 Subject: [PATCH 4/7] the joy of rebasing --- src/aspire/image/image.py | 3 ++- tests/test_filters.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/aspire/image/image.py b/src/aspire/image/image.py index 65bbe0e254..5c8d95f24a 100644 --- a/src/aspire/image/image.py +++ b/src/aspire/image/image.py @@ -630,7 +630,8 @@ def filter(self, filter): # Second note, filter and grid dtype may not match image dtype, # upcast both here for most accurate convolution. filter_values = xp.asarray( - filter.evaluate_grid(self.shape[-2:]), dtype=self.dtype, pixel_size=self.pixel_size + filter.evaluate_grid(self.shape[-2:], pixel_size=self.pixel_size), + dtype=np.float64, ) # sanity check diff --git a/tests/test_filters.py b/tests/test_filters.py index c9f16ece34..51eb8d915e 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -247,6 +247,7 @@ def test_ctf_reference(): # Test match all significant digits above np.testing.assert_allclose(h, ref_h, atol=5e-5) + def test_rectangular_ctf(): """ Compare a truncated rectangular CTF application with the @@ -282,4 +283,3 @@ def test_rectangular_ctf(): np.testing.assert_allclose( truncated_img_with_ctf * mask, full_img_with_ctf_truncated * mask, atol=1e-6 ) - From 32ddaf6cf1641f1dfb09806d17361a9d4c986afe Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 16 Oct 2025 09:29:35 -0400 Subject: [PATCH 5/7] minor dtype regression --- src/aspire/image/image.py | 4 +++- tests/test_filters.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/aspire/image/image.py b/src/aspire/image/image.py index 5c8d95f24a..4749adb093 100644 --- a/src/aspire/image/image.py +++ b/src/aspire/image/image.py @@ -630,7 +630,9 @@ def filter(self, filter): # Second note, filter and grid dtype may not match image dtype, # upcast both here for most accurate convolution. filter_values = xp.asarray( - filter.evaluate_grid(self.shape[-2:], pixel_size=self.pixel_size), + filter.evaluate_grid( + self.shape[-2:], dtype=np.float64, pixel_size=self.pixel_size + ), dtype=np.float64, ) diff --git a/tests/test_filters.py b/tests/test_filters.py index 51eb8d915e..fd86a679c3 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -262,11 +262,11 @@ def test_rectangular_ctf(): # A = gaussian_2d(size=L, mu=(0,-L//10), sigma=L//8, dtype=np.float64) A = gaussian_2d(size=L, mu=(0, -L // 10), sigma=L // 32, dtype=np.float64) - full_img = Image(A) - truncated_img = Image(A[:rows, :cols]) + full_img = Image(A, pixel_size=2) + truncated_img = Image(A[:rows, :cols], pixel_size=2) # Create a CTFFilter - ctf_filter = CTFFilter(pixel_size=2) + ctf_filter = CTFFilter() # Apply to both Image instances full_img_with_ctf = full_img.filter(ctf_filter) From 6d89b02ae3780a878f65fee9d58e0848a8941460 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 16 Oct 2025 10:12:28 -0400 Subject: [PATCH 6/7] tox --- src/aspire/source/micrograph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aspire/source/micrograph.py b/src/aspire/source/micrograph.py index 1ae6e11b37..87eec8271e 100644 --- a/src/aspire/source/micrograph.py +++ b/src/aspire/source/micrograph.py @@ -143,7 +143,7 @@ def phase_flip(self, filters): phase_flipped_micrographs = np.empty( (self.micrograph_count, *self.micrograph_size), dtype=self.dtype ) - for i in trange(self.micrograph_count, desc=f"Phaseflipping micrograph"): + for i in trange(self.micrograph_count, desc="Phaseflipping micrograph"): # micrograph = self.images[i] # f = filters[i].sign # ... = micrograph.filter(f) From f6b0c877df7eab35a1776fb1b947e4032a56a429 Mon Sep 17 00:00:00 2001 From: Garrett Wright Date: Thu, 16 Oct 2025 15:24:46 -0400 Subject: [PATCH 7/7] docstring update --- src/aspire/operators/filters.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aspire/operators/filters.py b/src/aspire/operators/filters.py index 3c3f362fc3..6e3be25aad 100644 --- a/src/aspire/operators/filters.py +++ b/src/aspire/operators/filters.py @@ -121,7 +121,8 @@ def evaluate_grid(self, L, *args, dtype=np.float32, **kwargs): Passes arbritrary args and kwargs down to self.evaluate method. - :param L: Number of grid points (L by L). + :param L: Number of grid points. + L-by-L given a single `L`, or (L0, L1) if L is length 2. :param dtype: dtype of grid, defaults np.float32. :return: Filter values at omega's points. """