LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
lsst.pipe.tasks.mocks.mockObservation.MockObservationTask Class Reference
Inheritance diagram for lsst.pipe.tasks.mocks.mockObservation.MockObservationTask:

Public Member Functions

def __init__ (self, **kwds)
 
def run (self, butler, n, tractInfo, camera, catalog=None)
 
def makePointings (self, n, tractInfo)
 
def buildWcs (self, position, pa, detector)
 
def buildPhotoCalib (self)
 
def buildPsf (self, detector)
 
def buildApCorrMap (self, detector)
 
def buildTransmissionCurve (self, detector)
 

Public Attributes

 schema
 
 ccdKey
 
 visitKey
 
 pointingKey
 
 filterKey
 
 rng
 

Static Public Attributes

 ConfigClass = MockObservationConfig
 

Detailed Description

Task to generate mock Exposure parameters (Wcs, Psf, PhotoCalib), intended for use as a subtask
of MockCoaddTask.

@todo:
- document "pa" in detail; angle of what to what?
- document the catalog parameter of the run method

Definition at line 77 of file mockObservation.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.__init__ (   self,
**  kwds 
)

Definition at line 88 of file mockObservation.py.

88  def __init__(self, **kwds):
89  lsst.pipe.base.Task.__init__(self, **kwds)
91  self.ccdKey = self.schema.addField("ccd", type=np.int32, doc="CCD number")
92  self.visitKey = self.schema.addField("visit", type=np.int32, doc="visit number")
93  self.pointingKey = lsst.afw.table.CoordKey.addFields(self.schema, "pointing", "center of visit")
94  self.filterKey = self.schema.addField("filter", type=str, doc="Bandpass filter name", size=16)
95  self.rng = np.random.RandomState(self.config.seed)
96 
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.
Definition: aggregates.cc:83
static Schema makeMinimalSchema()
Return a minimal schema for Exposure tables and records.
Definition: Exposure.h:216

Member Function Documentation

◆ buildApCorrMap()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.buildApCorrMap (   self,
  detector 
)
Build an ApCorrMap with random linearly-varying fields for all
flux fields registered for aperture correction.

These flux field names are used only as strings; there is no
connection to any actual algorithms with those names or the PSF model.

Definition at line 224 of file mockObservation.py.

224  def buildApCorrMap(self, detector):
225  """Build an ApCorrMap with random linearly-varying fields for all
226  flux fields registered for aperture correction.
227 
228  These flux field names are used only as strings; there is no
229  connection to any actual algorithms with those names or the PSF model.
230  """
231  order = self.config.apCorrOrder
232 
233  def makeRandomBoundedField():
234  """Make an upper-left triangular coefficient array appropriate
235  for a 2-d polynomial."""
236  array = np.zeros((order + 1, order + 1), dtype=float)
237  for n in range(order + 1):
238  array[n, 0:order + 1 - n] = self.rng.randn(order + 1 - n)
239  return lsst.afw.math.ChebyshevBoundedField(bbox, array)
240 
241  bbox = detector.getBBox()
242  apCorrMap = lsst.afw.image.ApCorrMap()
243  for name in getApCorrNameSet():
244  apCorrMap.set(name + "_instFlux", makeRandomBoundedField())
245  apCorrMap.set(name + "_instFluxErr", makeRandomBoundedField())
246  return apCorrMap
247 
A thin wrapper around std::map to allow aperture corrections to be attached to Exposures.
Definition: ApCorrMap.h:45
A BoundedField based on 2-d Chebyshev polynomials of the first kind.

◆ buildPhotoCalib()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.buildPhotoCalib (   self)
Build a simple PhotoCalib object with the calibration factor
drawn from a Gaussian defined by config.

Definition at line 182 of file mockObservation.py.

182  def buildPhotoCalib(self):
183  """Build a simple PhotoCalib object with the calibration factor
184  drawn from a Gaussian defined by config.
185  """
187  self.rng.randn() * self.config.fluxMag0Err + self.config.fluxMag0,
188  self.config.fluxMag0Err
189  )
190  return photoCalib
191 
std::shared_ptr< PhotoCalib > makePhotoCalibFromCalibZeroPoint(double instFluxMag0, double instFluxMag0Err)
Construct a PhotoCalib from the deprecated Calib-style instFluxMag0/instFluxMag0Err values.
Definition: PhotoCalib.cc:613

◆ buildPsf()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.buildPsf (   self,
  detector 
)
Build a simple Gaussian Psf with linearly-varying ellipticity and size.

The Psf pattern increases sigma_x linearly along the x direction, and sigma_y
linearly along the y direction.

@param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
@return a psf (an instance of lsst.meas.algorithms.KernelPsf)

Definition at line 192 of file mockObservation.py.

192  def buildPsf(self, detector):
193  """Build a simple Gaussian Psf with linearly-varying ellipticity and size.
194 
195  The Psf pattern increases sigma_x linearly along the x direction, and sigma_y
196  linearly along the y direction.
197 
198  @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
199  @return a psf (an instance of lsst.meas.algorithms.KernelPsf)
200  """
201  bbox = detector.getBBox()
202  dx = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getWidth()
203  dy = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getHeight()
204  sigmaXFunc = lsst.afw.math.PolynomialFunction2D(1)
205  sigmaXFunc.setParameter(0, self.config.psfMinSigma - dx * bbox.getMinX() - dy * bbox.getMinY())
206  sigmaXFunc.setParameter(1, dx)
207  sigmaXFunc.setParameter(2, 0.0)
208  sigmaYFunc = lsst.afw.math.PolynomialFunction2D(1)
209  sigmaYFunc.setParameter(0, self.config.psfMinSigma)
210  sigmaYFunc.setParameter(1, 0.0)
211  sigmaYFunc.setParameter(2, dy)
212  angleFunc = lsst.afw.math.PolynomialFunction2D(0)
213  spatialFuncList = []
214  spatialFuncList.append(sigmaXFunc)
215  spatialFuncList.append(sigmaYFunc)
216  spatialFuncList.append(angleFunc)
218  self.config.psfImageSize, self.config.psfImageSize,
219  lsst.afw.math.GaussianFunction2D(self.config.psfMinSigma, self.config.psfMinSigma),
220  spatialFuncList
221  )
222  return lsst.meas.algorithms.KernelPsf(kernel)
223 
A kernel described by a function.
Definition: Kernel.h:535
A Psf defined by a Kernel.
Definition: KernelPsf.h:36

◆ buildTransmissionCurve()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.buildTransmissionCurve (   self,
  detector 
)
Build a random spacially-varying TransmissionCurve.

Definition at line 248 of file mockObservation.py.

248  def buildTransmissionCurve(self, detector):
249  """Build a random spacially-varying TransmissionCurve."""
250  bbox = detector.getBBox()
251  return makeRandomTransmissionCurve(rng=self.rng, maxRadius=max(bbox.getWidth(), bbox.getHeight()))
int max
def makeRandomTransmissionCurve(rng, minWavelength=4000.0, maxWavelength=7000.0, nWavelengths=200, maxRadius=80.0, nRadii=30, perturb=0.05)
Definition: testUtils.py:99

◆ buildWcs()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.buildWcs (   self,
  position,
  pa,
  detector 
)
Build a simple TAN Wcs with no distortion and exactly-aligned CCDs.

@param[in] position: ICRS object position on sky (on lsst.geom.SpherePoint)
@param[in] pa: position angle (an lsst.geom.Angle)
@param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)

Definition at line 167 of file mockObservation.py.

167  def buildWcs(self, position, pa, detector):
168  """Build a simple TAN Wcs with no distortion and exactly-aligned CCDs.
169 
170  @param[in] position: ICRS object position on sky (on lsst.geom.SpherePoint)
171  @param[in] pa: position angle (an lsst.geom.Angle)
172  @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
173  """
174  crval = position
175  pixelScale = (self.config.pixelScale * lsst.geom.arcseconds).asDegrees()
176  cd = (lsst.geom.LinearTransform.makeScaling(pixelScale)
178  crpix = detector.transform(lsst.geom.Point2D(0, 0), FOCAL_PLANE, PIXELS)
179  wcs = lsst.afw.geom.makeSkyWcs(crpix=crpix, crval=crval, cdMatrix=cd.getMatrix())
180  return wcs
181 
static LinearTransform makeRotation(Angle t) noexcept
static LinearTransform makeScaling(double s) noexcept
std::shared_ptr< SkyWcs > makeSkyWcs(daf::base::PropertySet &metadata, bool strip=false)
Construct a SkyWcs from FITS keywords.
Definition: SkyWcs.cc:521

◆ makePointings()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.makePointings (   self,
  n,
  tractInfo 
)
Generate (celestial) positions and rotation angles that define field locations.

Default implementation draws random pointings that are uniform in the tract's image
coordinate system.

@param[in] n: number of pointings
@param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo)
@return a Python iterable over (coord, angle) pairs:
- coord is an ICRS object position (an lsst.geom.SpherePoint)
- angle is a position angle (???) (an lsst.geom.Angle)

The default implementation returns an iterator (i.e. the function is a "generator"),
but derived-class overrides may return any iterable.

Definition at line 141 of file mockObservation.py.

141  def makePointings(self, n, tractInfo):
142  """Generate (celestial) positions and rotation angles that define field locations.
143 
144  Default implementation draws random pointings that are uniform in the tract's image
145  coordinate system.
146 
147  @param[in] n: number of pointings
148  @param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo)
149  @return a Python iterable over (coord, angle) pairs:
150  - coord is an ICRS object position (an lsst.geom.SpherePoint)
151  - angle is a position angle (???) (an lsst.geom.Angle)
152 
153  The default implementation returns an iterator (i.e. the function is a "generator"),
154  but derived-class overrides may return any iterable.
155  """
156  wcs = tractInfo.getWcs()
157  bbox = lsst.geom.Box2D(tractInfo.getBBox())
158  bbox.grow(lsst.geom.Extent2D(-0.1 * bbox.getWidth(), -0.1 * bbox.getHeight()))
159  for i in range(n):
160  x = self.rng.rand() * bbox.getWidth() + bbox.getMinX()
161  y = self.rng.rand() * bbox.getHeight() + bbox.getMinY()
162  pa = 0.0 * lsst.geom.radians
163  if self.config.doRotate:
164  pa = self.rng.rand() * 2.0 * np.pi * lsst.geom.radians
165  yield wcs.pixelToSky(x, y), pa
166 
A floating-point coordinate rectangle geometry.
Definition: Box.h:413

◆ run()

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.run (   self,
  butler,
  n,
  tractInfo,
  camera,
  catalog = None 
)
Driver that generates an ExposureCatalog of mock observations.

@param[in] butler: a data butler
@param[in] n: number of pointings
@param[in] camera: camera geometry (an lsst.afw.cameraGeom.Camera)
@param[in] catalog: catalog to which to add observations (an ExposureCatalog);
    if None then a new catalog is created.

@todo figure out what `pa` is and use that knowledge to set `boresightRotAng` and `rotType`

Definition at line 97 of file mockObservation.py.

97  def run(self, butler, n, tractInfo, camera, catalog=None):
98  """Driver that generates an ExposureCatalog of mock observations.
99 
100  @param[in] butler: a data butler
101  @param[in] n: number of pointings
102  @param[in] camera: camera geometry (an lsst.afw.cameraGeom.Camera)
103  @param[in] catalog: catalog to which to add observations (an ExposureCatalog);
104  if None then a new catalog is created.
105 
106  @todo figure out what `pa` is and use that knowledge to set `boresightRotAng` and `rotType`
107  """
108  if catalog is None:
109  catalog = lsst.afw.table.ExposureCatalog(self.schema)
110  else:
111  if not catalog.getSchema().contains(self.schema):
112  raise ValueError("Catalog schema does not match Task schema")
113  visit = 1
114 
115  for position, pa in self.makePointings(n, tractInfo):
116  visitInfo = lsst.afw.image.VisitInfo(
117  exposureTime=self.config.expTime,
119  boresightRaDec=position,
120  )
121  for detector in camera:
122  photoCalib = self.buildPhotoCalib()
123  record = catalog.addNew()
124  record.setI(self.ccdKey, detector.getId())
125  record.setI(self.visitKey, visit)
126  record.set(self.filterKey, 'r')
127  record.set(self.pointingKey, position)
128  record.setWcs(self.buildWcs(position, pa, detector))
129  record.setPhotoCalib(photoCalib)
130  record.setVisitInfo(visitInfo)
131  record.setPsf(self.buildPsf(detector))
132  record.setApCorrMap(self.buildApCorrMap(detector))
133  record.setTransmissionCurve(self.buildTransmissionCurve(detector))
134  record.setBBox(detector.getBBox())
135  detectorId = detector.getId()
136  obj = butler.get("ccdExposureId", visit=visit, ccd=detectorId, immediate=True)
137  record.setId(obj)
138  visit += 1
139  return catalog
140 
Information about a single exposure of an imaging camera.
Definition: VisitInfo.h:68
Custom catalog class for ExposureRecord/Table.
Definition: Exposure.h:311
static DateTime now(void)
Return current time as a DateTime.
Definition: DateTime.cc:518
def run(self, coaddExposures, bbox, wcs)
Definition: getTemplate.py:603

Member Data Documentation

◆ ccdKey

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.ccdKey

Definition at line 91 of file mockObservation.py.

◆ ConfigClass

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.ConfigClass = MockObservationConfig
static

Definition at line 86 of file mockObservation.py.

◆ filterKey

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.filterKey

Definition at line 94 of file mockObservation.py.

◆ pointingKey

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.pointingKey

Definition at line 93 of file mockObservation.py.

◆ rng

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.rng

Definition at line 95 of file mockObservation.py.

◆ schema

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.schema

Definition at line 90 of file mockObservation.py.

◆ visitKey

lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.visitKey

Definition at line 92 of file mockObservation.py.


The documentation for this class was generated from the following file: