Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-harmonics
Commits
dca116b5
Unverified
Commit
dca116b5
authored
Apr 29, 2025
by
Boris Bonev
Committed by
GitHub
Apr 29, 2025
Browse files
Revert "setting imaginary parts of DCT and nyquist frequency to zero in IRSHT…" (#71)
This reverts commit
82881276
.
parent
82881276
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
27 deletions
+7
-27
torch_harmonics/distributed/distributed_sht.py
torch_harmonics/distributed/distributed_sht.py
+3
-10
torch_harmonics/sht.py
torch_harmonics/sht.py
+4
-17
No files found.
torch_harmonics/distributed/distributed_sht.py
View file @
dca116b5
...
...
@@ -248,6 +248,9 @@ class DistributedInverseRealSHT(nn.Module):
# einsum
xs
=
torch
.
einsum
(
'...lmr, mlk->...kmr'
,
x
,
self
.
pct
.
to
(
x
.
dtype
)).
contiguous
()
#rl = torch.einsum('...lm, mlk->...km', x[..., 0], self.pct.to(x.dtype) )
#im = torch.einsum('...lm, mlk->...km', x[..., 1], self.pct.to(x.dtype) )
#xs = torch.stack((rl, im), -1).contiguous()
# inverse FFT
x
=
torch
.
view_as_complex
(
xs
)
...
...
@@ -260,11 +263,6 @@ class DistributedInverseRealSHT(nn.Module):
if
self
.
comm_size_azimuth
>
1
:
x
=
distributed_transpose_azimuth
.
apply
(
x
,
(
-
3
,
-
1
),
self
.
m_shapes
)
# set DCT and nyquist frequencies to 0:
x
[...,
0
].
imag
=
0.0
if
(
self
.
nlon
%
2
==
0
)
and
(
self
.
nlon
//
2
<
x
.
shape
[
-
1
]):
x
[...,
self
.
nlon
//
2
].
imag
=
0.0
# apply the inverse (real) FFT
x
=
torch
.
fft
.
irfft
(
x
,
n
=
self
.
nlon
,
dim
=-
1
,
norm
=
"forward"
)
...
...
@@ -530,11 +528,6 @@ class DistributedInverseRealVectorSHT(nn.Module):
if
self
.
comm_size_azimuth
>
1
:
x
=
distributed_transpose_azimuth
.
apply
(
x
,
(
-
4
,
-
1
),
self
.
m_shapes
)
# set DCT and nyquist frequencies to zero
x
[...,
0
].
imag
=
0.0
if
(
self
.
nlon
%
2
==
0
)
and
(
self
.
nlon
//
2
<
x
.
shape
[
-
1
]):
x
[...,
self
.
nlon
//
2
].
imag
=
0.0
# apply the inverse (real) FFT
x
=
torch
.
fft
.
irfft
(
x
,
n
=
self
.
nlon
,
dim
=-
1
,
norm
=
"forward"
)
...
...
torch_harmonics/sht.py
View file @
dca116b5
...
...
@@ -195,18 +195,13 @@ class InverseRealSHT(nn.Module):
# Evaluate associated Legendre functions on the output nodes
x
=
torch
.
view_as_real
(
x
)
xs
=
torch
.
einsum
(
"...lmr, mlk->...kmr"
,
x
,
self
.
pct
.
to
(
x
.
dtype
)).
contiguous
()
rl
=
torch
.
einsum
(
"...lm, mlk->...km"
,
x
[...,
0
],
self
.
pct
.
to
(
x
.
dtype
))
im
=
torch
.
einsum
(
"...lm, mlk->...km"
,
x
[...,
1
],
self
.
pct
.
to
(
x
.
dtype
))
xs
=
torch
.
stack
((
rl
,
im
),
-
1
)
# apply the inverse (real) FFT
x
=
torch
.
view_as_complex
(
xs
)
# ensure that imaginary part of 0 and nyquist components are zero
# this is important because not all backend algorithms provided through the
# irfft interface ensure that
x
[...,
0
].
imag
=
0.0
if
(
self
.
nlon
%
2
==
0
)
and
(
self
.
nlon
//
2
<
self
.
mmax
):
x
[...,
self
.
nlon
//
2
].
imag
=
0.0
x
=
torch
.
fft
.
irfft
(
x
,
n
=
self
.
nlon
,
dim
=-
1
,
norm
=
"forward"
)
return
x
...
...
@@ -400,14 +395,6 @@ class InverseRealVectorSHT(nn.Module):
# apply the inverse (real) FFT
x
=
torch
.
view_as_complex
(
xs
)
# ensure that imaginary part of 0 and nyquist components are zero
# this is important because not all backend algorithms provided through the
# irfft interface ensure that
x
[...,
0
].
imag
=
0.0
if
(
self
.
nlon
%
2
==
0
)
and
(
self
.
nlon
//
2
<
self
.
mmax
):
x
[...,
self
.
nlon
//
2
].
imag
=
0.0
x
=
torch
.
fft
.
irfft
(
x
,
n
=
self
.
nlon
,
dim
=-
1
,
norm
=
"forward"
)
return
x
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment