Coverage for tests / cat_add_deblend_flags.py: 0%
14 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:29 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-24 08:29 +0000
1# Add deblend and primary fields, and centroid flag to the the astrometry test catalog.
2import numpy as np
3from lsst.afw.table import SourceCatalog, SchemaMapper
5catalog = SourceCatalog.readFits("cat.xy.fits")
6mapper = SchemaMapper(catalog.schema)
7mapper.addMinimalSchema(catalog.schema)
8# nChild field can remain 0; we don't want to change existing test behavior.
9mapper.addOutputField("deblend_nChild", type=np.int32,
10 doc='Number of children this object has (defaults to 0)')
11# We want all sources to be primary sources.
12mapper.addOutputField("detect_isPrimary", type=np.int32,
13 doc="true if source has no children and is not a sky source")
14# We want all sources to have valid centroids (i.e. flag=0).
15mapper.addOutputField("base_SdssCentroid_flag", type="Flag",
16 doc="General centroid failure flag")
18schema = mapper.getOutputSchema()
19schema.setAliasMap(catalog.schema.getAliasMap())
21new_catalog = SourceCatalog(schema)
22new_catalog.extend(catalog, mapper=mapper)
23new_catalog['detect_isPrimary'] = 1
25new_catalog.writeFits("cat.xy.fits")