lsst.meas.base  16.0-13-gd9b1b71+10
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
lsst.meas.base.tests.TestDataset Class Reference

A simulated dataset consisting of a test image and an associated truth catalog. More...

Public Member Functions

def makeMinimalSchema (cls)
 
def __init__ (self, bbox, threshold=10.0, exposure=None, kwds)
 Initialize the dataset. More...
 
def addSource (self, instFlux, centroid, shape=None)
 Add a source to the simulation. More...
 
def addBlend (self)
 Return a context manager that allows a blend of multiple sources to be added. More...
 
def transform (self, wcs, kwds)
 Create a copy of the dataset transformed to a new WCS, with new Psf and Calib. More...
 
def realize (self, noise, schema, randomSeed=1)
 Create a simulated with noise and a simulated post-detection catalog with (Heavy)Footprints. More...
 

Static Public Member Functions

def makePerturbedWcs (oldWcs, minScaleFactor=1.2, maxScaleFactor=1.5, minRotation=None, maxRotation=None, minRefShift=None, maxRefShift=None, minPixShift=2.0, maxPixShift=4.0, randomSeed=1)
 Create a new undistorted TAN WCS that is similar but not identical to another, with random scaling, rotation, and offset (in both pixel position and reference position). More...
 
def makeEmptyExposure (bbox, wcs=None, crval=None, cdelt=None, psfSigma=2.0, psfDim=17, fluxMag0=1E12)
 Create an Exposure, with a Calib, Wcs, and Psf, but no pixel values set. More...
 
def drawGaussian (bbox, instFlux, ellipse)
 Create an image of an elliptical Gaussian. More...
 

Public Attributes

 keys
 
 threshold
 
 exposure
 
 psfShape
 
 schema
 
 catalog
 

Detailed Description

A simulated dataset consisting of a test image and an associated truth catalog.

TestDataset creates an idealized image made of pure Gaussians (including a Gaussian PSF), with simple noise and idealized Footprints/HeavyFootprints that simulated the outputs of detection and deblending. Multiple noise realizations can be created from the same underlying sources, allowing uncertainty estimates to be verified via Monte Carlo.

Typical usage:

dataset = TestDataset(bbox)
dataset.addSource(instFlux=1E5, centroid=lsst.geom.Point2D(25, 26))
dataset.addSource(instFlux=2E5, centroid=lsst.geom.Point2D(75, 24),
shape=lsst.afw.geom.Quadrupole(8, 7, 2))
with dataset.addBlend() as family:
family.addChild(instFlux=2E5, centroid=lsst.geom.Point2D(50, 72))
family.addChild(instFlux=1.5E5, centroid=lsst.geom.Point2D(51, 74))
exposure, catalog = dataset.realize(noise=100.0, schema=TestDataset.makeMinimalSchema())

Definition at line 120 of file tests.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.tests.TestDataset.__init__ (   self,
  bbox,
  threshold = 10.0,
  exposure = None,
  kwds 
)

Initialize the dataset.

Parameters
[in]bboxBounding box of the test image.
[in]thresholdThreshold absolute value used to determine footprints for simulated sources. This thresholding will be applied before noise is actually added to images (or before the noise level is even known), so this will necessarily produce somewhat artificial footprints.
[in]exposurelsst.afw.image.ExposureF test sources should be added to. Ownership should be considered transferred from the caller to the TestDataset. Must have a Gaussian Psf for truth catalog shapes to be exact.
[in]**kwdsKeyword arguments forwarded to makeEmptyExposure if exposure is None.

Definition at line 294 of file tests.py.

Member Function Documentation

◆ addBlend()

def lsst.meas.base.tests.TestDataset.addBlend (   self)

Return a context manager that allows a blend of multiple sources to be added.

Example:

d = TestDataset(...)
with d.addBlend() as b:
b.addChild(flux1, centroid1)
b.addChild(flux2, centroid2, shape2)

Note that nothing stops you from creating overlapping sources just using the addSource() method, but addBlend() is necesssary to create a parent object and deblended HeavyFootprints of the type produced by the detection and deblending pipelines.

Definition at line 368 of file tests.py.

◆ addSource()

def lsst.meas.base.tests.TestDataset.addSource (   self,
  instFlux,
  centroid,
  shape = None 
)

Add a source to the simulation.

Parameters
[in]instFluxTotal instFlux of the source to be added.
[in]centroidPosition of the source to be added (lsst.geom.Point2D).
[in]shape2nd moments of the source before PSF convolution (lsst.afw.geom.Quadrupole). Note that the truth catalog records post-convolution moments). If None, a point source will be added.
Returns
a truth catalog record and single-source image corresponding to the new source.

Definition at line 332 of file tests.py.

◆ drawGaussian()

def lsst.meas.base.tests.TestDataset.drawGaussian (   bbox,
  instFlux,
  ellipse 
)
static

Create an image of an elliptical Gaussian.

Parameters
[in,out]bboxBounding box of image to create.
[in]instFluxTotal instFlux of the Gaussian (normalized analytically, not using pixel values)
[in]ellipselsst.afw.geom.Ellipse holding the centroid and shape.

Definition at line 276 of file tests.py.

◆ makeEmptyExposure()

def lsst.meas.base.tests.TestDataset.makeEmptyExposure (   bbox,
  wcs = None,
  crval = None,
  cdelt = None,
  psfSigma = 2.0,
  psfDim = 17,
  fluxMag0 = 1E12 
)
static

Create an Exposure, with a Calib, Wcs, and Psf, but no pixel values set.

Parameters
[in]bboxBounding box of the image (image coordinates) as returned by makeCatalog.
[in]wcsNew Wcs for the exposure (created from crval and cdelt if None).
[in]crvalafw.geom.SpherePoint: ICRS center of the TAN WCS attached to the image.
[in]cdeltafw.geom.Angle: pixel scale of the image
[in]psfSigmaRadius (sigma) of the Gaussian PSF attached to the image
[in]psfDimWidth and height of the image's Gaussian PSF attached to the image
[in]fluxMag0Flux at magnitude zero (in e-) used to set the Calib of the exposure.

Definition at line 246 of file tests.py.

◆ makeMinimalSchema()

def lsst.meas.base.tests.TestDataset.makeMinimalSchema (   cls)
Return the minimal schema needed to hold truth catalog fields.

When TestDataset.realize() is called, the schema must include at least these fields.
Usually it will include additional fields for measurement algorithm outputs, allowing
the same catalog to be used for both truth values (the fields from the minimal schema)
and the measurements.

Definition at line 144 of file tests.py.

◆ makePerturbedWcs()

def lsst.meas.base.tests.TestDataset.makePerturbedWcs (   oldWcs,
  minScaleFactor = 1.2,
  maxScaleFactor = 1.5,
  minRotation = None,
  maxRotation = None,
  minRefShift = None,
  maxRefShift = None,
  minPixShift = 2.0,
  maxPixShift = 4.0,
  randomSeed = 1 
)
static

Create a new undistorted TAN WCS that is similar but not identical to another, with random scaling, rotation, and offset (in both pixel position and reference position).

The maximum and minimum arguments are interpreted as absolute values for a split range that covers both positive and negative values (as this method is used in testing, it is typically most important to avoid perturbations near zero). Scale factors are treated somewhat differently: the actual scale factor is chosen between minScaleFactor and maxScaleFactor OR (1/maxScaleFactor) and (1/minScaleFactor).

The default range for rotation is 30-60 degrees, and the default range for reference shift is 0.5-1.0 arcseconds (these cannot be safely included directly as default values because Angle objects are mutable).

The random number generator is primed with the seed given. If None, a seed is automatically chosen.

Definition at line 185 of file tests.py.

◆ realize()

def lsst.meas.base.tests.TestDataset.realize (   self,
  noise,
  schema,
  randomSeed = 1 
)

Create a simulated with noise and a simulated post-detection catalog with (Heavy)Footprints.

Parameters
[in]noiseStandard deviation of noise to be added to the exposure. The noise will be Gaussian and constant, appropriate for the sky-limited regime.
[in]schemaSchema of the new catalog to be created. Must start with self.schema (i.e. schema.contains(self.schema) must be True), but typically contains fields for already-configured measurement algorithms as well.
[in]randomSeedSeed for the random number generator. If None, a seed is chosen automatically.
Returns
a tuple of (exposure, catalog)

Definition at line 426 of file tests.py.

◆ transform()

def lsst.meas.base.tests.TestDataset.transform (   self,
  wcs,
  kwds 
)

Create a copy of the dataset transformed to a new WCS, with new Psf and Calib.

Parameters
[in]wcsWcs for the new dataset.
[in]**kwdsAdditional keyword arguments passed on to makeEmptyExposure. If not specified, these revert to the defaults for makeEmptyExposure, not the values in the current dataset.

Definition at line 386 of file tests.py.

Member Data Documentation

◆ catalog

lsst.meas.base.tests.TestDataset.catalog

Definition at line 314 of file tests.py.

◆ exposure

lsst.meas.base.tests.TestDataset.exposure

Definition at line 311 of file tests.py.

◆ keys

lsst.meas.base.tests.TestDataset.keys

Definition at line 154 of file tests.py.

◆ psfShape

lsst.meas.base.tests.TestDataset.psfShape

Definition at line 312 of file tests.py.

◆ schema

lsst.meas.base.tests.TestDataset.schema

Definition at line 313 of file tests.py.

◆ threshold

lsst.meas.base.tests.TestDataset.threshold

Definition at line 310 of file tests.py.


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