35 pixelScale = lsst.pex.config.Field(
36 dtype=float, default=0.2, optional=
False,
37 doc=
"Pixel scale for mock WCSs in arcseconds/pixel"
39 doRotate = lsst.pex.config.Field(
40 dtype=bool, default=
True, optional=
False,
41 doc=
"Whether to randomly rotate observations relative to the tract Wcs"
43 fluxMag0 = lsst.pex.config.Field(
44 dtype=float, default=1E11, optional=
False,
45 doc=
"Flux at zero magnitude used to define Calibs."
47 fluxMag0Sigma = lsst.pex.config.Field(
48 dtype=float, default=100.0, optional=
False,
49 doc=
"Error on flux at zero magnitude used to define Calibs; used to add scatter as well."
51 expTime = lsst.pex.config.Field(
52 dtype=float, default=60.0, optional=
False,
53 doc=
"Exposure time set in generated Calibs (does not affect flux or noise level)"
55 psfImageSize = lsst.pex.config.Field(
56 dtype=int, default=21, optional=
False,
57 doc=
"Image width and height of generated Psfs."
59 psfMinSigma = lsst.pex.config.Field(
60 dtype=float, default=1.5, optional=
False,
61 doc=
"Minimum radius for generated Psfs."
63 psfMaxSigma = lsst.pex.config.Field(
64 dtype=float, default=3.0, optional=
False,
65 doc=
"Maximum radius for generated Psfs."
67 seed = lsst.pex.config.Field(dtype=int, default=1, doc=
"Seed for numpy random number generator")
70 """Task to generate mock Exposure parameters (Wcs, Psf, Calib), intended for use as a subtask
74 - document "pa" in detail; angle of what to what?
75 - document the catalog parameter of the run method
78 ConfigClass = MockObservationConfig
81 lsst.pipe.base.Task.__init__(self, **kwds)
83 self.
ccdKey = self.schema.addField(
"ccd", type=int, doc=
"CCD number")
84 self.
visitKey = self.schema.addField(
"visit", type=int, doc=
"visit number")
86 self.
rng = numpy.random.RandomState(self.config.seed)
88 def run(self, butler, n, tractInfo, camera, catalog=None):
89 """Driver that generates an ExposureCatalog of mock observations.
91 @param[in] butler: a data butler
92 @param[in] n: number of pointings
93 @param[in] camera: camera geometry (an lsst.afw.cameraGeom.Camera)
94 @param[in] catalog: catalog to which to add observations (an ExposureCatalog);
95 if None then a new catalog is created.
100 if not catalog.getSchema().contains(self.
schema):
101 raise ValueError(
"Catalog schema does not match Task schema")
104 for detector
in camera:
106 record = catalog.addNew()
107 record.setI(self.
ccdKey, detector.getId())
110 record.setWcs(self.
buildWcs(position, pa, detector))
111 record.setCalib(calib)
112 record.setPsf(self.
buildPsf(detector))
113 record.setBBox(detector.getBBox())
114 detectorId = detector.getId()
115 obj = butler.get(
"ccdExposureId", visit=visit, ccd=detectorId, immediate=
True)
121 """Generate (celestial) positions and rotation angles that define field locations.
123 Default implementation draws random pointings that are uniform in the tract's image
126 @param[in] n: number of pointings
127 @param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo)
128 @return a Python iterable over (coord, angle) pairs:
129 - coord is an object position (an lsst.afw.coord.Coord)
130 - angle is a position angle (???) (an lsst.afw.geom.Angle)
132 The default implementation returns an iterator (i.e. the function is a "generator"),
133 but derived-class overrides may return any iterable.
135 wcs = tractInfo.getWcs()
139 x = self.rng.rand() * bbox.getWidth() + bbox.getMinX()
140 y = self.rng.rand() * bbox.getHeight() + bbox.getMinY()
141 pa = 0.0 * lsst.afw.geom.radians
142 if self.config.doRotate:
143 pa = self.rng.rand() * 2.0 * numpy.pi * lsst.afw.geom.radians
144 yield wcs.pixelToSky(x, y), pa
147 """Build a simple TAN Wcs with no distortion and exactly-aligned CCDs.
149 @param[in] position: object position on sky (an lsst.afw.coord.Coord)
150 @param[in] pa: position angle (an lsst.afw.geom.Angle)
151 @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
154 pixelScale = (self.config.pixelScale * lsst.afw.geom.arcseconds).asDegrees()
158 crpix = detector.transform(fpCtr, PIXELS).getPoint()
164 """Build a simple Calib object with exposure time fixed by config, fluxMag0 drawn from
165 a Gaussian defined by config, and mid-time set to DateTime.now().
169 calib.setExptime(self.config.expTime)
171 self.rng.randn() * self.config.fluxMag0Sigma + self.config.fluxMag0,
172 self.config.fluxMag0Sigma
177 """Build a simple Gaussian Psf with linearly-varying ellipticity and size.
179 The Psf pattern increases sigma_x linearly along the x direction, and sigma_y
180 linearly along the y direction.
182 @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
183 @return a psf (an instance of lsst.meas.algorithms.KernelPsf)
185 bbox = detector.getBBox()
186 dx = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getWidth()
187 dy = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getHeight()
188 sigmaXFunc = lsst.afw.math.PolynomialFunction2D(1)
189 sigmaXFunc.setParameter(0, self.config.psfMinSigma - dx * bbox.getMinX() - dy * bbox.getMinY())
190 sigmaXFunc.setParameter(1, dx)
191 sigmaXFunc.setParameter(2, 0.0)
192 sigmaYFunc = lsst.afw.math.PolynomialFunction2D(1)
193 sigmaYFunc.setParameter(0, self.config.psfMinSigma)
194 sigmaYFunc.setParameter(1, 0.0)
195 sigmaYFunc.setParameter(2, dy)
196 angleFunc = lsst.afw.math.PolynomialFunction2D(0)
197 spatialFuncList = lsst.afw.math.Function2DList()
198 spatialFuncList.append(sigmaXFunc)
199 spatialFuncList.append(sigmaYFunc)
200 spatialFuncList.append(angleFunc)
202 self.config.psfImageSize, self.config.psfImageSize,
203 lsst.afw.math.GaussianFunction2D(self.config.psfMinSigma, self.config.psfMinSigma),
static DateTime now(void)
A Psf defined by a Kernel.
static Schema makeMinimalSchema()
Return a minimal schema for Exposure tables and records.
static CoordKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
boost::shared_ptr< Wcs > makeWcs(coord::Coord const &crval, geom::Point2D const &crpix, double CD11, double CD12, double CD21, double CD22)
Create a Wcs object from crval, crpix, CD, using CD elements (useful from python) ...
Custom catalog class for ExposureRecord/Table.
A floating-point coordinate rectangle geometry.
A kernel described by a function.