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 | List of all members
lsst.meas.base.tests.BlendContext Class Reference

Public Member Functions

def __init__ (self, owner)
 
def __enter__ (self)
 
def addChild (self, instFlux, centroid, shape=None)
 
def __exit__ (self, type_, value, tb)
 

Public Attributes

 owner
 
 parentRecord
 
 parentImage
 
 children
 

Detailed Description

Context manager which adds multiple overlapping sources and a parent.

Notes
-----
This is used as the return value for `TestDataset.addBlend`, and this is
the only way it should be used.

Definition at line 40 of file tests.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.base.tests.BlendContext.__init__ (   self,
  owner 
)

Definition at line 49 of file tests.py.

49  def __init__(self, owner):
50  self.owner = owner
51  self.parentRecord = self.owner.catalog.addNew()
52  self.parentImage = lsst.afw.image.ImageF(self.owner.exposure.getBBox())
53  self.children = []
54 

Member Function Documentation

◆ __enter__()

def lsst.meas.base.tests.BlendContext.__enter__ (   self)

Definition at line 55 of file tests.py.

55  def __enter__(self):
56  # BlendContext is its own context manager, so we just return self.
57  return self
58 

◆ __exit__()

def lsst.meas.base.tests.BlendContext.__exit__ (   self,
  type_,
  value,
  tb 
)

Definition at line 76 of file tests.py.

76  def __exit__(self, type_, value, tb):
77  # We're not using the context manager for any kind of exception safety
78  # or guarantees; we just want the nice "with" statement syntax.
79 
80  if type_ is not None:
81  # exception was raised; just skip all this and let it propagate
82  return
83 
84  # On exit, compute and set the truth values for the parent object.
85  self.parentRecord.set(self.owner.keys["nChild"], len(self.children))
86  # Compute instFlux from sum of component fluxes
87  instFlux = 0.0
88  for record, image in self.children:
89  instFlux += record.get(self.owner.keys["instFlux"])
90  self.parentRecord.set(self.owner.keys["instFlux"], instFlux)
91  # Compute centroid from instFlux-weighted mean of component centroids
92  x = 0.0
93  y = 0.0
94  for record, image in self.children:
95  w = record.get(self.owner.keys["instFlux"])/instFlux
96  x += record.get(self.owner.keys["centroid"].getX())*w
97  y += record.get(self.owner.keys["centroid"].getY())*w
98  self.parentRecord.set(self.owner.keys["centroid"], lsst.geom.Point2D(x, y))
99  # Compute shape from instFlux-weighted mean of offset component shapes
100  xx = 0.0
101  yy = 0.0
102  xy = 0.0
103  for record, image in self.children:
104  w = record.get(self.owner.keys["instFlux"])/instFlux
105  dx = record.get(self.owner.keys["centroid"].getX()) - x
106  dy = record.get(self.owner.keys["centroid"].getY()) - y
107  xx += (record.get(self.owner.keys["shape"].getIxx()) + dx**2)*w
108  yy += (record.get(self.owner.keys["shape"].getIyy()) + dy**2)*w
109  xy += (record.get(self.owner.keys["shape"].getIxy()) + dx*dy)*w
110  self.parentRecord.set(self.owner.keys["shape"], lsst.afw.geom.Quadrupole(xx, yy, xy))
111  # Run detection on the parent image to get the parent Footprint.
112  self.owner._installFootprint(self.parentRecord, self.parentImage)
113  # Create perfect HeavyFootprints for all children; these will need to
114  # be modified later to account for the noise we'll add to the image.
115  deblend = lsst.afw.image.MaskedImageF(self.owner.exposure.getMaskedImage(), True)
116  for record, image in self.children:
117  deblend.getImage().getArray()[:, :] = image.getArray()
118  heavyFootprint = lsst.afw.detection.HeavyFootprintF(self.parentRecord.getFootprint(), deblend)
119  record.setFootprint(heavyFootprint)
120 
121 
An ellipse core with quadrupole moments as parameters.
Definition: Quadrupole.h:47
daf::base::PropertySet * set
Definition: fits.cc:912

◆ addChild()

def lsst.meas.base.tests.BlendContext.addChild (   self,
  instFlux,
  centroid,
  shape = None 
)
Add a child to the blend; return corresponding truth catalog record.

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)

Definition at line 59 of file tests.py.

59  def addChild(self, instFlux, centroid, shape=None):
60  """Add a child to the blend; return corresponding truth catalog record.
61 
62  instFlux : `float`
63  Total instFlux of the source to be added.
64  centroid : `lsst.geom.Point2D`
65  Position of the source to be added.
66  shape : `lsst.afw.geom.Quadrupole`
67  Second moments of the source before PSF convolution. Note that
68  the truth catalog records post-convolution moments)
69  """
70  record, image = self.owner.addSource(instFlux, centroid, shape)
71  record.set(self.owner.keys["parent"], self.parentRecord.getId())
72  self.parentImage += image
73  self.children.append((record, image))
74  return record
75 
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

Member Data Documentation

◆ children

lsst.meas.base.tests.BlendContext.children

Definition at line 53 of file tests.py.

◆ owner

lsst.meas.base.tests.BlendContext.owner

Definition at line 50 of file tests.py.

◆ parentImage

lsst.meas.base.tests.BlendContext.parentImage

Definition at line 52 of file tests.py.

◆ parentRecord

lsst.meas.base.tests.BlendContext.parentRecord

Definition at line 51 of file tests.py.


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