def eval_ipol(ipol, hor): n = hor.shape[1] dtype = hor.dtype pix = np.zeros((1, n, 2), dtype=dtype) phase = np.zeros((1, n, 3), dtype=dtype) det_pos = np.zeros((1, 3)) det_comps = np.array([[1, 1, 0]]) comps = np.zeros(1) rbox, nbox, ys = pmat.extract_interpol_params(ipol, dtype) pmat.get_core(dtype).translate(hor, pix.T, phase.T, det_pos.T, det_comps.T, comps, rbox.T, nbox, ys.T) return np.concatenate([pix[0].T, phase[0, :, 1:].T], 0)
def eval_ipol(ipol, hor): n = hor.shape[1] dtype = hor.dtype pix = np.zeros((1,n,2),dtype=dtype) phase = np.zeros((1,n,3),dtype=dtype) det_pos = np.zeros((1,3)) det_comps = np.array([[1,1,0]]) comps = np.zeros(1) rbox, nbox, ys = pmat.extract_interpol_params(ipol, dtype) pmat.get_core(dtype).translate( hor, pix.T, phase.T, det_pos.T, det_comps.T, comps, rbox.T, nbox, ys.T) return np.concatenate([pix[0].T,phase[0,:,1:].T],0)
def project_tod_on_workspace(scan, tod, wgeo): """Compute the tod onto a map using the pixelization defined in the workspace, and return it along with a [TQU,TQU] hitmap and a hits-by-detector-by-y array.""" rhs = enmap.zeros(wgeo.shape, wgeo.lwcs, wgeo.dtype) hdiv = enmap.zeros((rhs.shape[:1] + rhs.shape), rhs.wcs, rhs.dtype) # Project it onto the workspace pcut = pmat.PmatCut(scan) pmap = PmatWorkspaceTOD(scan, wgeo) pix, phase = pmap.get_pix_phase() # Build rhs junk = np.zeros(pcut.njunk, dtype=rhs.dtype) pcut.backward(tod, junk) pmap.backward(tod, rhs, pix, phase) # Build div tmp = hdiv[0].copy() for i in range(ncomp): tmp[:] = np.eye(ncomp)[i, :, None, None] pmap.forward(tod, tmp, pix, phase) pcut.backward(tod, junk) pmap.backward(tod, hdiv[i], pix, phase) # Find each detector's hits by wy. Some detectors have # sufficient residual curvature that they hit every wy. yhits = np.zeros([scan.ndet, rhs.shape[-2]], dtype=np.int32) core = pmat.get_core(dtype) core.bincount_flat(yhits.T, pix.T, rhs.shape[-2:], 0) return rhs, hdiv, yhits
def project_tod_on_workspace(scan, tod, wgeo): """Compute the tod onto a map using the pixelization defined in the workspace, and return it along with a [TQU,TQU] hitmap and a hits-by-detector-by-y array.""" rhs = enmap.zeros(wgeo.shape, wgeo.lwcs, wgeo.dtype) hdiv = enmap.zeros((rhs.shape[:1]+rhs.shape),rhs.wcs, rhs.dtype) # Project it onto the workspace pcut = pmat.PmatCut(scan) pmap = PmatWorkspaceTOD(scan, wgeo) pix, phase = pmap.get_pix_phase() # Build rhs junk = np.zeros(pcut.njunk,dtype=rhs.dtype) pcut.backward(tod, junk) pmap.backward(tod, rhs, pix, phase) # Build div tmp = hdiv[0].copy() for i in range(ncomp): tmp[:] = np.eye(ncomp)[i,:,None,None] pmap.forward(tod, tmp, pix, phase) pcut.backward(tod, junk) pmap.backward(tod, hdiv[i], pix, phase) # Find each detector's hits by wy. Some detectors have # sufficient residual curvature that they hit every wy. yhits = np.zeros([scan.ndet, rhs.shape[-2]],dtype=np.int32) core = pmat.get_core(dtype) core.bincount_flat(yhits.T, pix.T, rhs.shape[-2:], 0) return rhs, hdiv, yhits
def __init__(self, scan, wgeo): # Build the pointing interpolator self.trans = TransformPos2Pix(scan, wgeo.gwcs) self.poly = pmat.PolyInterpol(self.trans, scan.boresight, scan.offsets) # Build the pixel shift information. This assumes ces-like scans in equ-like systems self.sdir = pmat.get_scan_dir(scan.boresight[:, 1]) self.period = pmat.get_scan_period(scan.boresight[:, 1], scan.srate) self.wgeo = wgeo self.nphi = int(np.abs(360. / wgeo.gwcs.wcs.cdelt[0])) self.core = pmat.get_core(wgeo.dtype) self.scan = scan
def __init__(self, scan, wgeo): # Build the pointing interpolator self.trans = TransformPos2Pix(scan, wgeo.gwcs) self.poly = pmat.PolyInterpol(self.trans, scan.boresight, scan.offsets) # Build the pixel shift information. This assumes ces-like scans in equ-like systems self.sdir = pmat.get_scan_dir(scan.boresight[:,1]) self.period = pmat.get_scan_period(scan.boresight[:,1], scan.srate) self.wgeo = wgeo self.nphi = int(np.abs(360./wgeo.gwcs.wcs.cdelt[0])) self.core = pmat.get_core(wgeo.dtype) self.scan = scan
def __init__(self, wgeo): self.wgeo = wgeo self.nphi = int(np.abs(360. / wgeo.gwcs.wcs.cdelt[0])) self.core = pmat.get_core(wgeo.dtype)
T=273.15, P=550., hum=0.2, freq=150., lapse=0.0065) ncomp = 3 nsamp = args.nsamp ndet = args.ndet bits = config.get("map_bits") acc = config.get("pmat_accuracy") max_size = config.get("pmat_interpol_max_size") max_time = config.get("pmat_interpol_max_time") dtype = np.float64 if bits > 32 else np.float32 ptype = np.float64 core = pmat.get_core(dtype) dirs = [int(w) for w in args.dir.split(",")] np.random.seed(args.seed) def hor2cel(hor, toff): """Transform from [{tsec,az,el},nsamp] to [{ra,dec,c,s},nsamp], where tsec is the offset from toff. Toff is given in mjd.""" shape = hor.shape[1:] hor = hor.reshape(hor.shape[0], -1).astype(float) tmp = coordinates.transform("hor", "cel", hor[1:], time=hor[0] / 24 / 60 / 60 + toff, site=site, pol=True)
def add_weight_fortran(omap, pix_ranges, weights, nphi=0): core = pmat.get_core(dtype) core.add_rows(omap.T, pix_ranges[:,0], pix_ranges[:,1:].T, weights, nphi)
def __init__(self, wgeo): self.wgeo = wgeo self.nphi = int(np.abs(360./wgeo.gwcs.wcs.cdelt[0])) self.core = pmat.get_core(wgeo.dtype)
T = 273.15, P = 550., hum = 0.2, freq = 150., lapse= 0.0065) ncomp = 3 nsamp = args.nsamp ndet = args.ndet bits = config.get("map_bits") acc = config.get("pmat_accuracy") max_size = config.get("pmat_interpol_max_size") max_time = config.get("pmat_interpol_max_time") dtype = np.float64 if bits > 32 else np.float32 ptype = np.float64 core = pmat.get_core(dtype) dirs = [int(w) for w in args.dir.split(",")] np.random.seed(args.seed) def hor2cel(hor, toff): """Transform from [{tsec,az,el},nsamp] to [{ra,dec,c,s},nsamp], where tsec is the offset from toff. Toff is given in mjd.""" shape = hor.shape[1:] hor = hor.reshape(hor.shape[0],-1).astype(float) tmp = coordinates.transform("hor", "cel", hor[1:], time=hor[0]/24/60/60+toff, site=site, pol=True) res = np.zeros((4,)+tmp.shape[1:]) res[0] = utils.rewind(tmp[0], tmp[0,0]) res[1] = tmp[1] res[2] = np.cos(2*tmp[2]) res[3] = np.sin(2*tmp[2]) res = res.reshape(res.shape[:1]+shape)