You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Drawing sims with curvedsky.rand_alm crashes under the following conditions:
User supplies lmax that is smaller than the lmax that would correspond to the shape of ps
The dtype is np.complex64
What I Did
Here's an example script that captures the bug.
frompixellimportenmap, curvedsky, utils, enplotimportnumpyasnp# make a geometry to put maps onto without aliasingshape, wcs=enmap.fullsky_geometry(res=8*utils.arcmin, variant='fejer1')
print(shape, wcs)
# make an arbitrary power spectrum with an lmax of 1000ps=np.exp(-np.arange(1001)/100+1)
# double prec simps_dtype=np.float64alm_dtype=np.complex128map_dtype=np.float64# if lmax of my realization is >= 1000, pads ps with 0 (fine)omap=curvedsky.alm2map(curvedsky.rand_alm(ps.astype(ps_dtype), lmax=1300, seed=123, dtype=alm_dtype), enmap.empty(shape, wcs, map_dtype))
# if lmax of my realization is < 1000, still OKomap=curvedsky.alm2map(curvedsky.rand_alm(ps.astype(ps_dtype), lmax=500, seed=123, dtype=alm_dtype), enmap.empty(shape, wcs, map_dtype))
# single prec simps_dtype=np.float32alm_dtype=np.complex64map_dtype=np.float32# if lmax of my realization is >= 1000, pads ps with 0 (fine)omap=curvedsky.alm2map(curvedsky.rand_alm(ps.astype(ps_dtype), lmax=1300, seed=123, dtype=alm_dtype), enmap.empty(shape, wcs, map_dtype))
# if lmax of my realization is < 1000, now this crashesomap=curvedsky.alm2map(curvedsky.rand_alm(ps.astype(ps_dtype), lmax=500, seed=123, dtype=alm_dtype), enmap.empty(shape, wcs, map_dtype))
# issue is specific to the alm_dtype being single precps_dtype=np.float64alm_dtype=np.complex64map_dtype=np.float64# if lmax of my realization is >= 1000, pads ps with 0 (fine)omap=curvedsky.alm2map(curvedsky.rand_alm(ps.astype(ps_dtype), lmax=1300, seed=123, dtype=alm_dtype), enmap.empty(shape, wcs, map_dtype))
# if lmax of my realization is < 1000, this also crashesomap=curvedsky.alm2map(curvedsky.rand_alm(ps.astype(ps_dtype), lmax=500, seed=123, dtype=alm_dtype), enmap.empty(shape, wcs, map_dtype))
If you print the output of curvedsky.rand_alm rather than project it into a map, you get some weird looking elements in the first crashing case, before the same error message occurs:
# double prec, if lmax of my realization is >= 1000, pads ps with 0 (fine)
[-1.78990227+0.j 0.46422573+0.j -3.96110789+0.j ... 0. +0.j
0. +0.j 0. +0.j]
# double prec, if lmax of my realization is < 1000, still OK
[-1.78990227+0.j 0.46422573+0.j -3.96110789+0.j
... -0.06780981-0.04358139j 0.05597249-0.04199121j
0.13843811+0.0326628j ]
# single prec, if lmax of my realization is >= 1000, pads ps with 0 (fine)
[-1.7899024 +0.j 0.46422574+0.j -3.9611077 +0.j ... 0. +0.j
0. +0.j 0. +0.j]
# single prec, if lmax of my realization is < 1000, now this crashes
[-1.7899024e+00+0.0e+00j 4.6422574e-01+0.0e+00j -3.9611077e+00+0.0e+00j
... -3.5032462e-44-2.2e-44j 2.5223372e-44-1.8e-44j
5.6051939e-45+1.4e-45j]
The text was updated successfully, but these errors were encountered:
Description
Drawing sims with
curvedsky.rand_alm
crashes under the following conditions:lmax
that is smaller than the lmax that would correspond to the shape ofps
dtype
isnp.complex64
What I Did
Here's an example script that captures the bug.
The error in either of the crashing cases is
If you print the output of
curvedsky.rand_alm
rather than project it into a map, you get some weird looking elements in the first crashing case, before the same error message occurs:The text was updated successfully, but these errors were encountered: