@@ -17,11 +17,9 @@ def wigner_subset_to_s2(
17
17
Transforms an arbitrary subset of Wigner coefficients onto a subset of spin signals
18
18
on the sphere.
19
19
20
- This function takes a collection of spin spherical harmonic coefficients each with
21
- a different (though not necessarily unique) spin and maps them back to their
22
- corresponding pixel-space representations. Following this operation one may
23
- liftn this collection of spin signals to a signal on SO(3) by exploiting the
24
- correct Mackey functions.
20
+ This function takes a collection of spin spherical harmonic coefficients each with
21
+ a different (though not necessarily unique) spin and maps them back to their
22
+ corresponding pixel-space representations.
25
23
26
24
Args:
27
25
flmn (np.ndarray): Collection of spin spherical harmonic coefficients
@@ -33,15 +31,25 @@ def wigner_subset_to_s2(
33
31
sampling (str, optional): Sampling scheme. Supported sampling schemes include
34
32
{"mw", "mwss"}. Defaults to "mw".
35
33
34
+ Raises:
35
+ ValueError: If sampling scheme is not recognised.
36
+ ValueError: If the number of spins does not match the number of Wigner coefficients.
37
+
36
38
Returns:
37
- np.ndarray: A collection of spin signals with shape :math:`[batch, n_s, n_\theta, n_\phi, channels]`.
39
+ np.ndarray: A collection of spin signals with
40
+ shape :math:`[batch, n_s, n_\theta, n_\phi, channels]`.
38
41
39
42
"""
40
43
if sampling .lower () not in ["mw" , "mwss" ]:
41
44
raise ValueError (
42
45
f"Fourier-Wigner algorithm does not support { sampling } sampling."
43
46
)
44
47
48
+ if flmn .shape [1 ] != spins .shape [0 ]:
49
+ raise ValueError (
50
+ f"Number of spins specified { spins .shape [0 ]} does not match the number of Wigner coefficients { flmn .shape [1 ]} "
51
+ )
52
+
45
53
# EXTRACT VARIOUS PRECOMPUTES
46
54
Delta , _ = DW
47
55
@@ -93,9 +101,7 @@ def wigner_subset_to_s2_jax(
93
101
94
102
This function takes a collection of spin spherical harmonic coefficients each with
95
103
a different (though not necessarily unique) spin and maps them back to their
96
- corresponding pixel-space representations. Following this operation one may
97
- liftn this collection of spin signals to a signal on SO(3) by exploiting the
98
- correct Mackey functions.
104
+ corresponding pixel-space representations.
99
105
100
106
Args:
101
107
flmn (jnp.ndarray): Collection of spin spherical harmonic coefficients
@@ -107,6 +113,10 @@ def wigner_subset_to_s2_jax(
107
113
sampling (str, optional): Sampling scheme. Supported sampling schemes include
108
114
{"mw", "mwss"}. Defaults to "mw".
109
115
116
+ Raises:
117
+ ValueError: If sampling scheme is not recognised.
118
+ ValueError: If the number of spins does not match the number of Wigner coefficients.
119
+
110
120
Returns:
111
121
jnp.ndarray: A collection of spin signals with shape :math:`[batch, n_s, n_\theta, n_\phi, channels]`.
112
122
@@ -116,6 +126,11 @@ def wigner_subset_to_s2_jax(
116
126
f"Fourier-Wigner algorithm does not support { sampling } sampling."
117
127
)
118
128
129
+ if flmn .shape [1 ] != spins .shape [0 ]:
130
+ raise ValueError (
131
+ f"Number of spins specified { spins .shape [0 ]} does not match the number of Wigner coefficients { flmn .shape [1 ]} "
132
+ )
133
+
119
134
# EXTRACT VARIOUS PRECOMPUTES
120
135
Delta , _ = DW
121
136
@@ -167,10 +182,10 @@ def so3_to_wigner_subset(
167
182
Transforms a signal on the rotation group to an arbitrary subset of its Wigner
168
183
coefficients.
169
184
170
- This function takes a signal on the rotation group SO(3) and computes a subset of
171
- spin spherical harmonic coefficients corresponding to slices across the requested
172
- spin numbers. These spin numbers can be arbitrarily chosen such that their absolute
173
- value is less than or equal to the azimuthal band-limit :math:`N\leq L`.
185
+ This function takes a signal on the rotation group SO(3) and computes a subset of
186
+ spin spherical harmonic coefficients corresponding to slices across the requested
187
+ spin numbers. These spin numbers can be arbitrarily chosen such that their absolute
188
+ value is less than or equal to the azimuthal band-limit :math:`N\leq L`.
174
189
175
190
Args:
176
191
f (np.ndarray): Signal on the rotation group with shape :math:`[batch, n_\gamma, n_\theta,n_\phi, channels]`.
@@ -186,12 +201,11 @@ def so3_to_wigner_subset(
186
201
np.ndarray: Collection of spin spherical harmonic coefficients with shape :math:`[batch, n_s, L, 2L-1, channels]`.
187
202
188
203
"""
189
- # COMPUTE FFT OVER GAMMA
190
- x = np .fft .fft (f , axis = - 4 , norm = "forward" )
191
- x = np .fft .fftshift (x , axes = - 4 )
192
-
193
- # EXTRACT REQUESTED SPIN COMPONENTS
194
- x = x [:, N - 1 - spins ]
204
+ # COMPUTE DFT OVER GAMMA SUBSET
205
+ e = np .exp (
206
+ - 2j * np .pi * np .einsum ("g,n->gn" , np .arange (f .shape [1 ]) / f .shape [1 ], - spins )
207
+ )
208
+ x = np .einsum ("bgtpc,gn->bntpc" , f , e ) / f .shape [1 ]
195
209
196
210
return s2_to_wigner_subset (x , spins , DW , L , sampling )
197
211
@@ -209,10 +223,10 @@ def so3_to_wigner_subset_jax(
209
223
Transforms a signal on the rotation group to an arbitrary subset of its Wigner
210
224
coefficients (JAX).
211
225
212
- This function takes a signal on the rotation group SO(3) and computes a subset of
213
- spin spherical harmonic coefficients corresponding to slices across the requested
214
- spin numbers. These spin numbers can be arbitrarily chosen such that their absolute
215
- value is less than or equal to the azimuthal band-limit :math:`N\leq L`.
226
+ This function takes a signal on the rotation group SO(3) and computes a subset of
227
+ spin spherical harmonic coefficients corresponding to slices across the requested
228
+ spin numbers. These spin numbers can be arbitrarily chosen such that their absolute
229
+ value is less than or equal to the azimuthal band-limit :math:`N\leq L`.
216
230
217
231
Args:
218
232
f (jnp.ndarray): Signal on the rotation group with shape :math:`[batch, n_\gamma, n_\theta,n_\phi, channels]`.
@@ -229,12 +243,13 @@ def so3_to_wigner_subset_jax(
229
243
with shape :math:`[batch, n_s, L, 2L-1, channels]`.
230
244
231
245
"""
232
- # COMPUTE FFT OVER GAMMA
233
- x = jnp .fft .fft (f , axis = - 4 , norm = "forward" )
234
- x = jnp .fft .fftshift (x , axes = - 4 )
235
-
236
- # EXTRACT REQUESTED SPIN COMPONENTS
237
- x = x [:, N - 1 - spins ]
246
+ # COMPUTE DFT OVER GAMMA SUBSET
247
+ e = jnp .exp (
248
+ - 2j
249
+ * jnp .pi
250
+ * jnp .einsum ("g,n->gn" , jnp .arange (f .shape [1 ]) / f .shape [1 ], - spins )
251
+ )
252
+ x = jnp .einsum ("bgtpc,gn->bntpc" , f , e ) / f .shape [1 ]
238
253
239
254
return s2_to_wigner_subset_jax (x , spins , DW , L , sampling )
240
255
@@ -250,11 +265,11 @@ def s2_to_wigner_subset(
250
265
Transforms from a collection of arbitrary spin signals on the sphere to the
251
266
corresponding collection of their harmonic coefficients.
252
267
253
- This function takes a multimodal collection of spin spherical harmonic signals
254
- on the sphere and transforms them into their spin spherical harmonic coefficients.
255
- These cofficients may then be combined into a subset of Wigner coefficients for
256
- downstream analysis. In this way one may combine input features across a variety
257
- of spins into a unified representation.
268
+ This function takes a multimodal collection of spin spherical harmonic signals
269
+ on the sphere and transforms them into their spin spherical harmonic coefficients.
270
+ These coefficients may then be combined into a subset of Wigner coefficients for
271
+ downstream analysis. In this way one may combine input features across a variety
272
+ of spins into a unified representation.
258
273
259
274
Args:
260
275
fs (np.ndarray): Collection of spin signal maps on the sphere with shape :math:`[batch, n_s, n_\theta,n_\phi, channels]`.
@@ -336,11 +351,11 @@ def s2_to_wigner_subset_jax(
336
351
Transforms from a collection of arbitrary spin signals on the sphere to the
337
352
corresponding collection of their harmonic coefficients (JAX).
338
353
339
- This function takes a multimodal collection of spin spherical harmonic signals
340
- on the sphere and transforms them into their spin spherical harmonic coefficients.
341
- These cofficients may then be combined into a subset of Wigner coefficients for
342
- downstream analysis. In this way one may combine input features across a variety
343
- of spins into a unified representation.
354
+ This function takes a multimodal collection of spin spherical harmonic signals
355
+ on the sphere and transforms them into their spin spherical harmonic coefficients.
356
+ These coefficients may then be combined into a subset of Wigner coefficients for
357
+ downstream analysis. In this way one may combine input features across a variety
358
+ of spins into a unified representation.
344
359
345
360
Args:
346
361
fs (jnp.ndarray): Collection of spin signal maps on the sphere with shape :math:`[batch, n_s, n_\theta,n_\phi, channels]`.
0 commit comments