LSSTApplications  18.0.0+46,18.0.0+93,19.0.0,19.0.0+1,19.0.0+2,19.0.0+3,19.0.0+4,19.0.0-1-g20d9b18+2,19.0.0-1-g3dc8cbe+2,19.0.0-1-g425ff20,19.0.0-1-g5549ca4,19.0.0-1-g580fafe+2,19.0.0-1-g5db401e+3,19.0.0-1-g6fe20d0+1,19.0.0-1-g7011481+2,19.0.0-1-g8c57eb9+2,19.0.0-1-g9828021+2,19.0.0-1-gb5175dc+2,19.0.0-1-gd7f3e1b+2,19.0.0-1-gdc0e4a7+2,19.0.0-1-ge272bc4+2,19.0.0-2-g0d9f9cd+2,19.0.0-2-g1c703f9ef+1,19.0.0-2-g3d9e4fb2+2,19.0.0-2-gd955cfd+2,19.0.0-3-g2d13df8,19.0.0-3-g63079e6+2,19.0.0-7-g8a434f2+1,19.0.0-7-gf796fef9+3,w.2019.49
LSSTDataManagementBasePackage
Functions
lsst.meas.astrom.denormalizeMatches Namespace Reference

Functions

def denormalizeMatches (matches, matchMeta=None)
 

Function Documentation

◆ denormalizeMatches()

def lsst.meas.astrom.denormalizeMatches.denormalizeMatches (   matches,
  matchMeta = None 
)
Generate a denormalized Catalog of matches

Parameters
----------
matches : `list` of `lsst.afw.table.ReferenceMatch`
    List of matches between reference catalog and source catalog.
matchMeta : `lsst.daf.base.PropertyList`
    Matching metadata to write in catalog.

Returns
-------
catalog : `lsst.afw.table.BaseCatalog`
    Catalog containing matchlist entries.

Notes
-----
This is intended for writing matches in a convenient way.
Normally we write matches in a 'normalized' form: recording only the join
table (reference ID, source ID) to minimise space (the reference and source
catalogs should both be available separately, so the only extra information
we need is how to join them). However, using that can be a pain, since it
requires reading each catalog and doing the join.

This function generates a Catalog containing all the information in the
matches. The reference catalog entries are in columns with 'ref'
prepended, while the source catalog entries are in columns with 'src'
prepended (including any alias mappings). The distance between the
matches is in a column named "distance".

See Also
--------
lsst.afw.table.packMatches

Definition at line 27 of file denormalizeMatches.py.

27 def denormalizeMatches(matches, matchMeta=None):
28  """Generate a denormalized Catalog of matches
29 
30  Parameters
31  ----------
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.
36 
37  Returns
38  -------
39  catalog : `lsst.afw.table.BaseCatalog`
40  Catalog containing matchlist entries.
41 
42  Notes
43  -----
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.
50 
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".
56 
57  See Also
58  --------
59  lsst.afw.table.packMatches
60  """
61  # TODO: DM-16863 Current this link is removed due to the conversion of
62  # afw.table not yet being complete and causing an error on build.
63  # """
64  if len(matches) == 0:
65  raise RuntimeError("No matches provided.")
66 
67  refSchema = matches[0].first.getSchema()
68  srcSchema = matches[0].second.getSchema()
69 
70  refMapper, srcMapper = afwTable.SchemaMapper.join([refSchema, srcSchema], ["ref_", "src_"])
71  schema = refMapper.editOutputSchema()
72 
73  schema = afwTable.catalogMatches.copyAliasMapWithPrefix(srcSchema, schema, prefix="src_")
74  schema = afwTable.catalogMatches.copyAliasMapWithPrefix(refSchema, schema, prefix="ref_")
75 
76  distKey = schema.addField("distance", type=float, doc="Distance between ref and src")
77 
78  catalog = afwTable.BaseCatalog(schema)
79  catalog.reserve(len(matches))
80  for mm in matches:
81  row = catalog.addNew()
82  row.assign(mm.first, refMapper)
83  row.assign(mm.second, srcMapper)
84  row.set(distKey, mm.distance)
85 
86  if matchMeta is not None:
87  catalog.getTable().setMetadata(matchMeta)
88 
89  return catalog