Skip to content

Commit 365eec8

Browse files
authored
Merge pull request #389 from lsst/tickets/DM-50232
DM-50232: Repeatability analysis tools should group on isolated_star_id
2 parents ce92f8a + 7142e64 commit 365eec8

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

python/lsst/analysis/tools/actions/vector/vectorActions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class PerGroupStatistic(VectorAction):
372372
by pandas DataFrameGroupBy.aggregate passed in as a string function name.
373373
"""
374374

375-
groupKey = Field[str](doc="Column key to use for forming groups", default="obj_index")
375+
groupKey = Field[str](doc="Column key to use for forming groups", default="isolated_star_id")
376376
buildAction = ConfigurableActionField[VectorAction](doc="Action to build vector", default=LoadVector)
377377
func = Field[str](doc="Name of function to be applied per group")
378378

@@ -389,7 +389,7 @@ class ResidualWithPerGroupStatistic(VectorAction):
389389
"""Compute residual between individual elements of group and the per-group
390390
statistic."""
391391

392-
groupKey = Field[str](doc="Column key to use for forming groups", default="obj_index")
392+
groupKey = Field[str](doc="Column key to use for forming groups", default="isolated_star_id")
393393
buildAction = ConfigurableActionField(doc="Action to build vector", default=LoadVector)
394394
func = Field[str](doc="Name of function to be applied per group", default="mean")
395395

python/lsst/analysis/tools/tasks/associatedSourcesTractAnalysis.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class AssociatedSourcesTractAnalysisConnections(
4545
defaultTemplates={
4646
"outputName": "isolated_star_presources",
4747
"associatedSourcesInputName": "isolated_star_presources",
48+
"associatedSourceIdsInputName": "isolated_star_presource_associations",
4849
},
4950
):
5051
sourceCatalogs = ct.Input(
@@ -64,19 +65,29 @@ class AssociatedSourcesTractAnalysisConnections(
6465
dimensions=("instrument", "skymap", "tract"),
6566
)
6667

68+
associatedSourceIds = ct.Input(
69+
doc="Table containing unique ids for the associated sources",
70+
name="{associatedSourceIdsInputName}",
71+
storageClass="ArrowAstropy",
72+
deferLoad=True,
73+
dimensions=("instrument", "skymap", "tract"),
74+
)
75+
6776
skyMap = ct.Input(
6877
doc="Input definition of geometry/bbox and projection/wcs for warped exposures",
6978
name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
7079
storageClass="SkyMap",
7180
dimensions=("skymap",),
7281
)
82+
7383
camera = ct.PrerequisiteInput(
7484
doc="Input camera to use for focal plane geometry.",
7585
name="camera",
7686
storageClass="Camera",
7787
dimensions=("instrument",),
7888
isCalibration=True,
7989
)
90+
8091
astrometricCorrectionCatalogs = ct.Input(
8192
doc="Catalog containing proper motion and parallax.",
8293
name="gbdesAstrometricFit_starCatalog",
@@ -85,6 +96,7 @@ class AssociatedSourcesTractAnalysisConnections(
8596
multiple=True,
8697
deferLoad=True,
8798
)
99+
88100
visitTable = ct.Input(
89101
doc="Catalog containing visit information.",
90102
name="visitTable",
@@ -149,6 +161,7 @@ def callback(self, inputs, dataId):
149161
dataId["tract"],
150162
inputs["sourceCatalogs"],
151163
inputs["associatedSources"],
164+
inputs["associatedSourceIds"],
152165
inputs["astrometricCorrectionCatalogs"],
153166
inputs["visitTable"],
154167
)
@@ -159,16 +172,23 @@ def prepareAssociatedSources(
159172
tract,
160173
sourceCatalogs,
161174
associatedSources,
175+
associatedSourceIds,
162176
astrometricCorrectionCatalogs=None,
163177
visitTable=None,
164178
):
165-
"""Concatenate source catalogs and join on associated object index."""
179+
"""Concatenate source catalogs and join on associated source IDs."""
166180

167181
# Strip any provenance from tables before merging to prevent
168182
# warnings from conflicts being issued by astropy.utils.merge.
169183
for srcCat in sourceCatalogs:
170184
DatasetProvenance.strip_provenance_from_flat_dict(srcCat.meta)
171185
DatasetProvenance.strip_provenance_from_flat_dict(associatedSources.meta)
186+
DatasetProvenance.strip_provenance_from_flat_dict(associatedSourceIds.meta)
187+
188+
# associatedSource["obj_index"] refers to the corresponding index (row)
189+
# in associatedSourceIds.
190+
index = associatedSources["obj_index"]
191+
associatedSources["isolated_star_id"] = associatedSourceIds["isolated_star_id"][index]
172192

173193
# Keep only sources with associations
174194
sourceCatalogStack = vstack(sourceCatalogs, join_type="exact")
@@ -273,7 +293,10 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
273293
# Load specified columns from source catalogs
274294
names = self.collectInputNames()
275295
names |= {"sourceId", "coord_ra", "coord_dec"}
276-
names.remove("obj_index")
296+
for item in ["obj_index", "isolated_star_id"]:
297+
if item in names:
298+
names.remove(item)
299+
277300
sourceCatalogs = []
278301
for handle in inputs["sourceCatalogs"]:
279302
sourceCatalogs.append(self.loadData(handle, names))
@@ -296,6 +319,7 @@ def runQuantum(self, butlerQC, inputRefs, outputRefs):
296319

297320
# TODO: make key used for object index configurable
298321
inputs["associatedSources"] = self.loadData(inputs["associatedSources"], ["obj_index", "sourceId"])
322+
inputs["associatedSourceIds"] = self.loadData(inputs["associatedSourceIds"], ["isolated_star_id"])
299323

300324
if len(inputs["associatedSources"]) == 0:
301325
raise NoWorkFound(f"No associated sources in tract {dataId.tract.id}")

0 commit comments

Comments
 (0)