I have two catalogues in python, both are of type:
<lsst.afw.table.tableLib.SourceCatalog; proxy of <Swig Object of type 'lsst::afw::table::SortedCatalogT< lsst::afw::table::SourceRecord > *' at 0xdeadbeef> >
What’s the best way of creating one table by concatenating one onto the other, schematically, e.g.:
table1 += table2
+= doesn’t currently work,
table1.extend(table2) does work.
However, there’s a caveat: unlike NumPy arrays, catalogs aren’t necessarily stored in one block of memory, but you can only access NumPy views to catalog columns when the catalog is one contiguous block of memory. In general, when you concatenate catalogs, they won’t be contiguous, because it’ll just do a shallow copy of the records (i.e. they’ll be shared).
To do a deep copy of the records, you can use
table1.extend(table2, deep=True) - but even that won’t give you a contiguous catalog when concatenating, because it won’t reallocate all of the existing records in table1.
The easiest way to get a contiguous catalog is to just copy the result after concatenating:
result = table1.copy(deep=True)