From dcd9ca8a020ce8bff29bc3bbaff51f0695985a99 Mon Sep 17 00:00:00 2001 From: Patrick Roddy Date: Fri, 29 Sep 2023 12:10:19 +0100 Subject: [PATCH] Replace `ssht.sample_positions` & `MWSS` -> `mwss` (#221) --- .../arbitrary/_slepian_wavelet_covariance.py | 4 +- examples/misc/_denoising_axisym.py | 4 +- examples/misc/translation_normalisation.py | 5 +- examples/polar_cap/slepian_error.py | 4 +- .../axisymmetric_wavelet_covariance.py | 4 +- src/sleplet/_integration_methods.py | 20 +++++-- src/sleplet/_mask_methods.py | 56 +++++++++++++------ src/sleplet/_vars.py | 2 +- src/sleplet/functions/africa.py | 2 +- src/sleplet/functions/slepian_dirac_delta.py | 32 +++++++++-- src/sleplet/functions/south_america.py | 2 +- src/sleplet/harmonic_methods.py | 22 ++++++-- src/sleplet/noise.py | 6 +- src/sleplet/plot_methods.py | 12 ++-- src/sleplet/plotting/_create_plot_sphere.py | 27 ++++++++- src/sleplet/slepian/_slepian_decomposition.py | 4 +- src/sleplet/slepian_methods.py | 8 +-- tests/test_decomposition.py | 8 +-- tests/test_harmonic.py | 5 +- tests/test_translation.py | 39 +++++++++---- 20 files changed, 185 insertions(+), 81 deletions(-) diff --git a/examples/arbitrary/_slepian_wavelet_covariance.py b/examples/arbitrary/_slepian_wavelet_covariance.py index cf5fef8e8..e0f46e489 100644 --- a/examples/arbitrary/_slepian_wavelet_covariance.py +++ b/examples/arbitrary/_slepian_wavelet_covariance.py @@ -5,7 +5,7 @@ import sleplet -SAMPLING_SCHEME = "MWSS" +SAMPLING_SCHEME = "mwss" def compute_slepian_wavelet_covariance( @@ -29,7 +29,7 @@ def compute_slepian_wavelet_covariance( covariance.shape[0], ) np.testing.assert_equal( - ssht.sample_shape(slepian_wavelets.L, Method=SAMPLING_SCHEME), + ssht.sample_shape(slepian_wavelets.L, Method=SAMPLING_SCHEME.upper()), covariance.shape[1:], ) return covariance diff --git a/examples/misc/_denoising_axisym.py b/examples/misc/_denoising_axisym.py index 210f0e255..735ebfc3c 100644 --- a/examples/misc/_denoising_axisym.py +++ b/examples/misc/_denoising_axisym.py @@ -5,7 +5,7 @@ import sleplet -SAMPLING_SCHEME = "MWSS" +SAMPLING_SCHEME = "mwss" def denoising_axisym( # noqa: PLR0913 @@ -60,5 +60,5 @@ def denoising_axisym( # noqa: PLR0913 else flm ) - f = ssht.inverse(flm, signal.L, Method=SAMPLING_SCHEME) + f = ssht.inverse(flm, signal.L, Method=SAMPLING_SCHEME.upper()) return f, noised_signal.snr, denoised_snr diff --git a/examples/misc/translation_normalisation.py b/examples/misc/translation_normalisation.py index b43d76df6..5db26027e 100644 --- a/examples/misc/translation_normalisation.py +++ b/examples/misc/translation_normalisation.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt import numpy as np +import s2fft import seaborn as sns import pyssht as ssht @@ -10,13 +11,13 @@ ALPHA_DEFAULT = 0.75 L = 128 -SAMPLING_SCHEME = "MWSS" +SAMPLING_SCHEME = "mwss" def compute_translation_normalisation_theta() -> None: """Analysis of the translation norm for referee.""" hg = sleplet.functions.HarmonicGaussian(L) - thetas, _ = ssht.sample_positions(L, Method=SAMPLING_SCHEME) + thetas = s2fft.samples.thetas(L, sampling=SAMPLING_SCHEME) norm = np.zeros(len(thetas)) for i, theta in enumerate(thetas): print(f"compute norm {i+1}/{len(thetas)}") diff --git a/examples/polar_cap/slepian_error.py b/examples/polar_cap/slepian_error.py index 9371ee401..b3a694fd1 100644 --- a/examples/polar_cap/slepian_error.py +++ b/examples/polar_cap/slepian_error.py @@ -10,7 +10,7 @@ sns.set(context="paper") L = 16 -SAMPLING_SCHEME = "MWSS" +SAMPLING_SCHEME = "mwss" THETA_MAX = 40 @@ -18,7 +18,7 @@ def main() -> None: """Creates a plot of Slepian coefficients against rank.""" region = sleplet.slepian.Region(theta_max=np.deg2rad(THETA_MAX)) earth = sleplet.functions.Earth(L, region=region) - field = ssht.inverse(earth.coefficients, L, Method=SAMPLING_SCHEME) + field = ssht.inverse(earth.coefficients, L, Method=SAMPLING_SCHEME.upper()) integrate_region = _helper_region(L, region, field, earth.coefficients) integrate_sphere = _helper_sphere(L, region, field, earth.coefficients) N = sleplet.slepian.SlepianPolarCap(L, np.deg2rad(THETA_MAX)).N diff --git a/examples/wavelets/axisymmetric_wavelet_covariance.py b/examples/wavelets/axisymmetric_wavelet_covariance.py index bbfa0a252..46e89f98c 100644 --- a/examples/wavelets/axisymmetric_wavelet_covariance.py +++ b/examples/wavelets/axisymmetric_wavelet_covariance.py @@ -9,7 +9,7 @@ J_MIN = 2 L = 128 RANDOM_SEED = 30 -SAMPLING_SCHEME = "MWSS" +SAMPLING_SCHEME = "mwss" def _compute_wavelet_covariance( @@ -83,7 +83,7 @@ def axisymmetric_wavelet_covariance( # compute covariance from data for j, coefficient in enumerate(wlm): - f_wav_j = ssht.inverse(coefficient, L, Method=SAMPLING_SCHEME) + f_wav_j = ssht.inverse(coefficient, L, Method=SAMPLING_SCHEME.upper()) covar_data[i, j] = ( f_wav_j.var() if _is_ergodic(j_min, j=j) else f_wav_j[0, 0] ) diff --git a/src/sleplet/_integration_methods.py b/src/sleplet/_integration_methods.py index fae0e8402..9a70cd549 100644 --- a/src/sleplet/_integration_methods.py +++ b/src/sleplet/_integration_methods.py @@ -3,18 +3,26 @@ import numpy as np import numpy.typing as npt - -import pyssht as ssht +import s2fft import sleplet._vars def calc_integration_weight(L: int) -> npt.NDArray[np.float_]: """Computes the spherical Jacobian for the integration.""" - thetas, phis = ssht.sample_positions( - L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, + thetas = np.tile( + s2fft.samples.thetas(L, sampling=sleplet._vars.SAMPLING_SCHEME), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T + phis = np.tile( + s2fft.samples.phis_equiang(L, sampling=sleplet._vars.SAMPLING_SCHEME), + (s2fft.samples.ntheta(L, sampling=sleplet._vars.SAMPLING_SCHEME), 1), ) delta_theta = np.ediff1d(thetas[:, 0]).mean() delta_phi = np.ediff1d(phis[0]).mean() diff --git a/src/sleplet/_mask_methods.py b/src/sleplet/_mask_methods.py index 9de1159c4..1e224da9f 100644 --- a/src/sleplet/_mask_methods.py +++ b/src/sleplet/_mask_methods.py @@ -4,6 +4,7 @@ import numpy as np import numpy.typing as npt import platformdirs +import s2fft import pyssht as ssht @@ -32,10 +33,19 @@ def create_mask_region( phi_min or phi_max is provided * arbitrary - just checks the shape of the input mask. """ - thetas, phis = ssht.sample_positions( - L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, + thetas = np.tile( + s2fft.samples.thetas(L, sampling=sleplet._vars.SAMPLING_SCHEME), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T + phis = np.tile( + s2fft.samples.phis_equiang(L, sampling=sleplet._vars.SAMPLING_SCHEME), + (s2fft.samples.ntheta(L, sampling=sleplet._vars.SAMPLING_SCHEME), 1), ) match region.region_type: @@ -88,7 +98,7 @@ def ensure_masked_flm_bandlimited( L, Reality=reality, Spin=spin, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) mask = create_mask_region(L, region) field = np.where(mask, field, 0) @@ -97,7 +107,7 @@ def ensure_masked_flm_bandlimited( L, Reality=reality, Spin=spin, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) @@ -159,13 +169,18 @@ def _create_africa_mask( rot_flm, L, Reality=True, - Method=sleplet._vars.SAMPLING_SCHEME, - ) - thetas, _ = ssht.sample_positions( - L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) + thetas = np.tile( + s2fft.samples.thetas(L, sampling=sleplet._vars.SAMPLING_SCHEME), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T return (thetas <= _AFRICA_RANGE) & (earth_f >= 0) @@ -179,13 +194,18 @@ def _create_south_america_mask( rot_flm, L, Reality=True, - Method=sleplet._vars.SAMPLING_SCHEME, - ) - thetas, _ = ssht.sample_positions( - L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) + thetas = np.tile( + s2fft.samples.thetas(L, sampling=sleplet._vars.SAMPLING_SCHEME), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T return (thetas <= _SOUTH_AMERICA_RANGE) & (earth_f >= 0) diff --git a/src/sleplet/_vars.py b/src/sleplet/_vars.py index 72feb92c7..f4df05a78 100644 --- a/src/sleplet/_vars.py +++ b/src/sleplet/_vars.py @@ -4,7 +4,7 @@ PHI_MAX_DEFAULT = 2 * np.pi PHI_MIN_DEFAULT = 0.0 RANDOM_SEED = 30 -SAMPLING_SCHEME = "MWSS" +SAMPLING_SCHEME = "mwss" SPHERE_UNSEEN = -1.56e30 THETA_0 = 0.0 THETA_MAX_DEFAULT = np.pi diff --git a/src/sleplet/functions/africa.py b/src/sleplet/functions/africa.py index 3df0f490b..50829c525 100644 --- a/src/sleplet/functions/africa.py +++ b/src/sleplet/functions/africa.py @@ -65,7 +65,7 @@ def _grid_fun( rot_flm, self.L, Reality=self.reality, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) mask_name = f"{self.name}_L{self.L}.npy" mask_location = sleplet._data.setup_pooch.find_on_pooch_then_local( diff --git a/src/sleplet/functions/slepian_dirac_delta.py b/src/sleplet/functions/slepian_dirac_delta.py index 9a5bc7eb5..fc81c0f33 100644 --- a/src/sleplet/functions/slepian_dirac_delta.py +++ b/src/sleplet/functions/slepian_dirac_delta.py @@ -4,6 +4,7 @@ import numpy as np import numpy.typing as npt import pydantic.v1 as pydantic +import s2fft import pyssht as ssht @@ -52,15 +53,36 @@ def _setup_args(self) -> None: def _compute_angles(self) -> None: """Computes alpha/beta if not provided.""" - thetas, phis = ssht.sample_positions( - self.L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, + thetas = np.tile( + s2fft.samples.thetas( + self.L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + ( + s2fft.samples.nphi_equiang( + self.L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T + phis = np.tile( + s2fft.samples.phis_equiang( + self.L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + ( + s2fft.samples.ntheta( + self.L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), ) sp = ssht.inverse( self.slepian.eigenvectors[0], self.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) idx = tuple(np.argwhere(sp == sp.max())[0]) self._alpha = phis[idx] diff --git a/src/sleplet/functions/south_america.py b/src/sleplet/functions/south_america.py index afbfd528c..c35dbd4a2 100644 --- a/src/sleplet/functions/south_america.py +++ b/src/sleplet/functions/south_america.py @@ -65,7 +65,7 @@ def _grid_fun( rot_flm, self.L, Reality=self.reality, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) mask_name = f"{self.name}_L{self.L}.npy" mask_location = sleplet._data.setup_pooch.find_on_pooch_then_local( diff --git a/src/sleplet/harmonic_methods.py b/src/sleplet/harmonic_methods.py index 90da9be30..62f4cea15 100644 --- a/src/sleplet/harmonic_methods.py +++ b/src/sleplet/harmonic_methods.py @@ -4,6 +4,7 @@ import numpy as np import numpy.typing as npt +import s2fft import pyssht as ssht @@ -63,7 +64,7 @@ def invert_flm_boosted( resolution, Reality=reality, Spin=spin, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) @@ -81,10 +82,19 @@ def _ensure_f_bandlimited( If the function created is created in pixel space rather than harmonic space then need to transform it into harmonic space first before using it. """ - thetas, phis = ssht.sample_positions( - L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, + thetas = np.tile( + s2fft.samples.thetas(L, sampling=sleplet._vars.SAMPLING_SCHEME), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T + phis = np.tile( + s2fft.samples.phis_equiang(L, sampling=sleplet._vars.SAMPLING_SCHEME), + (s2fft.samples.ntheta(L, sampling=sleplet._vars.SAMPLING_SCHEME), 1), ) f = grid_fun(thetas, phis) return ssht.forward( @@ -92,7 +102,7 @@ def _ensure_f_bandlimited( L, Reality=reality, Spin=spin, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) diff --git a/src/sleplet/noise.py b/src/sleplet/noise.py index 7e3fbc9ae..1d9a6106d 100644 --- a/src/sleplet/noise.py +++ b/src/sleplet/noise.py @@ -104,7 +104,7 @@ def _create_slepian_noise( flm = ssht.forward( sleplet.slepian_methods.slepian_inverse(slepian_signal, L, slepian), L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) nlm = _create_noise(L, flm, snr_in) return sleplet.slepian_methods.slepian_forward(L, slepian, flm=nlm) @@ -141,12 +141,12 @@ def harmonic_hard_thresholding( _logger.info("begin harmonic hard thresholding") for j, coefficient in enumerate(wav_coeffs[1:]): _logger.info(f"start Psi^{j + 1}/{len(wav_coeffs)-1}") - f = ssht.inverse(coefficient, L, Method=sleplet._vars.SAMPLING_SCHEME) + f = ssht.inverse(coefficient, L, Method=sleplet._vars.SAMPLING_SCHEME.upper()) f_thresholded = _perform_hard_thresholding(f, sigma_j[j], n_sigma) wav_coeffs[j + 1] = ssht.forward( f_thresholded, L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) return wav_coeffs diff --git a/src/sleplet/plot_methods.py b/src/sleplet/plot_methods.py index ac62f3326..5609e777a 100644 --- a/src/sleplet/plot_methods.py +++ b/src/sleplet/plot_methods.py @@ -4,6 +4,7 @@ import matplotlib as mpl import numpy as np import numpy.typing as npt +import s2fft import pyssht as ssht @@ -67,7 +68,8 @@ def _calc_nearest_grid_point( values - the translation needs to be at the same position as the rotation such that the difference error is small. """ - thetas, phis = ssht.sample_positions(L, Method=sleplet._vars.SAMPLING_SCHEME) + thetas = s2fft.samples.thetas(L, sampling=sleplet._vars.SAMPLING_SCHEME) + phis = s2fft.samples.phis_equiang(L, sampling=sleplet._vars.SAMPLING_SCHEME) pix_j = np.abs(phis - alpha_pi_fraction * np.pi).argmin() pix_i = np.abs(thetas - beta_pi_fraction * np.pi).argmin() alpha, beta = phis[pix_j], thetas[pix_i] @@ -104,7 +106,7 @@ def find_max_amplitude( field = ssht.inverse( function.coefficients, function.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) # find resolution of final plot for boosting if necessary @@ -152,7 +154,7 @@ def _set_outside_region_to_minimum( mask = sleplet._mask_methods.create_mask_region(L, region) # adapt for closed plot - _, n_phi = ssht.sample_shape(L, Method=sleplet._vars.SAMPLING_SCHEME) + _, n_phi = ssht.sample_shape(L, Method=sleplet._vars.SAMPLING_SCHEME.upper()) closed_mask = np.insert(mask, n_phi, mask[:, 0], axis=1) # set values outside mask to negative infinity @@ -191,7 +193,7 @@ def _boost_field( # noqa: PLR0913 L, Reality=reality, Spin=spin, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) return sleplet.harmonic_methods.invert_flm_boosted( flm, @@ -265,6 +267,6 @@ def _coefficients_to_field_sphere( f.L, Reality=f.reality, Spin=f.spin, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) ) diff --git a/src/sleplet/plotting/_create_plot_sphere.py b/src/sleplet/plotting/_create_plot_sphere.py index bd00cd595..826ee9106 100644 --- a/src/sleplet/plotting/_create_plot_sphere.py +++ b/src/sleplet/plotting/_create_plot_sphere.py @@ -7,6 +7,7 @@ import plotly.graph_objs as go import plotly.io as pio import pydantic.v1 as pydantic +import s2fft import pyssht as ssht @@ -69,7 +70,7 @@ def execute(self) -> None: x, y, z, f_plot, vmin, vmax = self._setup_plot( f, self.resolution, - method=sleplet._vars.SAMPLING_SCHEME, + method=sleplet._vars.SAMPLING_SCHEME.upper(), ) if isinstance(self.region, sleplet.slepian.region.Region): @@ -146,7 +147,29 @@ def _setup_plot( # noqa: PLR0913 else: f, _, _ = f - thetas, phis = ssht.sample_positions(resolution, Grid=True, Method=method) + thetas = np.tile( + s2fft.samples.thetas(resolution, sampling=method), + ( + s2fft.samples.nphi_equiang( + resolution, + sampling=method, + ), + 1, + ), + ).T + phis = np.tile( + s2fft.samples.phis_equiang( + resolution, + sampling=method, + ), + ( + s2fft.samples.ntheta( + resolution, + sampling=method, + ), + 1, + ), + ) if thetas.size != f.size: raise AttributeError("Bandlimit L deos not match that of f") diff --git a/src/sleplet/slepian/_slepian_decomposition.py b/src/sleplet/slepian/_slepian_decomposition.py index 223a8e72c..189163fc5 100644 --- a/src/sleplet/slepian/_slepian_decomposition.py +++ b/src/sleplet/slepian/_slepian_decomposition.py @@ -58,7 +58,7 @@ def _integrate_region(self, rank: int) -> complex: s_p = ssht.inverse( self.slepian.eigenvectors[rank], self.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) weight = sleplet._integration_methods.calc_integration_weight(self.L) integration = sleplet._integration_methods.integrate_region_sphere( @@ -78,7 +78,7 @@ def _integrate_sphere(self, rank: int) -> complex: s_p = ssht.inverse( self.slepian.eigenvectors[rank], self.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) weight = sleplet._integration_methods.calc_integration_weight(self.L) return sleplet._integration_methods.integrate_whole_sphere( diff --git a/src/sleplet/slepian_methods.py b/src/sleplet/slepian_methods.py index 402c491e0..0de20785e 100644 --- a/src/sleplet/slepian_methods.py +++ b/src/sleplet/slepian_methods.py @@ -136,7 +136,7 @@ def compute_s_p_omega( Returns: The complex \(S_{p}(\omega)\) values. """ - n_theta, n_phi = ssht.sample_shape(L, Method=sleplet._vars.SAMPLING_SCHEME) + n_theta, n_phi = ssht.sample_shape(L, Method=sleplet._vars.SAMPLING_SCHEME.upper()) sp = np.zeros((slepian.N, n_theta, n_phi), dtype=np.complex_) for p in range(slepian.N): if p % L == 0: @@ -144,7 +144,7 @@ def compute_s_p_omega( sp[p] = ssht.inverse( slepian.eigenvectors[p], L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) return sp @@ -157,8 +157,8 @@ def _compute_s_p_omega_prime( ) -> npt.NDArray[np.complex_]: """Method to pick out the desired angle from Sp(omega).""" sp_omega = compute_s_p_omega(L, slepian) - p = ssht.theta_to_index(beta, L, Method=sleplet._vars.SAMPLING_SCHEME) - q = ssht.phi_to_index(alpha, L, Method=sleplet._vars.SAMPLING_SCHEME) + p = ssht.theta_to_index(beta, L, Method=sleplet._vars.SAMPLING_SCHEME.upper()) + q = ssht.phi_to_index(alpha, L, Method=sleplet._vars.SAMPLING_SCHEME.upper()) sp_omega_prime = sp_omega[:, p, q] # pad with zeros so it has the expected shape boost = L**2 - slepian.N diff --git a/tests/test_decomposition.py b/tests/test_decomposition.py index 0573478c7..1dbeff621 100644 --- a/tests/test_decomposition.py +++ b/tests/test_decomposition.py @@ -10,7 +10,7 @@ def test_decompose_all_polar(slepian_polar_cap, earth_polar_cap) -> None: field = ssht.inverse( earth_polar_cap.coefficients, slepian_polar_cap.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) harmonic_sum_p = sleplet.slepian_methods.slepian_forward( slepian_polar_cap.L, @@ -48,7 +48,7 @@ def test_decompose_all_lim_lat_lon(slepian_lim_lat_lon, earth_lim_lat_lon) -> No field = ssht.inverse( earth_lim_lat_lon.coefficients, slepian_lim_lat_lon.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) harmonic_sum_p = sleplet.slepian_methods.slepian_forward( slepian_lim_lat_lon.L, @@ -96,7 +96,7 @@ def test_equality_to_harmonic_transform_polar( f_harmonic = ssht.inverse( earth_polar_cap.coefficients, slepian_polar_cap.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) mask = sleplet._mask_methods.create_mask_region( slepian_polar_cap.L, @@ -123,7 +123,7 @@ def test_equality_to_harmonic_transform_lim_lat_lon( f_harmonic = ssht.inverse( earth_lim_lat_lon.coefficients, slepian_lim_lat_lon.L, - Method=sleplet._vars.SAMPLING_SCHEME, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), ) mask = sleplet._mask_methods.create_mask_region( slepian_lim_lat_lon.L, diff --git a/tests/test_harmonic.py b/tests/test_harmonic.py index b09cbe962..fcb6bf182 100644 --- a/tests/test_harmonic.py +++ b/tests/test_harmonic.py @@ -20,6 +20,9 @@ def test_harmonic_coefficients_padded(random_flm) -> None: def test_invert_flm_and_boost(random_flm) -> None: """Tests that the flm has been boosted and has right shape.""" - n_theta, n_phi = ssht.sample_shape(L_LARGE, Method=sleplet._vars.SAMPLING_SCHEME) + n_theta, n_phi = ssht.sample_shape( + L_LARGE, + Method=sleplet._vars.SAMPLING_SCHEME.upper(), + ) f = sleplet.harmonic_methods.invert_flm_boosted(random_flm, L_SMALL, L_LARGE) np.testing.assert_equal(f.shape, (n_theta, n_phi)) diff --git a/tests/test_translation.py b/tests/test_translation.py index b1349e71e..445ad5b03 100644 --- a/tests/test_translation.py +++ b/tests/test_translation.py @@ -1,7 +1,6 @@ import hypothesis import numpy as np - -import pyssht as ssht +import s2fft import sleplet @@ -56,11 +55,19 @@ def test_slepian_translation_changes_max_polar(slepian_dirac_delta_polar_cap) -> slepian_dirac_delta_polar_cap.slepian, ) new_max = tuple(np.argwhere(field == field.max())[0]) - thetas, _ = ssht.sample_positions( - slepian_dirac_delta_polar_cap.L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, - ) + thetas = np.tile( + s2fft.samples.thetas( + slepian_dirac_delta_polar_cap.L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T np.testing.assert_raises( AssertionError, np.testing.assert_equal, @@ -89,11 +96,19 @@ def test_slepian_translation_changes_max_lim_lat_lon( slepian_dirac_delta_lim_lat_lon.slepian, ) new_max = tuple(np.argwhere(field == field.max())[0]) - thetas, _ = ssht.sample_positions( - slepian_dirac_delta_lim_lat_lon.L, - Grid=True, - Method=sleplet._vars.SAMPLING_SCHEME, - ) + thetas = np.tile( + s2fft.samples.thetas( + slepian_dirac_delta_lim_lat_lon.L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + ( + s2fft.samples.nphi_equiang( + L, + sampling=sleplet._vars.SAMPLING_SCHEME, + ), + 1, + ), + ).T np.testing.assert_raises( AssertionError, np.testing.assert_equal,