lsst.meas.base g070148d5b3+79e3dbe116
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
lsst.meas.base.tests.TestDataset Class Reference

Public Member Functions

def makeMinimalSchema (cls)
 
def __init__ (self, bbox, threshold=10.0, exposure=None, **kwds)
 
def addSource (self, instFlux, centroid, shape=None, setPeakSignificance=True)
 
def addBlend (self)
 
def transform (self, wcs, **kwds)
 
def realize (self, noise, schema, randomSeed=1)
 

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)
 
def makeEmptyExposure (bbox, wcs=None, crval=None, cdelt=None, psfSigma=2.0, psfDim=17, calibration=4)
 
def drawGaussian (bbox, instFlux, ellipse)
 

Public Attributes

 keys
 
 threshold
 
 exposure
 
 psfShape
 
 schema
 
 catalog
 

Detailed Description

A simulated dataset consisuting of test image and 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.

Parameters
----------
bbox : `lsst.geom.Box2I` or `lsst.geom.Box2D`
    Bounding box of the test image.
threshold : `float`
    Threshold 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.
exposure : `lsst.afw.image.ExposureF`
    The image to which test sources should be added. Ownership should
    be considered transferred from the caller to the TestDataset.
    Must have a Gaussian PSF for truth catalog shapes to be exact.
**kwds
    Keyword arguments forwarded to makeEmptyExposure if exposure is `None`.

Notes
-----
Typical usage:

.. code-block: py

    bbox = lsst.geom.Box2I(lsst.geom.Point2I(0,0), lsst.geom.Point2I(100,
                                                                     100))
    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 124 of file tests.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 383 of file tests.py.

Member Function Documentation

◆ addBlend()

def lsst.meas.base.tests.TestDataset.addBlend (   self)
Return a context manager which can add a blend of multiple sources.

Notes
-----
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.

Examples
--------
.. code-block: py
    d = TestDataset(...)
    with d.addBlend() as b:
        b.addChild(flux1, centroid1)
        b.addChild(flux2, centroid2, shape2)

Definition at line 465 of file tests.py.

◆ addSource()

def lsst.meas.base.tests.TestDataset.addSource (   self,
  instFlux,
  centroid,
  shape = None,
  setPeakSignificance = True 
)
Add a source to the simulation.

Parameters
----------
instFlux : `float`
    Total instFlux of the source to be added.
centroid : `lsst.geom.Point2D`
    Position of the source to be added.
shape : `lsst.afw.geom.Quadrupole`
    Second moments of the source before PSF convolution. Note that the
    truth catalog records post-convolution moments. If `None`, a point
    source will be added.
setPeakSignificance : `bool`
    Set the ``significance`` field for peaks in the footprints?
    See ``lsst.meas.algorithms.SourceDetectionTask.setPeakSignificance``
    for how this field is computed for real datasets.

Returns
-------
record : `lsst.afw.table.SourceRecord`
    A truth catalog record.
image : `lsst.afw.image.ImageF`
    Single-source image corresponding to the new source.

Definition at line 417 of file tests.py.

◆ drawGaussian()

def lsst.meas.base.tests.TestDataset.drawGaussian (   bbox,
  instFlux,
  ellipse 
)
static
Create an image of an elliptical Gaussian.

Parameters
----------
bbox : `lsst.geom.Box2I` or `lsst.geom.Box2D`
    Bounding box of image to create.
instFlux : `float`
    Total instrumental flux of the Gaussian (normalized analytically,
    not using pixel values).
ellipse : `lsst.afw.geom.Ellipse`
    Defines the centroid and shape.

Returns
-------
image : `lsst.afw.image.ImageF`
    An image of the Gaussian.

Definition at line 356 of file tests.py.

◆ makeEmptyExposure()

def lsst.meas.base.tests.TestDataset.makeEmptyExposure (   bbox,
  wcs = None,
  crval = None,
  cdelt = None,
  psfSigma = 2.0,
  psfDim = 17,
  calibration = 4 
)
static
Create an Exposure, with a PhotoCalib, Wcs, and Psf, but no pixel values.

Parameters
----------
bbox : `lsst.geom.Box2I` or `lsst.geom.Box2D`
    Bounding box of the image in image coordinates.
wcs : `lsst.afw.geom.SkyWcs`, optional
    New WCS for the exposure (created from CRVAL and CDELT if `None`).
crval : `lsst.afw.geom.SpherePoint`, optional
    ICRS center of the TAN WCS attached to the image. If `None`, (45
    degrees, 45 degrees) is assumed.
cdelt : `lsst.geom.Angle`, optional
    Pixel scale of the image. If `None`, 0.2 arcsec is assumed.
psfSigma : `float`, optional
    Radius (sigma) of the Gaussian PSF attached to the image
psfDim : `int`, optional
    Width and height of the image's Gaussian PSF attached to the image
calibration : `float`, optional
    The spatially-constant calibration (in nJy/count) to set the
    PhotoCalib of the exposure.

Returns
-------
exposure : `lsst.age.image.ExposureF`
    An empty image.

Definition at line 312 of file tests.py.

◆ makeMinimalSchema()

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

Notes
-----
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 169 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
Return a perturbed version of the input WCS.

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).

Parameters
----------
oldWcs : `lsst.afw.geom.SkyWcs`
    The input WCS.
minScaleFactor : `float`
    Minimum scale factor to apply to the input WCS.
maxScaleFactor : `float`
    Maximum scale factor to apply to the input WCS.
minRotation : `lsst.geom.Angle` or `None`
    Minimum rotation to apply to the input WCS. If `None`, defaults to
    30 degrees.
maxRotation : `lsst.geom.Angle` or `None`
    Minimum rotation to apply to the input WCS. If `None`, defaults to
    60 degrees.
minRefShift : `lsst.geom.Angle` or `None`
    Miniumum shift to apply to the input WCS reference value. If
    `None`, defaults to 0.5 arcsec.
maxRefShift : `lsst.geom.Angle` or `None`
    Miniumum shift to apply to the input WCS reference value. If
    `None`, defaults to 1.0 arcsec.
minPixShift : `float`
    Minimum shift to apply to the input WCS reference pixel.
maxPixShift : `float`
    Maximum shift to apply to the input WCS reference pixel.
randomSeed : `int`
    Random seed.

Returns
-------
newWcs : `lsst.afw.geom.SkyWcs`
    A perturbed version of the input WCS.

Notes
-----
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 209 of file tests.py.

◆ realize()

def lsst.meas.base.tests.TestDataset.realize (   self,
  noise,
  schema,
  randomSeed = 1 
)
Simulate an exposure and detection catalog for this dataset.

The simulation includes noise, and the detection catalog includes
`~lsst.afw.detection.heavyFootprint.HeavyFootprint`\ s.

Parameters
----------
noise : `float`
Standard deviation of noise to be added to the exposure.  The
noise will be Gaussian and constant, appropriate for the
sky-limited regime.
schema : `lsst.afw.table.Schema`
Schema 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.
randomSeed : `int`, optional
Seed for the random number generator.
If `None`, a seed is chosen automatically.

Returns
-------
`exposure` : `lsst.afw.image.ExposureF`
Simulated image.
`catalog` : `lsst.afw.table.SourceCatalog`
Simulated detection catalog.

Definition at line 533 of file tests.py.

◆ transform()

def lsst.meas.base.tests.TestDataset.transform (   self,
  wcs,
**  kwds 
)
Copy this dataset transformed to a new WCS, with new Psf and PhotoCalib.

Parameters
----------
wcs : `lsst.afw.geom.SkyWcs`
    WCS for the new dataset.
**kwds
    Additional keyword arguments passed on to
    `TestDataset.makeEmptyExposure`.  If not specified, these revert
    to the defaults for `~TestDataset.makeEmptyExposure`, not the
    values in the current dataset.

Returns
-------
newDataset : `TestDataset`
    Transformed copy of this dataset.

Definition at line 484 of file tests.py.

Member Data Documentation

◆ catalog

lsst.meas.base.tests.TestDataset.catalog

Definition at line 390 of file tests.py.

◆ exposure

lsst.meas.base.tests.TestDataset.exposure

Definition at line 387 of file tests.py.

◆ keys

lsst.meas.base.tests.TestDataset.keys

Definition at line 182 of file tests.py.

◆ psfShape

lsst.meas.base.tests.TestDataset.psfShape

Definition at line 388 of file tests.py.

◆ schema

lsst.meas.base.tests.TestDataset.schema

Definition at line 389 of file tests.py.

◆ threshold

lsst.meas.base.tests.TestDataset.threshold

Definition at line 386 of file tests.py.


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