How to use the pixell.utils.to_Nd function in pixell

To help you get started, we’ve selected a few pixell examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github simonsobs / pixell / pixell / curvedsky.py View on Github external
def map2alm_raw(map, alm, minfo, ainfo, spin=[0,2], copy=False):
	"""Direct wrapper of libsharp's map2alm. Requires ainfo and minfo
	to already be set up, and that the map and alm must be fully compatible
	with these."""
	if not (map.dtype == np.float32 or map.dtype == np.float64): raise TypeError("Only float32 or float64 dtype supported for shts")
	if copy: alm = alm.copy()
	alm_full = utils.to_Nd(alm, 3)
	map_full = utils.to_Nd(map, 4)
	map_flat = map_full.reshape(map_full.shape[:-2]+(-1,))
	sht      = sharp.sht(minfo, ainfo)
	for s, i1, i2 in enmap.spin_helper(spin, map_flat.shape[1]):
		alm_full[:,i1:i2,:] = sht.map2alm(map_flat[:,i1:i2,:], alm_full[:,i1:i2,:], spin=s)
	return alm
github simonsobs / pixell / pixell / curvedsky.py View on Github external
def alm2map_raw(alm, map, ainfo, minfo, spin=[0,2], deriv=False, copy=False):
	"""Direct wrapper of libsharp's alm2map. Requires ainfo and minfo
	to already be set up, and that the map and alm must be fully compatible
	with these."""
	if copy: map = map.copy()
	alm = np.asarray(alm, dtype=np.result_type(map.dtype,1j))
	alm_full = utils.to_Nd(alm, 2 if deriv else 3)
	map_full = utils.to_Nd(map, 4)
	map_flat = map_full.reshape(map_full.shape[:-2]+(-1,))
	sht      = sharp.sht(minfo, ainfo)
	# Perform the SHT
	if deriv:
		# We need alm_full[ntrans,nalm] -> map_flat[ntrans,2,npix]
		# or alm_full[nalm] -> map_flat[2,npix]
		map_flat[:] = sht.alm2map_der1(alm_full, map_flat)
		# sharp's theta is a zenith angle, but we want a declination.
		# Actually, we may need to take into account left-handed
		# coordinates too, though I'm not sure how to detect those in
		# general.
		map_flat[:,0] = -map_flat[:,0]
	else:
		for s, i1, i2 in enmap.spin_helper(spin, map_flat.shape[1]):
			map_flat[:,i1:i2,:] = sht.alm2map(alm_full[:,i1:i2,:], map_flat[:,i1:i2,:], spin=s)
	return map
github simonsobs / pixell / pixell / curvedsky.py View on Github external
def alm2map_raw(alm, map, ainfo, minfo, spin=[0,2], deriv=False, copy=False):
	"""Direct wrapper of libsharp's alm2map. Requires ainfo and minfo
	to already be set up, and that the map and alm must be fully compatible
	with these."""
	if copy: map = map.copy()
	alm = np.asarray(alm, dtype=np.result_type(map.dtype,1j))
	alm_full = utils.to_Nd(alm, 2 if deriv else 3)
	map_full = utils.to_Nd(map, 4)
	map_flat = map_full.reshape(map_full.shape[:-2]+(-1,))
	sht      = sharp.sht(minfo, ainfo)
	# Perform the SHT
	if deriv:
		# We need alm_full[ntrans,nalm] -> map_flat[ntrans,2,npix]
		# or alm_full[nalm] -> map_flat[2,npix]
		map_flat[:] = sht.alm2map_der1(alm_full, map_flat)
		# sharp's theta is a zenith angle, but we want a declination.
		# Actually, we may need to take into account left-handed
		# coordinates too, though I'm not sure how to detect those in
		# general.
		map_flat[:,0] = -map_flat[:,0]
	else:
		for s, i1, i2 in enmap.spin_helper(spin, map_flat.shape[1]):
			map_flat[:,i1:i2,:] = sht.alm2map(alm_full[:,i1:i2,:], map_flat[:,i1:i2,:], spin=s)
github simonsobs / pixell / pixell / curvedsky.py View on Github external
def map2alm_raw(map, alm, minfo, ainfo, spin=[0,2], copy=False):
	"""Direct wrapper of libsharp's map2alm. Requires ainfo and minfo
	to already be set up, and that the map and alm must be fully compatible
	with these."""
	if not (map.dtype == np.float32 or map.dtype == np.float64): raise TypeError("Only float32 or float64 dtype supported for shts")
	if copy: alm = alm.copy()
	alm_full = utils.to_Nd(alm, 3)
	map_full = utils.to_Nd(map, 4)
	map_flat = map_full.reshape(map_full.shape[:-2]+(-1,))
	sht      = sharp.sht(minfo, ainfo)
	for s, i1, i2 in enmap.spin_helper(spin, map_flat.shape[1]):
		alm_full[:,i1:i2,:] = sht.map2alm(map_flat[:,i1:i2,:], alm_full[:,i1:i2,:], spin=s)
	return alm