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 record.setId(butler.get(
"ccdExposureId", visit=visit, ccd=detector.getId(), immediate=
True))
119 """Generate (celestial) positions and rotation angles that define field locations.
121 Default implementation draws random pointings that are uniform in the tract's image
124 @param[in] n: number of pointings
125 @param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo)
126 @return a Python iterable over (coord, angle) pairs:
127 - coord is an object position (an lsst.afw.coord.Coord)
128 - angle is a position angle (???) (an lsst.afw.geom.Angle)
130 The default implementation returns an iterator (i.e. the function is a "generator"),
131 but derived-class overrides may return any iterable.
133 wcs = tractInfo.getWcs()
137 x = self.rng.rand() * bbox.getWidth() + bbox.getMinX()
138 y = self.rng.rand() * bbox.getHeight() + bbox.getMinY()
139 pa = 0.0 * lsst.afw.geom.radians
140 if self.config.doRotate:
141 pa = self.rng.rand() * 2.0 * numpy.pi * lsst.afw.geom.radians
142 yield wcs.pixelToSky(x, y), pa
145 """Build a simple TAN Wcs with no distortion and exactly-aligned CCDs.
147 @param[in] position: object position on sky (an lsst.afw.coord.Coord)
148 @param[in] pa: position angle (an lsst.afw.geom.Angle)
149 @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
152 pixelScale = (self.config.pixelScale * lsst.afw.geom.arcseconds).asDegrees()
156 crpix = detector.transform(fpCtr, PIXELS).getPoint()
162 """Build a simple Calib object with exposure time fixed by config, fluxMag0 drawn from
163 a Gaussian defined by config, and mid-time set to DateTime.now().
167 calib.setExptime(self.config.expTime)
169 self.rng.randn() * self.config.fluxMag0Sigma + self.config.fluxMag0,
170 self.config.fluxMag0Sigma
175 """Build a simple Gaussian Psf with linearly-varying ellipticity and size.
177 The Psf pattern increases sigma_x linearly along the x direction, and sigma_y
178 linearly along the y direction.
180 @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
181 @return a psf (an instance of lsst.meas.algorithms.KernelPsf)
183 bbox = detector.getBBox()
184 dx = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getWidth()
185 dy = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getHeight()
186 sigmaXFunc = lsst.afw.math.PolynomialFunction2D(1)
187 sigmaXFunc.setParameter(0, self.config.psfMinSigma - dx * bbox.getMinX() - dy * bbox.getMinY())
188 sigmaXFunc.setParameter(1, dx)
189 sigmaXFunc.setParameter(2, 0.0)
190 sigmaYFunc = lsst.afw.math.PolynomialFunction2D(1)
191 sigmaYFunc.setParameter(0, self.config.psfMinSigma)
192 sigmaYFunc.setParameter(1, 0.0)
193 sigmaYFunc.setParameter(2, dy)
194 angleFunc = lsst.afw.math.PolynomialFunction2D(0)
195 spatialFuncList = lsst.afw.math.Function2DList()
196 spatialFuncList.append(sigmaXFunc)
197 spatialFuncList.append(sigmaYFunc)
198 spatialFuncList.append(angleFunc)
200 self.config.psfImageSize, self.config.psfImageSize,
201 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)
Wcs::Ptr 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) ...
boost::enable_if_c< ((C+Nf-N)>=1), ArrayRef< T, Nf,(C+Nf-N)> >::type flatten(Array< T, N, C > const &input)
Create a view into an array with trailing contiguous dimensions merged.
Custom catalog class for ExposureRecord/Table.
A floating-point coordinate rectangle geometry.
A kernel described by a function.