- edited description
Odd nlat discrepancy
Issue #50
resolved
I was trying to play around with the odd nlat case and it doesn’t seem to be working as expected. This is a simple script to show the issue.
import math
import numpy as np
import shtns
nlat = 33
nlon = 48
lmax = 7
mmax = 7
sh = shtns.sht(lmax=lmax, mmax=mmax, mres=1, norm=shtns.sht_orthonormal)
sh.set_grid(nlat, nlon,
flags=shtns.sht_reg_fast | shtns.SHT_PHI_CONTIGUOUS,
polar_opt=1.0e-10)
theta = np.arccos(sh.cos_theta)
phi = (2.0 * np.pi / nlon) * np.arange(nlon)
n, m = 1, 0
ynm = sh.spec_array()
ynm[sh.idx(n, m)] = np.sqrt(
4.0 * np.pi / (2 * n + 1)
* math.factorial(n + m) / math.factorial(n - m))
sht_theta = np.arccos(sh.synth(ynm))
print(f"sht_theta[0, :]: {sht_theta[0, :]}")
print(f"sht_theta[:, 0]: {sht_theta[:, 0]}")
print(f"theta: {theta}")
print(f"sht_theta {sht_theta.shape} theta {theta.shape}")
print(f"error: ", np.linalg.norm(sht_theta[:, 0] - theta))
Basically, the sht_theta[:, 0]
should be the same as theta
here (and they are for even nlat
), but they’re different sizes.
Am I doing something wrong or is this a bug?
Comments (4)
-
reporter -
repo owner This is indeed a bug. The python interface mixes up the nlat and nlon dimensions. It is fixed in commit 5a815ac, I will make a new release once you confirm it is ok.
-
reporter Yeah, that seems to have fixed it! Thank you.
-
repo owner - changed status to resolved
fixed in v3.5.1
- Log in to comment