Currently, if I want to copy a table while adding a few columns (as specified by schema in the example) I need to do something like:
cat = afwTable.SourceCatalog(schema)
|
cat.table.defineCentroid(srcCat.table.getCentroidDefinition())
|
cat.table.definePsfFlux(srcCat.table.getPsfFluxDefinition())
|
# etc.
|
|
scm = afwTable.SchemaMapper(srcCat.getSchema(), schema)
|
for schEl in srcCat.getSchema():
|
scm.addMapping(schEl.getKey(), True)
|
|
cat.extend(srcCat, True, scm)
|
Please make this easier! For example
- by adding a flag to the SchemaMapper constructor that automatically does the addMapping (should this be the default?)
- by making it possible to copy all the slots (maybe this'll be the case when the new alias scheme is implemented?).
Maybe we just need a new method:
cat = srcCat.extend(schema)
|
that does all the above steps.