Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lenspyx/remapping/utils_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def st2mmax(spin, tht, lmax):


class Geom:
def __init__(self, theta:np.ndarray[float], phi0:np.ndarray[float], nphi:np.ndarray[np.uint64], ringstart:np.ndarray[np.uint64], w:np.ndarray[float]):
def __init__(self, theta:np.ndarray[float], phi0:np.ndarray[float], nphi:np.ndarray[np.uint64], ringstart:np.ndarray[np.uint64], w:np.ndarray[float], name='unnamed'):
"""Iso-latitude pixelisation of the sphere

Args:
Expand All @@ -31,6 +31,7 @@ def __init__(self, theta:np.ndarray[float], phi0:np.ndarray[float], nphi:np.ndar
nphi: number of pixels in each ring
ringstart: index of first pixel of each ring in real space map
w: quadrature weight for each ring (used for SHT of 'analysis'-type )
name: identifier for the geometry, used for e.g. debugging


"""
Expand All @@ -43,6 +44,7 @@ def __init__(self, theta:np.ndarray[float], phi0:np.ndarray[float], nphi:np.ndar
self.phi0 = phi0[argsort].astype(np.float64)
self.nph = nphi[argsort].astype(np.uint64)
self.ofs = ringstart[argsort].astype(np.uint64)
self.name = name

def npix(self):
"""Number of pixels
Expand Down Expand Up @@ -103,7 +105,7 @@ def thinout(self, spin, good_size_real=True):
nphi_eq = np.array([good_size(int(np.ceil(stx / dph_eq)), good_size_real) for stx in st])
nph = np.where((st / nph) > dph_eq, nphi_eq, nph)
ofs = np.insert(np.cumsum(nph[:-1]), 0, 0)
return Geom(tht, self.phi0, nph, ofs, self.weight / nph * self.nph)
return Geom(tht, self.phi0, nph, ofs, self.weight / nph * self.nph, name='thinout')

def split(self, nbands, verbose=False):
"""Split the pixelization into chunks
Expand Down Expand Up @@ -146,6 +148,7 @@ def synthesis(self, gclm: np.ndarray, spin:int, lmax:int, mmax:int, nthreads:int

"""
gclm = np.atleast_2d(gclm)
print(gclm.shape, gclm.dtype, gclm)
return synthesis(alm=gclm, theta=self.theta, lmax=lmax, mmax=mmax, nphi=self.nph, spin=spin, phi0=self.phi0,
nthreads=nthreads, ringstart=self.ofs, map=map, **kwargs)

Expand Down Expand Up @@ -256,7 +259,7 @@ def get_thingauss_geometry(lmax:int, smax:int, good_size_real=True):
mmax = np.minimum(np.maximum(st2mmax(smax, tht, lmax), st2mmax(-smax, tht, lmax)), np.ones(nlat) * lmax)
nph = np.array([good_size(int(np.ceil(2 * m + 1)), good_size_real) for m in mmax])
ofs = np.insert(np.cumsum(nph[:-1]), 0, 0)
return Geom(tht, phi0, nph, ofs, wt / nph)
return Geom(tht, phi0, nph, ofs, wt / nph, name='thinguass')

@staticmethod
def get_healpix_geometry(nside:int):
Expand All @@ -270,7 +273,7 @@ def get_healpix_geometry(nside:int):
base = ducc0.healpix.Healpix_Base(nside, "RING")
geom = base.sht_info()
area = (4 * np.pi) / (12 * nside ** 2)
return Geom(w=np.full((geom['theta'].size, ), area), **geom)
return Geom(w=np.full((geom['theta'].size, ), area), **geom, name='healpix')

@staticmethod
def get_cc_geometry(ntheta:int, nphi:int):
Expand Down Expand Up @@ -308,7 +311,7 @@ def get_f1_geometry(ntheta:int, nphi:int):
nph = np.full((ntheta,), nphi, dtype=np.uint64)
ofs = np.insert(np.cumsum(nph[:-1]), 0, 0)
w = ducc0.sht.experimental.get_gridweights('F1', ntheta)
return Geom(tht, phi0, nph, ofs, w / nphi)
return Geom(tht, phi0, nph, ofs, w / nphi, name='f1')


@staticmethod
Expand All @@ -329,7 +332,7 @@ def get_gl_geometry(lmax:int, good_size_real=True, nphi:int or None =None):
phi0 = np.zeros(nlatf, dtype=float)
nph = np.full((nlatf,), nphi, dtype=np.uint64)
ofs = np.insert(np.cumsum(nph[:-1]), 0, 0)
return Geom(tht, phi0, nph, ofs, wt / nph)
return Geom(tht, phi0, nph, ofs, wt / nph, name='gl')

@staticmethod
def get_tgl_geometry(lmax:int, smax:int, good_size_real=True):
Expand All @@ -342,7 +345,7 @@ def get_tgl_geometry(lmax:int, smax:int, good_size_real=True):
(very slightly more points if set but largely inconsequential)

"""
return Geom.get_thingauss_geometry(lmax, smax, good_size_real=good_size_real)
return Geom.get_thingauss_geometry(lmax, smax, good_size_real=good_size_real, name='tgl')


class pbounds:
Expand Down