I run healpy.sphtfunc.alm2map passing alm as an array with l_max = 256 and asking as output a map with l_max = 191, but it seems that the function does not accept correctly the new l_max.
Here an example code of what I am doing, with artificially generated alms:
import healpy as hp
import numpy as np
#nside and lmax
nside_high = 128
lmax_high= 2*nside_high
nside_low = 64
lmax_low= 3*nside_low-1
#Cl
Cl = np.ones(lmax_high)
#Alm
Alm = hp.synalm(Cl, lmax = lmax_high)
#Map
Map = hp.alm2map(Alm, nside = nside_low, lmax = lmax_low)
I get this error:
ValueError Traceback (most recent call last)
/var/folders/k_/2j08yy711tb17zmmsznfx1zh0000gn/T/ipykernel_9189/2207532576.py in <cell line: 18>()
16
17 #Map
---> 18 Map = hp.alm2map(Alm, nside = nside_l, lmax = lmax_l)
/opt/anaconda3/lib/python3.8/site-packages/astropy/utils/decorators.py in wrapper(*args, **kwargs)
552 warnings.warn(msg, warning_type, stacklevel=2)
553
--> 554 return function(*args, **kwargs)
555
556 return wrapper
/opt/anaconda3/lib/python3.8/site-packages/healpy/sphtfunc.py in alm2map(alms, nside, lmax, mmax, pixwin, fwhm, sigma, pol, inplace, verbose)
502 mmax = -1
503 if pol:
--> 504 output = sphtlib._alm2map(
505 alms_new[0] if lonely else tuple(alms_new), nside, lmax=lmax, mmax=mmax
506 )
ValueError: Wrong alm size.
Can anyone help?
The purpose of
lmax
argument inalm2map
is just to handle input alms which havemmax != lmax
, they cannot be used to clip alms.Currently the easiest way to clip alms is:
The next version of
healpy
will have a dedicated functionresize_alm
:https://github.com/healpy/healpy/pull/803
In the future it would be nice to use the function to automatically handle this, I opened an issue to track this:
https://github.com/healpy/healpy/issues/817