def run(): exposure, srcCat = loadData() schema = srcCat.getSchema() # # Create the astrometry task # config = AstrometryTask.ConfigClass() config.refObjLoader.filterMap = {"_unknown_": "r"} config.matcher.sourceFluxType = "Psf" # sample catalog does not contain aperture flux aTask = AstrometryTask(config=config) # # And the photometry Task # config = PhotoCalTask.ConfigClass() config.applyColorTerms = False # we don't have any available, so this suppresses a warning pTask = PhotoCalTask(config=config, schema=schema) # # The tasks may have added extra elements to the schema (e.g. AstrometryTask's centroidKey to # handle distortion; photometryTask's config.outputField). If this is so, we need to add # these columns to the Source table. # # We wouldn't need to do this if we created the schema prior to measuring the exposure, # but in this case we read the sources from disk # if schema != srcCat.getSchema(): # the tasks added fields print("Adding columns to the source catalogue") cat = afwTable.SourceCatalog(schema) cat.table.defineCentroid(srcCat.table.getCentroidDefinition()) cat.table.definePsfFlux(srcCat.table.getPsfFluxDefinition()) scm = afwTable.SchemaMapper(srcCat.getSchema(), schema) for schEl in srcCat.getSchema(): scm.addMapping(schEl.getKey(), True) cat.extend(srcCat, True, scm) # copy srcCat to cat, adding new columns srcCat = cat del cat # # Process the data # matches = aTask.run(exposure, srcCat).matches result = pTask.run(exposure, matches) calib = result.calib fm0, fm0Err = calib.getFluxMag0() print("Used %d calibration sources out of %d matches" % (len(result.matches), len(matches))) delta = result.arrays.refMag - result.arrays.srcMag q25, q75 = np.percentile(delta, [25, 75]) print("RMS error is %.3fmmsg (robust %.3f, Calib says %.3f)" % (np.std(delta), 0.741 * (q75 - q25), 2.5 / np.log(10) * fm0Err / fm0))
def run(): exposure, srcCat = loadData() schema = srcCat.getSchema() # # Create the reference catalog loader # refCatDir = os.path.join(lsst.utils.getPackageDir('meas_astrom'), 'tests', 'data', 'sdssrefcat') butler = Butler(refCatDir) refObjLoader = LoadIndexedReferenceObjectsTask(butler=butler) # # Create the astrometry task # config = AstrometryTask.ConfigClass() config.matcher.sourceFluxType = "Psf" # sample catalog does not contain aperture flux config.matcher.minSnr = 0 # disable S/N test because sample catalog does not contain flux sigma aTask = AstrometryTask(config=config, refObjLoader=refObjLoader) # # And the photometry Task # config = PhotoCalTask.ConfigClass() config.applyColorTerms = False # we don't have any available, so this suppresses a warning # The associated data has been prepared on the basis that we use PsfFlux to perform photometry. config.fluxField = "base_PsfFlux_flux" pTask = PhotoCalTask(config=config, schema=schema) # # The tasks may have added extra elements to the schema (e.g. AstrometryTask's centroidKey to # handle distortion; photometryTask's config.outputField). If this is so, we need to add # these columns to the Source table. # # We wouldn't need to do this if we created the schema prior to measuring the exposure, # but in this case we read the sources from disk # if schema != srcCat.getSchema(): # the tasks added fields print("Adding columns to the source catalogue") cat = afwTable.SourceCatalog(schema) cat.table.defineCentroid(srcCat.table.getCentroidDefinition()) cat.table.definePsfFlux(srcCat.table.getPsfFluxDefinition()) scm = afwTable.SchemaMapper(srcCat.getSchema(), schema) for schEl in srcCat.getSchema(): scm.addMapping(schEl.getKey(), True) cat.extend(srcCat, True, scm) # copy srcCat to cat, adding new columns srcCat = cat del cat # # Process the data # matches = aTask.run(exposure, srcCat).matches result = pTask.run(exposure, matches) calib = result.calib fm0, fm0Err = calib.getFluxMag0() print("Used %d calibration sources out of %d matches" % (len(result.matches), len(matches))) delta = result.arrays.refMag - result.arrays.srcMag q25, q75 = np.percentile(delta, [25, 75]) print("RMS error is %.3fmmsg (robust %.3f, Calib says %.3f)" % (np.std(delta), 0.741 * (q75 - q25), 2.5 / np.log(10) * fm0Err / fm0))