LSST Applications g0000d66e7c+4a51730b0a,g0485b4d2cb+be65c9c1d7,g0fba68d861+eb108e5914,g1ec0fe41b4+3ea9d11450,g1fd858c14a+41d169aaf2,g2440f9efcc+8c5ae1fdc5,g35bb328faa+8c5ae1fdc5,g470b45d79c+bb7d8e732a,g4d2262a081+972b13e66a,g53246c7159+8c5ae1fdc5,g55585698de+c657de43f9,g56a49b3a55+7eddd92ad8,g60b5630c4e+c657de43f9,g67b6fd64d1+97cc007aa2,g78460c75b0+7e33a9eb6d,g786e29fd12+668abc6043,g7ac00fbb6c+088e1a4fa9,g8352419a5c+8c5ae1fdc5,g8852436030+3f3bba821f,g89139ef638+97cc007aa2,g94187f82dc+c657de43f9,g989de1cb63+97cc007aa2,g9d31334357+c657de43f9,g9f33ca652e+06d39d8afb,ga815be3f0b+8e7c4d07ad,gabe3b4be73+8856018cbb,gabf8522325+977d9fabaf,gb1101e3267+12c96a40b1,gb89ab40317+97cc007aa2,gc91f06edcd+2ffb87f22b,gcf25f946ba+3f3bba821f,gd6cbbdb0b4+1cc2750d2e,gde0f65d7ad+4ad7118dbf,ge278dab8ac+6b863515ed,ge410e46f29+97cc007aa2,gf35d7ec915+97dd712d81,gf5e32f922b+8c5ae1fdc5,gf67bdafdda+97cc007aa2,w.2025.19
LSST Data Management Base Package
|
Classes | |
class | MatchFakesConnections |
Variables | |
fakeCats : `pandas.DataFrame` | |
skyMap : `lsst.skymap.SkyMap` | |
diffIm : `lsst.afw.image.Exposure` | |
associatedDiaSources : `pandas.DataFrame` | |
result : `lsst.pipe.base.Struct` | |
fakeCat : `pandas.DataFrame` | |
combinedFakeCat : `pandas.DataFrame` | |
exposure : `lsst.afw.image.exposure.exposure.ExposureF` | |
movingFakeCat : `pandas.DataFrame` | |
image : `lsst.afw.image.exposure.exposure.ExposureF` | |
ras : `numpy.ndarray`, (N,) | |
decs : `numpy.ndarray`, (N,) | |
vectors : `numpy.ndarray`, (N, 3) | |
ccdVisitFakeMagnitudes : `pandas.DataFrame` | |
band : `str` | |
lsst.pipe.tasks.matchFakes.associatedDiaSources : `pandas.DataFrame` |
Definition at line 148 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.band : `str` |
Definition at line 427 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.ccdVisitFakeMagnitudes : `pandas.DataFrame` |
Definition at line 425 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.combinedFakeCat : `pandas.DataFrame` |
Definition at line 222 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.decs : `numpy.ndarray`, (N,) |
Definition at line 328 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.diffIm : `lsst.afw.image.Exposure` |
Definition at line 146 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.exposure : `lsst.afw.image.exposure.exposure.ExposureF` |
Definition at line 248 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.fakeCat : `pandas.DataFrame` |
fakeCat = self.composeFakeCat(fakeCats, skyMap) if self.config.doMatchVisit: fakeCat = self.getVisitMatchedFakeCat(fakeCat, diffIm) return self._processFakes(fakeCat, diffIm, associatedDiaSources) def _processFakes(self, fakeCat, diffIm, associatedDiaSources):
if len(fakeCats) == 1: return fakeCats[0].get() outputCat = [] for fakeCatRef in fakeCats: cat = fakeCatRef.get() tractId = fakeCatRef.dataId["tract"] # Make sure all data is within the inner part of the tract. outputCat.append(cat[ skyMap.findTractIdArray(cat[self.config.ra_col], cat[self.config.dec_col], degrees=False) == tractId]) return pd.concat(outputCat) def getVisitMatchedFakeCat(self, fakeCat, exposure):
selected = exposure.getInfo().getVisitInfo().getId() == fakeCat["visit"] return fakeCat[selected] def _addPixCoords(self, fakeCat, image):
wcs = image.getWcs() ras = fakeCat[self.config.ra_col].values decs = fakeCat[self.config.dec_col].values xs, ys = wcs.skyToPixelArray(ras, decs) fakeCat["x"] = xs fakeCat["y"] = ys return fakeCat def _trimFakeCat(self, fakeCat, image):
vectors = np.empty((len(ras), 3)) vectors[:, 2] = np.sin(decs) vectors[:, 0] = np.cos(decs) * np.cos(ras) vectors[:, 1] = np.cos(decs) * np.sin(ras) return vectors class MatchVariableFakesConnections(MatchFakesConnections): ccdVisitFakeMagnitudes = connTypes.Input( doc="Catalog of fakes with magnitudes scattered for this ccdVisit.", name="{fakesType}ccdVisitFakeMagnitudes", storageClass="DataFrame", dimensions=("instrument", "visit", "detector"), ) @deprecated( reason="This task will be removed in v28.0 as it is replaced by `source_injection` tasks.", version="v28.0", category=FutureWarning, ) class MatchVariableFakesConfig(MatchFakesConfig, pipelineConnections=MatchVariableFakesConnections):
pass @deprecated( reason="This task will be removed in v28.0 as it is replaced by `source_injection` tasks.", version="v28.0", category=FutureWarning, ) class MatchVariableFakesTask(MatchFakesTask):
_DefaultName = "matchVariableFakes" ConfigClass = MatchVariableFakesConfig def runQuantum(self, butlerQC, inputRefs, outputRefs): inputs = butlerQC.get(inputRefs) inputs["band"] = butlerQC.quantum.dataId["band"] outputs = self.run(**inputs) butlerQC.put(outputs, outputRefs) def run(self, fakeCats, ccdVisitFakeMagnitudes, skyMap, diffIm, associatedDiaSources, band):
fakeCat = self.composeFakeCat(fakeCats, skyMap) self.computeExpectedDiffMag(fakeCat, ccdVisitFakeMagnitudes, band) return self._processFakes(fakeCat, diffIm, associatedDiaSources) def computeExpectedDiffMag(self, fakeCat, ccdVisitFakeMagnitudes, band):
Definition at line 171 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.fakeCats : `pandas.DataFrame` |
matchDistanceArcseconds = pexConfig.RangeField( doc="Distance in arcseconds to match within.", dtype=float, default=0.5, min=0, max=10, ) doMatchVisit = pexConfig.Field( dtype=bool, default=False, doc="Match visit to trim the fakeCat" ) trimBuffer = pexConfig.Field( doc="Size of the pixel buffer surrounding the image. Only those fake sources with a centroid" "falling within the image+buffer region will be considered matches.", dtype=int, default=100, ) @deprecated( reason="This task will be removed in v28.0 as it is replaced by `source_injection` tasks.", version="v28.0", category=FutureWarning, ) class MatchFakesTask(PipelineTask):
_DefaultName = "matchFakes" ConfigClass = MatchFakesConfig def run(self, fakeCats, skyMap, diffIm, associatedDiaSources):
trimmedFakes = self._trimFakeCat(fakeCat, diffIm) nPossibleFakes = len(trimmedFakes) fakeVects = self._getVectors(trimmedFakes[self.config.ra_col], trimmedFakes[self.config.dec_col]) diaSrcVects = self._getVectors( np.radians(associatedDiaSources.loc[:, "ra"]), np.radians(associatedDiaSources.loc[:, "dec"])) diaSrcTree = cKDTree(diaSrcVects) dist, idxs = diaSrcTree.query( fakeVects, distance_upper_bound=np.radians(self.config.matchDistanceArcseconds / 3600)) nFakesFound = np.isfinite(dist).sum() self.log.info("Found %d out of %d possible.", nFakesFound, nPossibleFakes) diaSrcIds = associatedDiaSources.iloc[np.where(np.isfinite(dist), idxs, 0)]["diaSourceId"].to_numpy() matchedFakes = trimmedFakes.assign(diaSourceId=np.where(np.isfinite(dist), diaSrcIds, 0)) return Struct( matchedDiaSources=matchedFakes.merge( associatedDiaSources.reset_index(drop=True), on="diaSourceId", how="left") ) def composeFakeCat(self, fakeCats, skyMap):
Definition at line 142 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.image : `lsst.afw.image.exposure.exposure.ExposureF` |
Definition at line 268 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.movingFakeCat : `pandas.DataFrame` |
Definition at line 253 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.ras : `numpy.ndarray`, (N,) |
# fakeCat must be processed with _addPixCoords before trimming if ('x' not in fakeCat.columns) or ('y' not in fakeCat.columns): fakeCat = self._addPixCoords(fakeCat, image) # Prefilter in ra/dec to avoid cases where the wcs incorrectly maps # input fakes which are really off the chip onto it. ras = fakeCat[self.config.ra_col].values * u.rad decs = fakeCat[self.config.dec_col].values * u.rad isContainedRaDec = image.containsSkyCoords(ras, decs, padding=0) # now use the exact pixel BBox to filter to only fakes that were inserted xs = fakeCat["x"].values ys = fakeCat["y"].values bbox = Box2D(image.getBBox()) isContainedXy = xs >= bbox.minX isContainedXy &= xs <= bbox.maxX isContainedXy &= ys >= bbox.minY isContainedXy &= ys <= bbox.maxY return fakeCat[isContainedRaDec & isContainedXy] def _getVectors(self, ras, decs):
Definition at line 326 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.result : `lsst.pipe.base.Struct` |
Definition at line 153 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.skyMap : `lsst.skymap.SkyMap` |
Definition at line 144 of file matchFakes.py.
lsst.pipe.tasks.matchFakes.vectors : `numpy.ndarray`, (N, 3) |
Definition at line 333 of file matchFakes.py.