Exemplo n.º 1
0
def solve(w,m):
	if w.ndim < 4: return m/w
	elif w.ndim == 4:
		# This is slower, but handles low-hit areas near the edge better
		iw = array_ops.eigpow(w,-1,axes=[0,1])
		return enmap.samewcs(array_ops.matmul(iw,m,axes=[0,1]), m)
		#return array_ops.solve_masked(w,m,axes=[0,1])
	else: raise NotImplementedError("Only 2d, 3d or 4d weight maps understood")
Exemplo n.º 2
0
def solve(w,m):
	if w.ndim < 4: return m/w
	elif w.ndim == 4:
		# This is slower, but handles low-hit areas near the edge better
		iw = array_ops.eigpow(w,-1,axes=[0,1])
		return enmap.samewcs(array_ops.matmul(iw,m,axes=[0,1]), m)
		#return array_ops.solve_masked(w,m,axes=[0,1])
	else: raise NotImplementedError("Only 2d, 3d or 4d weight maps understood")
Exemplo n.º 3
0
def mul(w, m):
    if w.ndim < 4: return m * w
    elif w.ndim == 4:
        return enmap.samewcs(array_ops.matmul(w, m, axes=[0, 1]), m)
    else:
        raise NotImplementedError("Only 2d, 3d or 4d weight maps understood")
Exemplo n.º 4
0
    return enmap.samewcs(map[utils.transpose_inds(dets, nrow, ncol)], map)


# Read our map, and give each row a weight
pickup = enmap.read_map(args.pickup_map)
pickup = reorder(pickup, nrow, ncol, d.dets)
weight = np.median((pickup[:, 1:] - pickup[:, :-1])**2, -1)
weight[weight > 0] = 1 / weight[weight > 0]

# Find the output pixel for each input pixel
baz = pickup[:1].posmap()[1, 0]
bel = baz * 0 + args.el * utils.degree
ipoint = np.array([baz, bel])

opoint = ipoint[:, None, :] + d.point_offset.T[:, :, None]
opix = template.sky2pix(opoint[::-1]).astype(int)  # [{y,x},ndet,naz]
opix = np.rollaxis(opix, 1)  # [ndet,{y,x},naz]

omap = enmap.zeros((3, ) + template.shape[-2:], template.wcs)
odiv = enmap.zeros((3, 3) + template.shape[-2:], template.wcs)
for det in range(d.ndet):
    omap += utils.bin_multi(opix[det], template.shape[-2:], weight[det] *
                            pickup[det]) * d.det_comps[det, :, None, None]
    odiv += utils.bin_multi(
        opix[det], template.shape[-2:], weight[det]) * d.det_comps[
            det, :, None, None, None] * d.det_comps[det, None, :, None, None]

odiv = enmap.samewcs(array_ops.eigpow(odiv, -1, axes=[0, 1]), odiv)
omap = enmap.samewcs(array_ops.matmul(odiv, omap, axes=[0, 1]), omap)
enmap.write_map(args.ofile, omap)
Exemplo n.º 5
0
 def M(self, x):
     map = self.dof.unzip(x)
     map[:] = array_ops.matmul(self.prec, map, [0, 1])
     return self.dof.zip(map)
Exemplo n.º 6
0
 def __call__(self, m):
     for idtile, mtile in zip(self.idiv.tiles, m.tiles):
         mtile[:] = array_ops.matmul(idtile, mtile, axes=[0, 1])
Exemplo n.º 7
0
 def __call__(self, m):
     m[:] = array_ops.matmul(self.idiv, m, axes=[0, 1])
Exemplo n.º 8
0
def mul(mat, vec, axes=[0, 1]):
    return enmap.samewcs(
        array_ops.matmul(mat.astype(vec.dtype), vec, axes=axes), mat, vec)
Exemplo n.º 9
0
def mul(w,m):
	if w.ndim < 4: return m*w
	elif w.ndim == 4: return enmap.samewcs(array_ops.matmul(w,m, axes=[0,1]),m)
	else: raise NotImplementedError("Only 2d, 3d or 4d weight maps understood")
Exemplo n.º 10
0
Arquivo: gibbs.py Projeto: jit9/enlib
def mul(mat, vec, axes):
    return array_ops.matmul(mat.astype(vec.dtype), vec, axes=axes)
Exemplo n.º 11
0
	def M(self, x):
		map = self.dof.unzip(x)
		map[:] = array_ops.matmul(self.prec, map, [0,1])
		return self.dof.zip(map)
Exemplo n.º 12
0
d.boresight[2] = args.el # In degrees, calibrated in next step
d = actdata.calibrate(d, exclude=["autocut"])

def reorder(map, nrow, ncol, dets):
	return enmap.samewcs(map[utils.transpose_inds(dets,nrow,ncol)],map)

# Read our map, and give each row a weight
pickup = enmap.read_map(args.pickup_map)
pickup = reorder(pickup, nrow, ncol, d.dets)
weight = np.median((pickup[:,1:]-pickup[:,:-1])**2,-1)
weight[weight>0] = 1/weight[weight>0]

# Find the output pixel for each input pixel
baz = pickup[:1].posmap()[1,0]
bel = baz*0 + args.el * utils.degree
ipoint = np.array([baz,bel])

opoint = ipoint[:,None,:] + d.point_offset.T[:,:,None]
opix   = template.sky2pix(opoint[::-1]).astype(int) # [{y,x},ndet,naz]
opix   = np.rollaxis(opix, 1) # [ndet,{y,x},naz]

omap = enmap.zeros((3,)+template.shape[-2:], template.wcs)
odiv = enmap.zeros((3,3)+template.shape[-2:], template.wcs)
for det in range(d.ndet):
	omap += utils.bin_multi(opix[det], template.shape[-2:], weight[det]*pickup[det]) * d.det_comps[det,:,None,None]
	odiv += utils.bin_multi(opix[det], template.shape[-2:], weight[det]) * d.det_comps[det,:,None,None,None] * d.det_comps[det,None,:,None,None]

odiv = enmap.samewcs(array_ops.eigpow(odiv,   -1, axes=[0,1]), odiv)
omap = enmap.samewcs(array_ops.matmul(odiv, omap, axes=[0,1]), omap)
enmap.write_map(args.ofile, omap)