def __init__(self, data, srcpos, ndir=1, sys=sys): # Build source parameter struct for PmatPtsrc self.params = np.zeros([srcpos.shape[-1], ndir, 8], np.float) self.params[:, :, :2] = srcpos[::-1, None, :].T self.params[:, :, 5:7] = 1 scan = actscan.ACTScan(data.entry, d=data) self.psrc = pmat.PmatPtsrc(scan, self.params, sys=sys) self.pcut = pmat.PmatCut(scan) # Extract basic offset self.off0 = data.point_correction self.off = self.off0 * 1 self.el = np.mean(data.boresight[2, ::100]) self.point_template = data.point_template
def __init__(self, scan, srcpos, ndir=1, perdet=False, sys="cel"): # Build source parameter struct for PmatPtsrc self.params = np.zeros([srcpos.shape[-1],ndir,scan.ndet if perdet else 1,8],np.float) self.params[:,:,:,:2] = srcpos[::-1,None,None,:].T self.params[:,:,:,5:7] = 1 self.psrc = pmat.PmatPtsrc(scan, self.params, sys=sys) self.pcut = pmat.PmatCut(scan) # Extract basic offset. Warning: referring to scan.d is fragile, since # scan.d is not updated when scan is sliced self.off0 = scan.d.point_correction self.off = self.off0*0 self.el = np.mean(scan.boresight[::100,2]) self.point_template = scan.d.point_template self.cut = scan.cut
def point_source_cut(d, srcs, thresholds=[]): if len(thresholds) == 0: return [] # Sort-of-circular dependency here. I don't like # how actdata datasets are incompatible with scans. # Should I just replace scans with actdata objects? from . import actscan # Simulate sources tod = np.zeros((d.ndet, d.nsamp), np.float32) srcs = srcs.astype(np.float64) scan = actscan.ACTScan(d.entry, d=d) psrc = pmat.PmatPtsrc(scan, srcs) psrc.forward(tod, srcs) # Use them to define mask cuts = [sampcut.from_mask(tod > tr) for tr in thresholds] return cuts
except (IOError, OSError): try: d = actscan.ACTScan(db[filelist[ind]]) if d.ndet == 0 or d.nsamp == 0: raise errors.DataMissing("all samples cut") except errors.DataMissing as e: L.debug("Skipped %s (%s)" % (filelist[ind], str(e))) continue try: L.debug("Reading samples") tod = d.get_samples().astype(dtype) except errors.DataMissing as e: L.debug("Skipped %s (%s)" % (filelist[ind], str(e))) continue # Measure noise L.debug("Noise") ivar = 1/np.array([np.median(onlyfinite(get_desloped_var(blockify(t,20)))) for t in tod]) # Set up pmat for this scan L.debug("Pmats") d.noise = bunch.Bunch(ivar = ivar) Psrc = pmat.PmatPtsrc(d, params.T) # Extract point-source relevant TOD properties L.debug("Extract data") srcdata = Psrc.extract(tod, cut=d.cut, raw=not args.oldformat) #srcdata.ivars = d.noise.iD[-1] srcdata.ivars = ivar L.debug("Writing") ptsrc_data.write_srcscan(ofile, srcdata)
ivar = 1 / (np.median(np.mean(diff**2, -1), -1) / 2**0.5) del diff print "D", id, comm.rank with bench.mark("actscan"): scan = actscan.ACTScan(entry, d=d) print "E", id, comm.rank with bench.mark("pmat1"): # Build effective source parameters for this TOD. This will ignore planet motion, # but this should only be a problem for very near objects like the moon or ISS src_param = np.zeros((len(srcs), 8)) src_param[:, 0] = srcs.dec src_param[:, 1] = srcs.ra src_param[:, 2] = 1 src_param[:, 5:7] = 1 # And use it to build our source model projector. This is only used for the cuts psrc = pmat.PmatPtsrc(scan, src_param) print "F", id, comm.rank with bench.mark("source mask"): # Find the samples where the sources live src_mask = np.zeros(tod.shape, np.bool) # Allow elongating the mask vertically nypad = 1 dypad = R / 2 if ypad > 0: nypad = int((2 * ypad) // dypad) + 1 dypad = (2 * ypad) / (nypad - 1) # Hack: modify detector offsets to apply the y broadening detoff = scan.offsets.copy() src_tod = tod * 0 for yi in range(nypad): yoff = -ypad + yi * dypad