LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+f5613e8b4f,g1470d8bcf6+190ad2ba91,g14a832a312+311607e4ab,g2079a07aa2+86d27d4dc4,g2305ad1205+a8e3196225,g295015adf3+b67ee847e5,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+a761f810f3,g487adcacf7+17c8fdbcbd,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+65b5bd823e,g5a732f18d5+53520f316c,g64a986408d+f5613e8b4f,g6c1bc301e9+51106c2951,g858d7b2824+f5613e8b4f,g8a8a8dda67+585e252eca,g99cad8db69+6729933424,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+ef4e3a5875,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e9bba80f27,gc120e1dc64+eee469a5e5,gc28159a63d+0e5473021a,gcf0d15dbbd+a761f810f3,gdaeeff99f8+f9a426f77a,ge6526c86ff+d4c1d4bfef,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf1cff7945b+f5613e8b4f,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Static Protected Attributes | List of all members
lsst.pipe.tasks.calexpCutout.CalexpCutoutTask Class Reference
Inheritance diagram for lsst.pipe.tasks.calexpCutout.CalexpCutoutTask:

Public Member Functions

 run (self, in_table, calexp)
 

Static Public Attributes

 ConfigClass = CalexpCutoutTaskConfig
 

Static Protected Attributes

str _DefaultName = "calexpCutoutTask"
 

Detailed Description

Task for computing cutouts on a specific calexp given
positions, xspans, and yspans of the stamps.

Definition at line 68 of file calexpCutout.py.

Member Function Documentation

◆ run()

lsst.pipe.tasks.calexpCutout.CalexpCutoutTask.run ( self,
in_table,
calexp )
Compute and return the cutouts.

Parameters
----------
in_table : `astropy.QTable`
    A table containing at least the following columns: position, xspan
    and yspan.  The position should be an `astropy.SkyCoord`.  The
    xspan and yspan are the extent of the cutout in x and y in pixels.
calexp : `lsst.afw.image.ExposureF`
    The calibrated exposure from which to extract cutouts

Returns
-------
output : `lsst.pipe.base.Struct`
    A struct containing:

    * cutouts: an `lsst.meas.algorithms.Stamps` object
               that wraps a list of masked images of the cutouts and a
               `PropertyList` containing the metadata to be persisted
               with the cutouts.  The exposure metadata is preserved and,
               in addition, arrays holding the RA and Dec of each stamp
               in degrees are added to the metadata.  Note: the origin
               of the output stamps is `lsst.afw.image.PARENT`.
    * skipped_positions: a `list` of `lsst.geom.SpherePoint` objects for
                         stamps that were skiped for being off the image
                         or partially off the image

Raises
------
ValueError
    If the input catalog doesn't have the required columns,
    a ValueError is raised

Definition at line 75 of file calexpCutout.py.

75 def run(self, in_table, calexp):
76 """Compute and return the cutouts.
77
78 Parameters
79 ----------
80 in_table : `astropy.QTable`
81 A table containing at least the following columns: position, xspan
82 and yspan. The position should be an `astropy.SkyCoord`. The
83 xspan and yspan are the extent of the cutout in x and y in pixels.
84 calexp : `lsst.afw.image.ExposureF`
85 The calibrated exposure from which to extract cutouts
86
87 Returns
88 -------
89 output : `lsst.pipe.base.Struct`
90 A struct containing:
91
92 * cutouts: an `lsst.meas.algorithms.Stamps` object
93 that wraps a list of masked images of the cutouts and a
94 `PropertyList` containing the metadata to be persisted
95 with the cutouts. The exposure metadata is preserved and,
96 in addition, arrays holding the RA and Dec of each stamp
97 in degrees are added to the metadata. Note: the origin
98 of the output stamps is `lsst.afw.image.PARENT`.
99 * skipped_positions: a `list` of `lsst.geom.SpherePoint` objects for
100 stamps that were skiped for being off the image
101 or partially off the image
102
103 Raises
104 ------
105 ValueError
106 If the input catalog doesn't have the required columns,
107 a ValueError is raised
108 """
109 cols = in_table.colnames
110 if 'position' not in cols or 'xspan' not in cols or 'yspan' not in cols:
111 raise ValueError('Required column missing from the input table. '
112 'Required columns are "position", "xspan", and "yspan". '
113 f'The column names are: {in_table.colnames}')
114 wcs = calexp.getWcs()
115 if wcs is None:
116 raise RuntimeError("Calexp has no WCS, so cannot compute sky positions.")
117 max_idx = self.config.max_cutouts
118 cutout_list = []
119 mim = calexp.getMaskedImage()
120 ras = []
121 decs = []
122 skipped_positions = []
123 for rec in in_table[:max_idx]:
124 ra = rec['position'].ra.degree
125 dec = rec['position'].dec.degree
126 ras.append(ra)
127 decs.append(dec)
128 pt = geom.SpherePoint(geom.Angle(ra, geom.degrees),
129 geom.Angle(dec, geom.degrees))
130 pix = wcs.skyToPixel(pt)
131 xspan = rec['xspan'].value
132 yspan = rec['yspan'].value
133 # Clamp to LL corner of the LL pixel and draw extent from there
134 box = geom.Box2I(geom.Point2I(int(pix.x-xspan/2), int(pix.y-yspan/2)),
135 geom.Extent2I(xspan, yspan))
136 if not mim.getBBox().contains(box):
137 if not self.config.skip_bad:
138 raise ValueError(f'Cutout bounding box is not completely contained in the image: {box}')
139 else:
140 skipped_positions.append(pt)
141 continue
142 sub = mim.Factory(mim, box)
143 stamp = Stamp(stamp_im=sub, position=pt)
144 cutout_list.append(stamp)
145 metadata = calexp.getMetadata()
146 metadata['RA_DEG'] = ras
147 metadata['DEC_DEG'] = decs
148 return pipeBase.Struct(cutouts=Stamps(cutout_list, metadata=metadata),
149 skipped_positions=skipped_positions)
A class representing an angle.
Definition Angle.h:128
An integer coordinate rectangle.
Definition Box.h:55
Point in an unspecified spherical coordinate system.
Definition SpherePoint.h:57

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.calexpCutout.CalexpCutoutTask._DefaultName = "calexpCutoutTask"
staticprotected

Definition at line 73 of file calexpCutout.py.

◆ ConfigClass

lsst.pipe.tasks.calexpCutout.CalexpCutoutTask.ConfigClass = CalexpCutoutTaskConfig
static

Definition at line 72 of file calexpCutout.py.


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