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
Functions
lsst.afw.image.utils Namespace Reference

Functions

def clipImage (im, minClip, maxClip)
 
def resetFilters ()
 
def defineFilter (name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False)
 
def getProjectionIndices (imageBBox, targetBBox)
 
def projectImage (image, bbox, fill=0)
 

Function Documentation

◆ clipImage()

def lsst.afw.image.utils.clipImage (   im,
  minClip,
  maxClip 
)
Clip an image to lie between minClip and maxclip (None to ignore)

Definition at line 35 of file utils.py.

35 def clipImage(im, minClip, maxClip):
36  """Clip an image to lie between minClip and maxclip (None to ignore)"""
37  if isinstance(im, MaskedImage):
38  mi = im
39  else:
40  mi = makeMaskedImage(im, Mask(im.getDimensions()))
41 
42  if minClip is not None:
44  mi, afwDetect.Threshold(-minClip, afwDetect.Threshold.VALUE, False))
45  afwDetect.setImageFromFootprintList(
46  mi.getImage(), ds.getFootprints(), minClip)
47 
48  if maxClip is not None:
50  afwDetect.setImageFromFootprintList(
51  mi.getImage(), ds.getFootprints(), maxClip)
52 
53 
54 @deprecated(reason=("Removed with no replacement (FilterLabels do not need to be reset)."
55  " Will be removed after v22."), category=FutureWarning, version="v22")
A set of Footprints, associated with a MaskedImage.
Definition: FootprintSet.h:53
A Threshold is used to pass a threshold value to detection algorithms.
Definition: Threshold.h:43
def clipImage(im, minClip, maxClip)
Definition: utils.py:35
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT >> image, typename std::shared_ptr< Mask< MaskPixelT >> mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT >> variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
Definition: MaskedImage.h:1240

◆ defineFilter()

def lsst.afw.image.utils.defineFilter (   name,
  lambdaEff,
  lambdaMin = np.nan,
  lambdaMax = np.nan,
  alias = [],
  force = False 
)
Define a filter and its properties in the filter registry

Definition at line 65 of file utils.py.

65 def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False):
66  """Define a filter and its properties in the filter registry"""
67  prop = FilterProperty(name, lambdaEff, lambdaMin, lambdaMax, force)
68  Filter.define(prop)
69  if isinstance(alias, str):
70  Filter.defineAlias(name, alias)
71  else:
72  for a in alias:
73  Filter.defineAlias(name, a)
74 
75 
def defineFilter(name, lambdaEff, lambdaMin=np.nan, lambdaMax=np.nan, alias=[], force=False)
Definition: utils.py:65
FilterProperty(FilterProperty const &)=default

◆ getProjectionIndices()

def lsst.afw.image.utils.getProjectionIndices (   imageBBox,
  targetBBox 
)
Get the indices to project an image

Given an image and target bounding box,
calculate the indices needed to appropriately
slice the input image and target image to
project the image to the target.

Parameters
----------
imageBBox: Box2I
    Bounding box of the input image
targetBBox: Box2I
    Bounding box of the target image

Returns
-------
targetSlices: tuple
    Slices of the target image in the form (by, bx), (iy, ix).
imageIndices: tuple
    Slices of the input image in the form (by, bx), (iy, ix).

Definition at line 76 of file utils.py.

76 def getProjectionIndices(imageBBox, targetBBox):
77  """Get the indices to project an image
78 
79  Given an image and target bounding box,
80  calculate the indices needed to appropriately
81  slice the input image and target image to
82  project the image to the target.
83 
84  Parameters
85  ----------
86  imageBBox: Box2I
87  Bounding box of the input image
88  targetBBox: Box2I
89  Bounding box of the target image
90 
91  Returns
92  -------
93  targetSlices: tuple
94  Slices of the target image in the form (by, bx), (iy, ix).
95  imageIndices: tuple
96  Slices of the input image in the form (by, bx), (iy, ix).
97  """
98  def getMin(dXmin):
99  """Get minimum indices"""
100  if dXmin < 0:
101  bxStart = -dXmin
102  ixStart = 0
103  else:
104  bxStart = 0
105  ixStart = dXmin
106  return bxStart, ixStart
107 
108  def getMax(dXmax):
109  """Get maximum indices"""
110  if dXmax < 0:
111  bxEnd = None
112  ixEnd = dXmax
113  elif dXmax != 0:
114  bxEnd = -dXmax
115  ixEnd = None
116  else:
117  bxEnd = ixEnd = None
118  return bxEnd, ixEnd
119 
120  dXmin = targetBBox.getMinX() - imageBBox.getMinX()
121  dXmax = targetBBox.getMaxX() - imageBBox.getMaxX()
122  dYmin = targetBBox.getMinY() - imageBBox.getMinY()
123  dYmax = targetBBox.getMaxY() - imageBBox.getMaxY()
124 
125  bxStart, ixStart = getMin(dXmin)
126  byStart, iyStart = getMin(dYmin)
127  bxEnd, ixEnd = getMax(dXmax)
128  byEnd, iyEnd = getMax(dYmax)
129 
130  bx = slice(bxStart, bxEnd)
131  by = slice(byStart, byEnd)
132  ix = slice(ixStart, ixEnd)
133  iy = slice(iyStart, iyEnd)
134  return (by, bx), (iy, ix)
135 
136 
def getProjectionIndices(imageBBox, targetBBox)
Definition: utils.py:76

◆ projectImage()

def lsst.afw.image.utils.projectImage (   image,
  bbox,
  fill = 0 
)
Project an image into a bounding box

Return a new image whose pixels are equal to those of
`image` within `bbox`, and equal to `fill` outside.

Parameters
----------
image: `afw.Image` or `afw.MaskedImage`
    The image to project
bbox: `Box2I`
    The bounding box to project onto.
fill: number
    The value to fill the region of the new
    image outside the bounding box of the original.

Returns
-------
newImage: `afw.Image` or `afw.MaskedImage`
    The new image with the input image projected
    into its bounding box.

Definition at line 137 of file utils.py.

137 def projectImage(image, bbox, fill=0):
138  """Project an image into a bounding box
139 
140  Return a new image whose pixels are equal to those of
141  `image` within `bbox`, and equal to `fill` outside.
142 
143  Parameters
144  ----------
145  image: `afw.Image` or `afw.MaskedImage`
146  The image to project
147  bbox: `Box2I`
148  The bounding box to project onto.
149  fill: number
150  The value to fill the region of the new
151  image outside the bounding box of the original.
152 
153  Returns
154  -------
155  newImage: `afw.Image` or `afw.MaskedImage`
156  The new image with the input image projected
157  into its bounding box.
158  """
159  if image.getBBox() == bbox:
160  return image
161  (by, bx), (iy, ix) = getProjectionIndices(image.getBBox(), bbox)
162 
163  if isinstance(image, MaskedImage):
164  newImage = type(image.image)(bbox)
165  newImage.array[by, bx] = image.image.array[iy, ix]
166  newMask = type(image.mask)(bbox)
167  newMask.array[by, bx] = image.mask.array[iy, ix]
168  newVariance = type(image.image)(bbox)
169  newVariance.array[by, bx] = image.variance.array[iy, ix]
170  newImage = MaskedImage(image=newImage, mask=newMask, variance=newVariance, dtype=newImage.array.dtype)
171  else:
172  newImage = type(image)(bbox)
173  if fill != 0:
174  newImage.set(fill)
175  newImage.array[by, bx] = image.array[iy, ix]
176  return newImage
table::Key< int > type
Definition: Detector.cc:163
def projectImage(image, bbox, fill=0)
Definition: utils.py:137

◆ resetFilters()

def lsst.afw.image.utils.resetFilters ( )
Reset registry of filters and filter properties

Definition at line 56 of file utils.py.

56 def resetFilters():
57  """Reset registry of filters and filter properties"""
58  Filter.reset()
59  FilterProperty.reset()
60 
61 
62 @deprecated(reason=("Removed with no replacement (but see lsst::afw::image::TransmissionCurve for how to set" "and retrieve filter wavelength information). Will be removed after v22."),
63  category=FutureWarning, version="v22")
64