LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
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__
 
def run
 
def makePointings
 
def buildWcs
 
def buildCalib
 
def buildPsf
 

Public Attributes

 schema
 
 ccdKey
 
 visitKey
 
 pointingKey
 
 rng
 

Static Public Attributes

 ConfigClass = MockObservationConfig
 

Detailed Description

Task to generate mock Exposure parameters (Wcs, Psf, Calib), 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 69 of file mockObservation.py.

Constructor & Destructor Documentation

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

Definition at line 80 of file mockObservation.py.

80 
81  def __init__(self, **kwds):
82  lsst.pipe.base.Task.__init__(self, **kwds)
84  self.ccdKey = self.schema.addField("ccd", type=int, doc="CCD number")
85  self.visitKey = self.schema.addField("visit", type=int, doc="visit number")
86  self.pointingKey = lsst.afw.table.CoordKey.addFields(self.schema, "pointing", "center of visit")
87  self.rng = numpy.random.RandomState(self.config.seed)
static Schema makeMinimalSchema()
Return a minimal schema for Exposure tables and records.
Definition: Exposure.h:164
static CoordKey addFields(afw::table::Schema &schema, std::string const &name, std::string const &doc)

Member Function Documentation

def lsst.pipe.tasks.mocks.mockObservation.MockObservationTask.buildCalib (   self)
Build a simple Calib object with exposure time fixed by config, fluxMag0 drawn from
a Gaussian defined by config, and mid-time set to DateTime.now().

Definition at line 161 of file mockObservation.py.

162  def buildCalib(self):
163  """Build a simple Calib object with exposure time fixed by config, fluxMag0 drawn from
164  a Gaussian defined by config, and mid-time set to DateTime.now().
165  """
166  calib = lsst.afw.image.Calib()
167  calib.setMidTime(lsst.daf.base.DateTime.now())
168  calib.setExptime(self.config.expTime)
169  calib.setFluxMag0(
170  self.rng.randn() * self.config.fluxMag0Sigma + self.config.fluxMag0,
171  self.config.fluxMag0Sigma
172  )
173  return calib
static DateTime now(void)
Definition: DateTime.cc:554
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 174 of file mockObservation.py.

175  def buildPsf(self, detector):
176  """Build a simple Gaussian Psf with linearly-varying ellipticity and size.
177 
178  The Psf pattern increases sigma_x linearly along the x direction, and sigma_y
179  linearly along the y direction.
180 
181  @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
182  @return a psf (an instance of lsst.meas.algorithms.KernelPsf)
183  """
184  bbox = detector.getBBox()
185  dx = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getWidth()
186  dy = (self.config.psfMaxSigma - self.config.psfMinSigma) / bbox.getHeight()
187  sigmaXFunc = lsst.afw.math.PolynomialFunction2D(1)
188  sigmaXFunc.setParameter(0, self.config.psfMinSigma - dx * bbox.getMinX() - dy * bbox.getMinY())
189  sigmaXFunc.setParameter(1, dx)
190  sigmaXFunc.setParameter(2, 0.0)
191  sigmaYFunc = lsst.afw.math.PolynomialFunction2D(1)
192  sigmaYFunc.setParameter(0, self.config.psfMinSigma)
193  sigmaYFunc.setParameter(1, 0.0)
194  sigmaYFunc.setParameter(2, dy)
195  angleFunc = lsst.afw.math.PolynomialFunction2D(0)
196  spatialFuncList = lsst.afw.math.Function2DList()
197  spatialFuncList.append(sigmaXFunc)
198  spatialFuncList.append(sigmaYFunc)
199  spatialFuncList.append(angleFunc)
201  self.config.psfImageSize, self.config.psfImageSize,
202  lsst.afw.math.GaussianFunction2D(self.config.psfMinSigma, self.config.psfMinSigma),
203  spatialFuncList
204  )
205  return lsst.meas.algorithms.KernelPsf(kernel)
A Psf defined by a Kernel.
Definition: KernelPsf.h:33
A kernel described by a function.
Definition: Kernel.h:628
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: object position on sky (an lsst.afw.coord.Coord)
@param[in] pa: position angle (an lsst.afw.geom.Angle)
@param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)

Definition at line 144 of file mockObservation.py.

145  def buildWcs(self, position, pa, detector):
146  """Build a simple TAN Wcs with no distortion and exactly-aligned CCDs.
147 
148  @param[in] position: object position on sky (an lsst.afw.coord.Coord)
149  @param[in] pa: position angle (an lsst.afw.geom.Angle)
150  @param[in] detector: detector information (an lsst.afw.cameraGeom.Detector)
151  """
152  crval = position
153  pixelScale = (self.config.pixelScale * lsst.afw.geom.arcseconds).asDegrees()
156  fpCtr = detector.makeCameraPoint(lsst.afw.geom.Point2D(0, 0), FOCAL_PLANE)
157  crpix = detector.transform(fpCtr, PIXELS).getPoint()
158 
159  wcs = lsst.afw.image.makeWcs(crval, crpix, *cd.getMatrix().flatten())
160  return wcs
static LinearTransform makeScaling(double s)
static LinearTransform makeRotation(Angle t)
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) ...
Definition: makeWcs.cc:141
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.
Definition: casts.h:150
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 object position (an lsst.afw.coord.Coord)
- angle is a position angle (???) (an lsst.afw.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 118 of file mockObservation.py.

119  def makePointings(self, n, tractInfo):
120  """Generate (celestial) positions and rotation angles that define field locations.
121 
122  Default implementation draws random pointings that are uniform in the tract's image
123  coordinate system.
124 
125  @param[in] n: number of pointings
126  @param[in] tractInfo: skymap tract (a lsst.skymap.TractInfo)
127  @return a Python iterable over (coord, angle) pairs:
128  - coord is an object position (an lsst.afw.coord.Coord)
129  - angle is a position angle (???) (an lsst.afw.geom.Angle)
130 
131  The default implementation returns an iterator (i.e. the function is a "generator"),
132  but derived-class overrides may return any iterable.
133  """
134  wcs = tractInfo.getWcs()
135  bbox = lsst.afw.geom.Box2D(tractInfo.getBBox())
136  bbox.grow(lsst.afw.geom.Extent2D(-0.1 * bbox.getWidth(), -0.1 * bbox.getHeight()))
137  for i in xrange(n):
138  x = self.rng.rand() * bbox.getWidth() + bbox.getMinX()
139  y = self.rng.rand() * bbox.getHeight() + bbox.getMinY()
140  pa = 0.0 * lsst.afw.geom.radians
141  if self.config.doRotate:
142  pa = self.rng.rand() * 2.0 * numpy.pi * lsst.afw.geom.radians
143  yield wcs.pixelToSky(x, y), pa
A floating-point coordinate rectangle geometry.
Definition: Box.h:271
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.

Definition at line 88 of file mockObservation.py.

88 
89  def run(self, butler, n, tractInfo, camera, catalog=None):
90  """Driver that generates an ExposureCatalog of mock observations.
91 
92  @param[in] butler: a data butler
93  @param[in] n: number of pointings
94  @param[in] camera: camera geometry (an lsst.afw.cameraGeom.Camera)
95  @param[in] catalog: catalog to which to add observations (an ExposureCatalog);
96  if None then a new catalog is created.
97  """
98  if catalog is None:
100  else:
101  if not catalog.getSchema().contains(self.schema):
102  raise ValueError("Catalog schema does not match Task schema")
103  visit = 1
104  for position, pa in self.makePointings(n, tractInfo):
105  for detector in camera:
106  calib = self.buildCalib()
107  record = catalog.addNew()
108  record.setI(self.ccdKey, detector.getId())
109  record.setI(self.visitKey, visit)
110  record.set(self.pointingKey, position)
111  record.setWcs(self.buildWcs(position, pa, detector))
112  record.setCalib(calib)
113  record.setPsf(self.buildPsf(detector))
114  record.setBBox(detector.getBBox())
115  record.setId(butler.get("ccdExposureId", visit=visit, ccd=detector.getId(), immediate=True))
116  visit += 1
117  return catalog
Custom catalog class for ExposureRecord/Table.
Definition: Exposure.h:55

Member Data Documentation

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

Definition at line 83 of file mockObservation.py.

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

Definition at line 78 of file mockObservation.py.

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

Definition at line 85 of file mockObservation.py.

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

Definition at line 86 of file mockObservation.py.

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

Definition at line 82 of file mockObservation.py.

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

Definition at line 84 of file mockObservation.py.


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