def run( rerun, # Rerun name frame, # Frame number ccds, # CCD number patch, # Sky patch identifier config, # Configuration coords, # Skycell centre coordinates scale, # Pixel scale sizes, # Skycell size ): io = pipReadWrite.ReadWrite(suprimecam.SuprimecamMapper(rerun=rerun), ['visit', 'ccd'], config=config) warpProc = pipWarp.Warp(config=config) identList = list() for ccd in ccds: dataId = {'visit': frame, 'ccd': ccd} identList.append(dataId) warp = warpProc.run(identList, io.inButler, coords[0], coords[1], scale, sizes[0], sizes[1]) warpProc.write(io.outButler, { 'visit': frame, 'patch': patch }, {"warp": warp})
def run( rerun, # Rerun name frame1, # Frame number for input frame2, # Frame number for template diff, # Difference identifier for output patch, # Sky patch identifier config, # Configuration ): io = pipReadWrite.ReadWrite(suprimecam.SuprimecamMapper(rerun=rerun), ['visit'], config=config) diffProc = pipDiff.Diff(config=config) exp1 = io.inButler.get('warp', {'visit': frame1, 'patch': patch}) exp2 = io.inButler.get('warp', {'visit': frame2, 'patch': patch}) diffExp, sources, psf, apcorr, brightSources = diffProc.run(exp1, exp2) sources = afwDet.PersistableSourceVector(sources) diffProc.write(io.outButler, { 'diff': diff, 'patch': patch, 'filter': diffExp.getFilter().getName() }, { "diff": diffExp, "diffpsf": psf, "diffsources": sources })
def run( rerun, # Rerun name frames, # Frame number ccds, # CCD number mit, # MIT CCDs? config, # Configuration ): # log = pexLog.getDefaultLog() # log.setThreshold(log.DEBUG) mapper = suprimecam.SuprimecamMapper(rerun=rerun, mit=mit) io = pipReadWrite.ReadWrite(mapper, ['visit', 'ccd'], config=config) detProc = pipMaster.Master(config=config) identMatrix = list() for ccd in ccds: identList = list() for frame in frames: dataId = {'visit': frame, 'ccd': ccd} identList.append(dataId) identMatrix.append(identList) masterList = detProc.run(identMatrix, io.inButler, io.outButler) for master, ccd in zip(masterList, ccds): name = "%s-%d.fits" % (rerun, ccd) master.writeFits(name) print "Wrote %s" % name return
def _getSuprimeMapper(rootdir=None, calibdir=None, outrootdir=None): if rootdir is None: rootdir = os.path.join(os.environ['HOME'], 'lsst', 'ACT-data') if calibdir is None: calibdir = os.path.join(rootdir, 'CALIB') mapperArgs = dict(root=rootdir, calibRoot=calibdir, outputRoot=outrootdir) mapper = obsSc.SuprimecamMapper(**mapperArgs) #return mapper wrap = WrapperMapper(mapper) return wrap
def run( rerun, # Rerun name frame, # Frame number ccd, # CCD number config, # Configuration log=pexLog.Log.getDefaultLog(), # Log object ): roots = config['roots'] registry = os.path.join(roots['data'], 'registry.sqlite3') imapp = suprimecam.SuprimecamMapper(rerun=rerun, root=roots['data'], calibRoot=roots['calib']) omapp = suprimecam.SuprimecamMapper(rerun=rerun, root=roots['output'], calibRoot=roots['calib'], registry=registry) io = pipReadWrite.ReadWrite([imapp, omapp], ['visit', 'ccd'], config=config) ccdProc = pipProcCcd.ProcessCcd(config=config, Isr=pipSuprimeCam.IsrSuprimeCam, log=log) dataId = {'visit': frame, 'ccd': ccd} raws = io.readRaw(dataId) detrends = io.detrends(dataId, config) exposure, psf, apcorr, brightSources, sources, matches, matchMeta = ccdProc.run( raws, detrends) io.write(dataId, exposure=exposure, psf=psf, sources=sources, matches=matches, matchMeta=matchMeta) catPolicy = os.path.join(os.getenv("PIPETTE_DIR"), "policy", "catalog.paf") catalog = pipCatalog.Catalog(catPolicy, allowNonfinite=False) basename = os.path.join(roots['output'], '%s-%d%d' % (rerun, frame, ccd)) if sources is not None: catalog.writeSources(basename + '.sources', sources, 'sources') if matches is not None: catalog.writeMatches(basename + '.matches', matches, 'sources') return
def run( rerun, # Rerun name frame, # Frame number ccd, # CCD number config, # Configuration log=pexLog.Log.getDefaultLog(), # Log object ): # Make our own mappers for now mapperArgs = {'rerun': rerun} # Arguments for mapper instantiation if config.has_key('roots'): roots = config['roots'] for key, value in { 'data': 'root', 'calib': 'calibRoot', 'output': 'outRoot' }.iteritems(): if roots.has_key(key): mapperArgs[value] = roots[key] camera = config['camera'] if camera.lower() in ("hsc"): mapper = obsHsc.HscSimMapper(**mapperArgs) ccdProc = pipCcd.ProcessCcd(config=config, Calibrate=CalibrateHscDc2, log=log) elif camera.lower() in ("suprimecam-mit", "sc-mit", "scmit", "suprimecam-old", "sc-old", "scold"): mapper = obsSc.SuprimecamMapper(mit=True, **mapperArgs) ccdProc = ProcessCcdSuprimeCam(config=config, log=log) elif camera.lower() in ("suprimecam", "suprime-cam", "sc"): mapper = obsSc.SuprimecamMapper(**mapperArgs) ccdProc = ProcessCcdSuprimeCam(config=config, log=log) io = pipReadWrite.ReadWrite(mapper, ['visit', 'ccd'], config=config) oldUmask = os.umask(2) if oldUmask != 2: io.log.log(io.log.WARN, "pipette umask started as: %s" % (os.umask(2))) dataId = {'visit': frame, 'ccd': ccd} raws = io.readRaw(dataId) detrends = io.detrends(dataId, config) if len([x for x in detrends if x]): # We need to run at least part of the ISR raws = io.readRaw(dataId) else: io.fileKeys = ['visit', 'ccd'] try: raws = io.read('calexp', dataId) config['do']['calibrate']['repair']['cosmicray'] = False except: raws = io.readRaw(dataId) detrends = None exposure, psf, apcorr, brightSources, sources, matches, matchMeta = ccdProc.run( raws, detrends) io.write(dataId, exposure=None, psf=psf, sources=None) catPolicy = os.path.join(os.getenv("PIPETTE_DIR"), "policy", "catalog.paf") catalog = pipCatalog.Catalog(catPolicy, allowNonfinite=False) deferredState = DeferredHSCState(dataId, io, matches, matchMeta, sources, brightSources, exposure) return deferredState
di = lsstDebug.getInfo(name) #if name == 'lsst.meas.algorithms.measurement': # di.display = True if name == '__main__': #di.display = True pass return di lsstDebug.Info = MyInfo if __name__ == '__main__': basedir = os.path.join(os.environ['HOME'], 'lsst', 'ACT-data') mapperArgs = dict(root=os.path.join(basedir, 'rerun/dstn'), calibRoot=os.path.join(basedir, 'CALIB')) mapper = obsSc.SuprimecamMapper(**mapperArgs) butlerFactory = dafPersist.ButlerFactory(mapper=mapper) butler = butlerFactory.create() print 'Butler', butler dataRef = butler.subset('raw', dataId=dict(visit=126969, ccd=5)) print 'dataRef:', dataRef #dataRef.butlerSubset = dataRef #print 'dataRef:', dataRef print 'len(dataRef):', len(dataRef) for dr in dataRef: print ' ', dr conf = procCcd.ProcessCcdConfig() conf.measurement.doRemoveOtherSources = True conf.doDetection = True