Coverage for python/lsst/jointcal/testUtils.py : 84%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# This file is part of jointcal.
# Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (http://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership.
# This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version.
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Return two fake ccdImages built on CFHT Megacam metadata.
If ``num1 == num2``, the catalogs will align on-sky so each source will have a match in the other catalog.
This uses the butler dataset stored in `tests/data/cfht_minimal` to bootstrap the metadata.
Parameters ---------- num1, num2 : `int`, optional Number of sources to put in the first and second catalogs. Should be a square, to have sqrt(num) centroids on a grid. seed : `int`, optional Seed value for np.random.
Returns ------- struct : `lsst.pipe.base.Struct` Result struct with components:
- `camera` : Camera representing these catalogs (`lsst.afw.cameraGeom.Camera`). - `catalogs` : Catalogs containing fake sources (`list` of `lsst.afw.table.SourceCatalog`). - `ccdImageList` : CcdImages containing the metadata and fake sources (`list` of `lsst.jointcal.CcdImage`). - `bbox` : Bounding Box of the image (`lsst.afw.geom.Box2I`). """
# Load or fake the necessary metadata for each CcdImage
# so we can access parts of the camera later (e.g. focal plane)
photoCalibMean=100.0, photoCalibErr=1.0) photoCalibMean=120.0, photoCalibErr=5.0)
catalogs=[struct1.catalog, struct2.catalog], ccdImageList=[struct1.ccdImage, struct2.ccdImage], bbox=struct1.bbox)
photoCalibMean=100.0, photoCalibErr=1.0): """Create a fake CcdImage by making a fake catalog.
Parameters ---------- butler : `lsst.daf.persistence.Butler` Butler to load metadata from. visit : `int` Visit identifier to build a butler dataId. ccdId : `int` CCD identifier to build a butler dataId. num : `int` Number of sources to put in the catalogs. Should be a square, to have sqrt(num) centroids on a grid. instFluxKeyName : `str` Name of the instFluxKey to populate in the catalog. photoCalibMean : `float`, optional Value to set for calibrationMean in the created PhotoCalib. photoCalibErr : `float`, optional Value to set for calibrationErr in the created PhotoCalib.
Returns ------- struct : `lsst.pipe.base.Struct` Result struct with components:
- `catalog` : Catalogs containing fake sources (`lsst.afw.table.SourceCatalog`). - `ccdImage` : CcdImage containing the metadata and fake sources (`lsst.jointcal.CcdImage`). - `bbox` : Bounding Box of the image (`lsst.afw.geom.Box2I`). """
detector, visit, ccdId, instFluxKeyName)
"""Return a fake minimally-useful catalog for jointcal.
Parameters ---------- num : `int` Number of sources to put in the catalogs. Should be a square, to have sqrt(num) centroids on a grid. bbox : `lsst.afw.geom.Box2I` Bounding Box of the detector to populate. instFluxKeyName : `str` Name of the instFluxKey to populate in the catalog. skyWcs : `lsst.afw.geom.SkyWcs` or None, optional If supplied, use this to fill in coordinates from centroids. refCat : `bool`, optional Return a ``SimpleCatalog`` so that it behaves like a reference catalog?
Returns ------- catalog : `lsst.afw.table.SourceCatalog` A populated source catalog. """ # centroid # shape lsst.afw.table.CoordinateType.PIXEL) # Put the fake sources in the minimal catalog. centroidKey, xErrKey, yErrKey, shapeKey, instFluxKeyName, skyWcs=skyWcs, refCat=refCat)
centroidKey, xErrKey, yErrKey, shapeKey, instFluxKeyName, skyWcs=None, fluxErrFraction=0.05, refCat=False): """Return a catalog populated with fake, but reasonable, sources.
Centroids are placed on a uniform grid, errors are normally distributed.
Parameters ---------- schema : `lsst.afw.table.Schema` Pre-built schema to make the catalog from. num : `int` Number of sources to put in the catalog. bbox : `lsst.afw.geom.Box2I` Bounding box of the ccd to put sources in. centroidKey : `lsst.afw.table.Key` Key for the centroid field to populate. xErrKey : `lsst.afw.table.Key` Key for the xErr field to populate. yErrKey : `lsst.afw.table.Key` Key for the yErr field to populate. shapeKey : `lsst.afw.table.Key` Key for the shape field to populate. instFluxKeyName : `str` Name of instFlux field to populate (i.e. instFluxKeyName+'_flux') skyWcs : `lsst.afw.geom.SkyWcs` or None, optional If supplied, use this to fill in coordinates from centroids. fluxErrFraction : `float`, optional Fraction of instFlux to use for the instFluxErr. refCat : `bool`, optional Return a ``SimpleCatalog`` so that it behaves like a reference catalog?
Returns ------- catalog : `lsst.afw.table.SourceCatalog` The filled catalog. """ else:
# make all the sources perfectly spherical, for simplicity.
"""Return a list of measuredStars built from a catalog.
Parameters ---------- catalog : `lsst.afw.table.SourceCatalog` The table to get sources from. pixToFocal : `lsst.afw.geom.TransformPoint2ToPoint2` Transform that goes from pixel to focal plane coordinates, to set the MeasuredStar x/y focal points.
Returns ------- stars : `list` of `lsst.jointcal.MeasuredStar` MeasuredStars built from the catalog sources. """ stars = [] for record in catalog: star = lsst.jointcal.star.MeasuredStar() star.x = record.getX() star.y = record.getY() star.setInstFlux(record.getInstFlux()) star.setInstFluxErr(record.getInstFluxErr()) # TODO: cleanup after DM-4044 point = lsst.afw.geom.Point2D(star.x, star.y) pointFocal = pixToFocal.applyForward(point) star.setXFocal(pointFocal.getX()) star.setYFocal(pointFocal.getY()) stars.append(star)
return stars |