38 dtype=float, default=0.2, optional=
False,
39 doc=
"Pixel scale for mock WCSs in arcseconds/pixel" 42 dtype=bool, default=
True, optional=
False,
43 doc=
"Whether to randomly rotate observations relative to the tract Wcs" 46 dtype=float, default=1E11, optional=
False,
47 doc=
"Flux at zero magnitude used to define PhotoCalibs." 50 dtype=float, default=100.0, optional=
False,
51 doc=
"Error on flux at zero magnitude used to define PhotoCalibs; used to add scatter as well." 54 dtype=float, default=60.0, optional=
False,
55 doc=
"Exposure time set in visitInfo (does not affect flux or noise level)" 58 dtype=int, default=21, optional=
False,
59 doc=
"Image width and height of generated Psfs." 62 dtype=float, default=1.5, optional=
False,
63 doc=
"Minimum radius for generated Psfs." 66 dtype=float, default=3.0, optional=
False,
67 doc=
"Maximum radius for generated Psfs." 70 dtype=int, default=1, optional=
False,
71 doc=
"Polynomial order for aperture correction fields" 77 """Task to generate mock Exposure parameters (Wcs, Psf, PhotoCalib), intended for use as a subtask 81 - document "pa" in detail; angle of what to what? 82 - document the catalog parameter of the run method 85 ConfigClass = MockObservationConfig
88 lsst.pipe.base.Task.__init__(self, **kwds)
90 self.
ccdKey = self.
schema.addField(
"ccd", type=np.int32, doc=
"CCD number")
91 self.
visitKey = self.
schema.addField(
"visit", type=np.int32, doc=
"visit number")
93 self.
filterKey = self.
schema.addField(
"filter", type=str, doc=
"Bandpass filter name", size=16)
96 def run(self, butler, n, tractInfo, camera, catalog=None):
97 """Driver that generates an ExposureCatalog of mock observations. 99 @param[in] butler: a data butler 100 @param[in] n: number of pointings 101 @param[in] camera: camera geometry (an lsst.afw.cameraGeom.Camera) 102 @param[in] catalog: catalog to which to add observations (an ExposureCatalog); 103 if None then a new catalog is created. 105 @todo figure out what `pa` is and use that knowledge to set `boresightRotAng` and `rotType` 111 raise ValueError(
"Catalog schema does not match Task schema")
116 exposureTime=self.
config.expTime,
118 boresightRaDec=position,
120 for detector
in camera:
122 record = catalog.addNew()
123 record.setI(self.
ccdKey, detector.getId())
127 record.setWcs(self.buildWcs(position, pa, detector)) 128 record.setPhotoCalib(photoCalib) 129 record.setVisitInfo(visitInfo) 130 record.setPsf(self.buildPsf(detector)) 133 record.setBBox(detector.getBBox()) 134 detectorId = detector.getId() 135 obj = butler.get("ccdExposureId", visit=visit, ccd=detectorId, immediate=
True)
141 """Generate (celestial) positions and rotation angles that define field locations. 143 Default implementation draws random pointings that are uniform in the tract's image 146 @param[in] n: number of pointings 147 @param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo) 148 @return a Python iterable over (coord, angle) pairs: 149 - coord is an ICRS object position (an lsst.afw.geom.SpherePoint) 150 - angle is a position angle (???) (an lsst.afw.geom.Angle) 152 The default implementation returns an iterator (i.e. the function is a "generator"), 153 but derived-class overrides may return any iterable. 155 wcs = tractInfo.getWcs()
159 x = self.
rng.rand() * bbox.getWidth() + bbox.getMinX()
160 y = self.
rng.rand() * bbox.getHeight() + bbox.getMinY()
161 pa = 0.0 * lsst.afw.geom.radians
163 pa = self.
rng.rand() * 2.0 * np.pi * lsst.afw.geom.radians
164 yield wcs.pixelToSky(x, y), pa
167 """Build a simple TAN Wcs with no distortion and exactly-aligned CCDs. 169 @param[in] position: ICRS object position on sky (on lsst.afw.geom.SpherePoint) 170 @param[in] pa: position angle (an lsst.afw.geom.Angle) 171 @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector) 174 pixelScale = (self.
config.pixelScale * lsst.afw.geom.arcseconds).asDegrees()
175 cd = (lsst.afw.geom.LinearTransform.makeScaling(pixelScale) *
176 lsst.afw.geom.LinearTransform.makeRotation(pa))
182 """Build a simple PhotoCalib object with the calibration factor 183 drawn from a Gaussian defined by config. 192 """Build a simple Gaussian Psf with linearly-varying ellipticity and size. 194 The Psf pattern increases sigma_x linearly along the x direction, and sigma_y 195 linearly along the y direction. 197 @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector) 198 @return a psf (an instance of lsst.meas.algorithms.KernelPsf) 200 bbox = detector.getBBox()
201 dx = (self.
config.psfMaxSigma - self.
config.psfMinSigma) / bbox.getWidth()
202 dy = (self.
config.psfMaxSigma - self.
config.psfMinSigma) / bbox.getHeight()
203 sigmaXFunc = lsst.afw.math.PolynomialFunction2D(1)
204 sigmaXFunc.setParameter(0, self.
config.psfMinSigma - dx * bbox.getMinX() - dy * bbox.getMinY())
205 sigmaXFunc.setParameter(1, dx)
206 sigmaXFunc.setParameter(2, 0.0)
207 sigmaYFunc = lsst.afw.math.PolynomialFunction2D(1)
208 sigmaYFunc.setParameter(0, self.
config.psfMinSigma)
209 sigmaYFunc.setParameter(1, 0.0)
210 sigmaYFunc.setParameter(2, dy)
211 angleFunc = lsst.afw.math.PolynomialFunction2D(0)
213 spatialFuncList.append(sigmaXFunc)
214 spatialFuncList.append(sigmaYFunc)
215 spatialFuncList.append(angleFunc)
218 lsst.afw.math.GaussianFunction2D(self.
config.psfMinSigma, self.
config.psfMinSigma),
224 """Build an ApCorrMap with random linearly-varying fields for all 225 flux fields registered for aperture correction. 227 These flux field names are used only as strings; there is no 228 connection to any actual algorithms with those names or the PSF model. 230 order = self.
config.apCorrOrder
232 def makeRandomBoundedField():
233 """Make an upper-left triangular coefficient array appropriate 234 for a 2-d polynomial.""" 235 array = np.zeros((order + 1, order + 1), dtype=float)
236 for n
in range(order + 1):
237 array[n, 0:order + 1 - n] = self.
rng.randn(order + 1 - n)
240 bbox = detector.getBBox()
243 apCorrMap.set(name +
"_instFlux", makeRandomBoundedField())
244 apCorrMap.set(name +
"_instFluxErr", makeRandomBoundedField())
248 """Build a random spacially-varying TransmissionCurve.""" 249 bbox = detector.getBBox()
def buildTransmissionCurve(self, detector)
std::shared_ptr< PhotoCalib > makePhotoCalibFromCalibZeroPoint(double instFluxMag0, double instFluxMag0Err)
Construct a PhotoCalib from the deprecated Calib-style instFluxMag0/instFluxMag0Err values...
A Psf defined by a Kernel.
bool contains(VertexIterator const begin, VertexIterator const end, UnitVector3d const &v)
A floating-point coordinate rectangle geometry.
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
def buildPhotoCalib(self)
Information about a single exposure of an imaging camera.
static Schema makeMinimalSchema()
Return a minimal schema for Exposure tables and records.
def buildApCorrMap(self, detector)
def buildPsf(self, detector)
def makeRandomTransmissionCurve(rng, minWavelength=4000.0, maxWavelength=7000.0, nWavelengths=200, maxRadius=80.0, nRadii=30, perturb=0.05)
static DateTime now(void)
Return current time as a DateTime.
def run(self, butler, n, tractInfo, camera, catalog=None)
def makePointings(self, n, tractInfo)
def buildWcs(self, position, pa, detector)
std::shared_ptr< SkyWcs > makeSkyWcs(TransformPoint2ToPoint2 const &pixelsToFieldAngle, lsst::geom::Angle const &orientation, bool flipX, lsst::geom::SpherePoint const &boresight, std::string const &projection="TAN")
Construct a FITS SkyWcs from camera geometry.
A BoundedField based on 2-d Chebyshev polynomials of the first kind.
Custom catalog class for ExposureRecord/Table.
static CoordKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)
Add a pair of _ra, _dec fields to a Schema, and return a CoordKey that points to them.
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
A kernel described by a function.