22 __all__ = [
"denormalizeMatches"]
28 """Generate a denormalized Catalog of matches 32 matches : `list` of `lsst.afw.table.ReferenceMatch` 33 List of matches between reference catalog and source catalog. 34 matchMeta : `lsst.daf.base.PropertyList` 35 Matching metadata to write in catalog. 39 catalog : `lsst.afw.table.BaseCatalog` 40 Catalog containing matchlist entries. 44 This is intended for writing matches in a convenient way. 45 Normally we write matches in a 'normalized' form: recording only the join 46 table (reference ID, source ID) to minimise space (the reference and source 47 catalogs should both be available separately, so the only extra information 48 we need is how to join them). However, using that can be a pain, since it 49 requires reading each catalog and doing the join. 51 This function generates a Catalog containing all the information in the 52 matches. The reference catalog entries are in columns with 'ref' 53 prepended, while the source catalog entries are in columns with 'src' 54 prepended (including any alias mappings). The distance between the 55 matches is in a column named "distance". 59 lsst.afw.table.packMatches 65 raise RuntimeError(
"No matches provided.")
67 refSchema = matches[0].first.getSchema()
68 srcSchema = matches[0].second.getSchema()
70 refMapper, srcMapper = afwTable.SchemaMapper.join([refSchema, srcSchema], [
"ref_",
"src_"])
71 schema = refMapper.editOutputSchema()
73 schema = afwTable.catalogMatches.copyAliasMapWithPrefix(srcSchema, schema, prefix=
"src_")
74 schema = afwTable.catalogMatches.copyAliasMapWithPrefix(refSchema, schema, prefix=
"ref_")
76 distKey = schema.addField(
"distance", type=float, doc=
"Distance between ref and src")
79 catalog.reserve(len(matches))
81 row = catalog.addNew()
82 row.assign(mm.first, refMapper)
83 row.assign(mm.second, srcMapper)
84 row.set(distKey, mm.distance)
86 if matchMeta
is not None:
87 catalog.getTable().setMetadata(matchMeta)
def denormalizeMatches(matches, matchMeta=None)