DM-50420: Inject variable sources into the template and science images#1313
DM-50420: Inject variable sources into the template and science images#1313BrunoSanchez wants to merge 1 commit into
Conversation
a7d364a to
9ff8adb
Compare
9ff8adb to
dd01b6b
Compare
isullivan
left a comment
There was a problem hiding this comment.
A number of minor changes, but please think about whether the injectedCat->injectionCat rename is necessary.
| ConfigClass = MatchInjectedToDiaSourceConfig | ||
|
|
||
| def run(self, injectedCat, diffIm, diaSources): | ||
| # def run(self, injectedCat, injectedTemplateCat, diffIm, diaSources): |
There was a problem hiding this comment.
Remove commented-out code
| if column.endswith("instFlux"): | ||
| flux = injectedCat[column] | ||
| fluxErr = injectedCat[column+"Err"].copy() | ||
| # flux = injectionCat[column] |
There was a problem hiding this comment.
Remove commented-out code
| """ | ||
| # First match the diaSrc to the injected fakes | ||
| injectedCat = injectedCat.to_pandas() | ||
| # injectedCat = injectedCat.to_pandas() |
There was a problem hiding this comment.
Remove commented-out code
| idxsAux = np.where(np.array(idxs) < len(diaSources), idxs, -1) | ||
| idxsBackMatched = np.where(idxsAux >= 0, idxsBack[idxsAux], -1) |
There was a problem hiding this comment.
| idxsAux = np.where(np.array(idxs) < len(diaSources), idxs, -1) | |
| idxsBackMatched = np.where(idxsAux >= 0, idxsBack[idxsAux], -1) | |
| valid = idxsAux >= 0 | |
| idxsBackMatched = np.full_like(idxsAux, -1) | |
| idxsBackMatched[valid] = idxsBack[idxsAux[valid]] |
To better avoid edge cases when idxsAux=-1.
| variableDoublesFakeCat['dist_diaSrc'] = -1 | ||
|
|
||
| # Match variable sources to their twin's matched diaSource | ||
| for i, row in enumerate(variableDoublesFakeCat): |
There was a problem hiding this comment.
I worry that this loop over the fake sources will get very slow for large numbers of injected fakes. Could you use astropy.table.join?
| injectedCat = connTypes.Input( | ||
| injectionCat = connTypes.Input( |
There was a problem hiding this comment.
This connection name change breaks previous pipelines and tests. Is it necessary? If so, you'll need to update drp_pipe as well.
| injectionCat = connTypes.Input( | ||
| doc="Catalog of sources injected in the images.", | ||
| name="{fakesType}_pvi_catalog", | ||
| name="{fakesType}VisitDetectorFakeSourceCat", |
There was a problem hiding this comment.
Should {fakesType} be dropped from all of the connections?
|
|
||
| def run(self, injectedCat, diffIm, diaSources): | ||
| # def run(self, injectedCat, injectedTemplateCat, diffIm, diaSources): | ||
| def run(self, injectionCat, diffIm, diaSources): |
There was a problem hiding this comment.
See above comment on injectedCat vs injectionCat
|
|
||
| Parameters | ||
| ---------- | ||
| fakeCat : `astropy.table.table.Table` |
There was a problem hiding this comment.
One too many .table I think. Below as well.
| """ | ||
| # Match the fakes to the associated sources. For this we don't use the coordinates | ||
| # but instead check for the diaSources. Since they were present in the table already | ||
| if not isinstance(assocDiaSources, Table): |
There was a problem hiding this comment.
Is this necessary, now that the connection is being read as Astropy?
Fix matching to account for template fakes and mutual match strategy