Skip to content

Commit

Permalink
Remove s2wav & s2fft (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy authored Oct 5, 2023
1 parent 7bf0705 commit b5b0969
Show file tree
Hide file tree
Showing 52 changed files with 325 additions and 477 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ the figures in
`SLEPLET` has been tested with
[![Python](https://img.shields.io/pypi/pyversions/sleplet)](https://www.python.org).
Windows is not currently supported as `SLEPLET` relies on
[pyssht](https://pypi.org/project/pyssht) which does not work on Windows. This
can hopefully be replaced with [s2fft](https://github.com/astro-informatics/s2fft)
in the future when it is available on [PyPI](https://pypi.org).
[pyssht](https://pypi.org/project/pyssht) and
[pys2let](https://pypi.org/project/pys2let) which do not work on Windows.
These can hopefully be replaced with
[s2fft](https://github.com/astro-informatics/s2fft) and
[s2wav](https://github.com/astro-informatics/s2wav) in the future when they
are available on [PyPI](https://pypi.org).

## Example Usage

Expand Down
56 changes: 28 additions & 28 deletions documentation/DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ done

```python
import numpy as np
import s2fft
import pyssht as ssht
import sleplet

for ell in range(2, 0, -1):
f = sleplet.functions.HarmonicGaussian(128, l_sigma=10**ell, m_sigma=10)
flm = f.translate(alpha=0.75 * np.pi, beta=0.125 * np.pi)
f_sphere = s2fft.inverse(flm, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(flm, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(
f_sphere,
f.L,
Expand All @@ -75,12 +75,12 @@ sphere earth -L 128
```

```python
import s2fft
import pyssht as ssht
import sleplet

f = sleplet.functions.Earth(128)
flm = sleplet.harmonic_methods.rotate_earth_to_south_america(f.coefficients, f.L)
f_sphere = s2fft.inverse(flm, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(flm, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_2").execute()
```

Expand All @@ -93,15 +93,15 @@ done
```

```python
import s2fft
import pyssht as ssht
import sleplet

for ell in range(2, 0, -1):
f = sleplet.functions.HarmonicGaussian(128, l_sigma=10**ell, m_sigma=10)
g = sleplet.functions.Earth(128)
flm = f.convolve(f.coefficients, g.coefficients.conj())
flm_rot = sleplet.harmonic_methods.rotate_earth_to_south_america(flm, f.L)
f_sphere = s2fft.inverse(flm_rot, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(flm_rot, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, f"fig_3_ell_{ell}").execute()
```

Expand All @@ -126,13 +126,13 @@ sphere slepian_south_america -L 128 -s 2 -u
```

```python
import s2fft
import pyssht as ssht
import sleplet

# a
f = sleplet.functions.Earth(128, smoothing=2)
flm = sleplet.harmonic_methods.rotate_earth_to_south_america(f.coefficients, f.L)
f_sphere = s2fft.inverse(flm, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(flm, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_3_a", normalise=False).execute()
# b
region = sleplet.slepian.Region(mask_name="south_america")
Expand Down Expand Up @@ -282,13 +282,13 @@ sphere slepian_africa -L 128 -s 2 -u
```

```python
import s2fft
import pyssht as ssht
import sleplet

# a
f = sleplet.functions.Earth(128, smoothing=2)
flm = sleplet.harmonic_methods.rotate_earth_to_africa(f.coefficients, f.L)
f_sphere = s2fft.inverse(flm, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(flm, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_9_a", normalise=False).execute()
# b
region = sleplet.slepian.Region(mask_name="africa")
Expand Down Expand Up @@ -639,13 +639,13 @@ done
```

```python
import s2fft
import pyssht as ssht
import sleplet

for ell in range(5):
for m in range(ell + 1):
f = sleplet.functions.SphericalHarmonic(128, ell=ell, m=m)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(
f_sphere,
f.L,
Expand All @@ -670,17 +670,17 @@ sphere elongated_gaussian -e -1 -1 -L 128 -m rotate -a 0.25 -b 0.25 -g 0.25

```python
import numpy as np
import s2fft
import pyssht as ssht
import sleplet

# a
f = sleplet.functions.ElongatedGaussian(128, p_sigma=0.1, t_sigma=0.1)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_2_2_a", annotations=[]).execute()
# b-d
for a, b, g in [(0, 0, 0.25), (0, 0.25, 0.25), (0.25, 0.25, 0.25)]:
glm_rot = f.rotate(alpha=a * np.pi, beta=b * np.pi, gamma=g * np.pi)
g_sphere = s2fft.inverse(glm_rot, f.L, method="jax", sampling="mwss")
g_sphere = ssht.inverse(glm_rot, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(
g_sphere,
f.L,
Expand Down Expand Up @@ -713,12 +713,12 @@ done
```

```python
import s2fft
import pyssht as ssht
import sleplet

for j in [None, *list(range(4))]:
f = sleplet.functions.AxisymmetricWavelets(128, B=3, j_min=2, j=j)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(
f_sphere,
f.L,
Expand Down Expand Up @@ -758,16 +758,16 @@ sphere gaussian -a 0.75 -b 0.125 -L 128 -m translate -o

```python
import numpy as np
import s2fft
import pyssht as ssht
import sleplet

# a
f = sleplet.functions.Gaussian(128)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_3_1_a", annotations=[]).execute()
# b
glm_trans = f.translate(alpha=0.75 * np.pi, beta=0.125 * np.pi)
g_sphere = s2fft.inverse(glm_trans, f.L, method="jax", sampling="mwss")
g_sphere = ssht.inverse(glm_trans, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(g_sphere, f.L, "fig_3_1_b", annotations=[]).execute()
```

Expand All @@ -782,16 +782,16 @@ sphere squashed_gaussian -a 0.75 -b 0.125 -L 128 -m translate -o

```python
import numpy as np
import s2fft
import pyssht as ssht
import sleplet

# a
f = sleplet.functions.SquashedGaussian(128)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_3_2_a", annotations=[]).execute()
# b
glm_trans = f.translate(alpha=0.75 * np.pi, beta=0.125 * np.pi)
g_sphere = s2fft.inverse(glm_trans, f.L, method="jax", sampling="mwss")
g_sphere = ssht.inverse(glm_trans, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(g_sphere, f.L, "fig_3_2_b", annotations=[]).execute()
```

Expand All @@ -806,16 +806,16 @@ sphere elongated_gaussian -a 0.75 -b 0.125 -L 128 -m translate -o

```python
import numpy as np
import s2fft
import pyssht as ssht
import sleplet

# a
f = sleplet.functions.ElongatedGaussian(128)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(f_sphere, f.L, "fig_3_3_a", annotations=[]).execute()
# b
glm_trans = f.translate(alpha=0.75 * np.pi, beta=0.125 * np.pi)
g_sphere = s2fft.inverse(glm_trans, f.L, method="jax", sampling="mwss")
g_sphere = ssht.inverse(glm_trans, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(g_sphere, f.L, "fig_3_3_b", annotations=[]).execute()
```

Expand All @@ -830,12 +830,12 @@ done
```

```python
import s2fft
import pyssht as ssht
import sleplet

for ell in range(2, 0, -1):
f = sleplet.functions.HarmonicGaussian(128, l_sigma=10**ell, m_sigma=10)
f_sphere = s2fft.inverse(f.coefficients, f.L, method="jax", sampling="mwss")
f_sphere = ssht.inverse(f.coefficients, f.L, Method="MWSS")
sleplet.plotting.PlotSphere(
f_sphere,
f.L,
Expand Down
6 changes: 3 additions & 3 deletions examples/arbitrary/_slepian_wavelet_covariance.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np
import numpy.typing as npt

import s2fft
import pyssht as ssht

import sleplet

SAMPLING_SCHEME = "mwss"
SAMPLING_SCHEME = "MWSS"


def compute_slepian_wavelet_covariance(
Expand All @@ -29,7 +29,7 @@ def compute_slepian_wavelet_covariance(
covariance.shape[0],
)
np.testing.assert_equal(
s2fft.samples.f_shape(slepian_wavelets.L, sampling=SAMPLING_SCHEME),
ssht.sample_shape(slepian_wavelets.L, Method=SAMPLING_SCHEME),
covariance.shape[1:],
)
return covariance
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import numpy as np

import s2fft

import sleplet

sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))
Expand Down Expand Up @@ -40,11 +38,8 @@ def main() -> None:
rng = np.random.default_rng(RANDOM_SEED)

for i in range(RUNS):
# Generate random complex signal
f_p = s2fft.samples.flm_2d_to_1d(
s2fft.utils.signal_generator.generate_flm(rng, L),
L,
)
# Generate normally distributed random complex signal
f_p = sleplet.harmonic_methods.compute_random_signal(L, rng, var_signal=VAR_FP)

# compute wavelet coefficients
w_p = sleplet.wavelet_methods.slepian_wavelet_forward(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ def _plot_axisymmetric_coefficients(shannon: int) -> None:
awc = sleplet.functions.AxisymmetricWaveletCoefficientsAfrica(L, B=B, j_min=J_MIN)

# find sorted coefficients
w_lm = np.sort(np.sort(np.abs(awc.wavelet_coefficients), axis=1), axis=2)[
:,
::-1,
::-1,
]
w_lm = np.sort(np.abs(awc.wavelet_coefficients), axis=1)[:, ::-1]

# perform plot
plt.plot(w_lm[0, :shannon], "--", label=r"$|W^{{\phi}}_{\ell m}|$")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

import numpy as np

import s2fft

import sleplet

sys.path.append(str(pathlib.Path(__file__).resolve().parents[1]))
Expand Down Expand Up @@ -40,11 +38,8 @@ def main() -> None:
rng = np.random.default_rng(RANDOM_SEED)

for i in range(RUNS):
# Generate random complex signal
f_p = s2fft.samples.flm_2d_to_1d(
s2fft.utils.signal_generator.generate_flm(rng, L),
L,
)
# Generate normally distributed random complex signal
f_p = sleplet.harmonic_methods.compute_random_signal(L, rng, var_signal=VAR_FP)

# compute wavelet coefficients
w_p = sleplet.wavelet_methods.slepian_wavelet_forward(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ def _plot_axisymmetric_coefficients(shannon: int) -> None:
)

# find sorted coefficients
w_lm = np.sort(np.sort(np.abs(awc.wavelet_coefficients), axis=1), axis=2)[
:,
::-1,
::-1,
]
w_lm = np.sort(np.abs(awc.wavelet_coefficients), axis=1)[:, ::-1]

# perform plot
plt.plot(w_lm[0, :shannon], "--", label=r"$|W^{{\phi}}_{\ell m}|$")
Expand Down
7 changes: 3 additions & 4 deletions examples/misc/_denoising_axisym.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import numpy as np
import numpy.typing as npt

import s2fft
import pyssht as ssht

import sleplet

EXECUTION_MODE = "jax"
SAMPLING_SCHEME = "mwss"
SAMPLING_SCHEME = "MWSS"


def denoising_axisym( # noqa: PLR0913
Expand Down Expand Up @@ -61,5 +60,5 @@ def denoising_axisym( # noqa: PLR0913
else flm
)

f = s2fft.inverse(flm, signal.L, method=EXECUTION_MODE, sampling=SAMPLING_SCHEME)
f = ssht.inverse(flm, signal.L, Method=SAMPLING_SCHEME)
return f, noised_signal.snr, denoised_snr
5 changes: 2 additions & 3 deletions examples/misc/translation_normalisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
import seaborn as sns

import pyssht as ssht
import s2fft

import sleplet

sns.set(context="paper")

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 = s2fft.samples.thetas(L, sampling=SAMPLING_SCHEME)
thetas, _ = ssht.sample_positions(L, Method=SAMPLING_SCHEME)
norm = np.zeros(len(thetas))
for i, theta in enumerate(thetas):
print(f"compute norm {i+1}/{len(thetas)}")
Expand Down
4 changes: 1 addition & 3 deletions examples/polar_cap/slepian_coefficients.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import numpy.typing as npt
import seaborn as sns

import s2fft

import sleplet

sns.set(context="paper")
Expand All @@ -20,7 +18,7 @@ def _earth_region_harmonic_coefficients(
"""Harmonic coefficients of the Earth for the polar cap region."""
region = sleplet.slepian.Region(theta_max=np.deg2rad(theta_max))
earth = sleplet.functions.Earth(L, region=region)
coefficients = np.abs(s2fft.samples.flm_2d_to_1d(earth.coefficients, L))
coefficients = np.abs(earth.coefficients)
coefficients[::-1].sort()
return coefficients

Expand Down
Loading

0 comments on commit b5b0969

Please sign in to comment.