Defects#
- class lsst.ip.isr.Defects(defectList=None, metadata=None, *, normalize_on_init=True, **kwargs)#
Bases:
IsrCalibCalibration handler for collections of
lsst.meas.algorithms.Defect.Parameters#
- defectListiterable, optional
Collections of defects to apply to the image. Can be an iterable of
lsst.meas.algorithms.Defectorlsst.geom.BoxI.- metadata
lsst.daf.base.PropertyList, optional Metadata to associate with the defects. Will be copied and overwrite existing metadata, if any. If not supplied the existing metadata will be reset.
- normalize_on_init
bool If True, normalization is applied to the defects in
defectListto remove duplicates, eliminate overlaps, etc.
Notes#
Defects are stored within this collection in a “reduced” or “normalized” form: rather than simply storing the bounding boxes which are added to the collection, we eliminate overlaps and duplicates. This normalization procedure may introduce overhead when adding many new defects; it may be temporarily disabled using the
Defects.bulk_updatecontext manager if necessary.The attributes stored in this calibration are:
- _defects
list[lsst.meas.algorithms.Defect] The collection of Defect objects.
Methods Summary
append(value)Temporarily suspend normalization of the defect list.
copy()Copy the defects to a new list, creating new defects from the bounding boxes.
fromDict(dictionary)Construct a calibration from a dictionary of properties.
fromFootprintList(fpList)Compute a defect list from a footprint list, optionally growing the footprints.
fromMask(mask, maskName)Compute a defect list from a specified mask plane.
fromTable(tableList[, normalize_on_init])Construct a
Defectsfrom the contents of aBaseCatalog.insert(index, value)maskPixels(mask[, maskName])Set mask plane based on these defects.
readLsstDefectsFile(filename[, ...])Read defects information from a legacy LSST format text file.
toDict()Return a dictionary containing the calibration properties.
Convert defect list to
BaseCatalogusing the FITS region standard.toTable()Convert defects to a simple table form that we use to write to text files.
Make a transposed copy of this defect list.
updateCounters([columns, hot, cold])Update metadata with pixel and column counts.
Methods Documentation
- append(value)#
- bulk_update()#
Temporarily suspend normalization of the defect list.
- copy()#
Copy the defects to a new list, creating new defects from the bounding boxes.
Returns#
- new
Defects New list with new
Defectentries.
Notes#
This is not a shallow copy in that new
Defectinstances are created from the original bounding boxes. It’s also not a deep copy since the bounding boxes are not recreated.- new
- classmethod fromDict(dictionary)#
Construct a calibration from a dictionary of properties.
Must be implemented by the specific calibration subclasses.
Parameters#
- dictionary
dict Dictionary of properties.
Returns#
- calib
lsst.ip.isr.CalibType Constructed calibration.
Raises#
- RuntimeError
Raised if the supplied dictionary is for a different calibration.
- dictionary
- classmethod fromFootprintList(fpList)#
Compute a defect list from a footprint list, optionally growing the footprints.
Parameters#
- fpList
listoflsst.afw.detection.Footprint Footprint list to process.
Returns#
- defects
Defects List of defects.
- fpList
- classmethod fromMask(mask, maskName)#
Compute a defect list from a specified mask plane.
Parameters#
- mask
lsst.afw.image.Maskorlsst.afw.image.MaskedImage Image to process.
- maskName
strorlist Mask plane name, or list of names to convert.
Returns#
- defects
Defects Defect list constructed from masked pixels.
- mask
- classmethod fromTable(tableList, normalize_on_init=True)#
Construct a
Defectsfrom the contents of aBaseCatalog.Parameters#
- table
lsst.afw.table.BaseCatalog Table with one row per defect.
- normalize_on_init
bool, optional If
True, normalization is applied to the defects listed in the table to remove duplicates, eliminate overlaps, etc. Otherwise the defects in the returned object exactly match those in the table.
Returns#
Notes#
Two table formats are recognized. The first is the FITS regions definition tabular format written by
toFitsRegionTablewhere the pixel origin is corrected from FITS 1-based to a 0-based origin. The second is the legacy defects format using columnsx0,y0(bottom left hand pixel of box in 0-based coordinates),widthandheight.The FITS standard regions can only read BOX, POINT, or ROTBOX with a zero degree rotation.
- table
- insert(index, value)#
- maskPixels(mask, maskName='BAD')#
Set mask plane based on these defects.
Parameters#
- maskedImage
lsst.afw.image.MaskedImageorlsst.afw.image.Mask Image to process. Only the mask plane is updated.
- maskNamestr, optional
Mask plane name to use.
- maskedImage
- classmethod readLsstDefectsFile(filename, normalize_on_init=False)#
Read defects information from a legacy LSST format text file.
Parameters#
- filename
str Name of text file containing the defect information.
- normalize_on_init
bool, optional If
True, normalization is applied to the defects listed in the table to remove duplicates, eliminate overlaps, etc. Otherwise the defects in the returned object exactly match those in the table.
Returns#
- defects
Defects The defects.
Notes#
These defect text files are used as the human readable definitions of defects in calibration data definition repositories. The format is to use four columns defined as follows:
- x0
int X coordinate of bottom left corner of box.
- y0
int Y coordinate of bottom left corner of box.
- width
int X extent of the box.
- height
int Y extent of the box.
Files of this format were used historically to represent defects in simple text form. Use
Defects.readTextandDefects.writeTextto use the more modern format.- filename
- toDict()#
Return a dictionary containing the calibration properties.
The dictionary should be able to be round-tripped through
fromDict.Returns#
- dictionary
dict Dictionary of properties.
- dictionary
- toFitsRegionTable()#
Convert defect list to
BaseCatalogusing the FITS region standard.Returns#
- table
lsst.afw.table.BaseCatalog Defects in tabular form.
Notes#
The table created uses the FITS regions definition tabular format. The
XandYcoordinates are converted to FITS Physical coordinates that have origin pixel (1, 1) rather than the (0, 0) used in LSST software.- table
- toTable()#
Convert defects to a simple table form that we use to write to text files.
Returns#
- table
lsst.afw.table.BaseCatalog Defects in simple tabular form.
Notes#
These defect tables are used as the human readable definitions of defects in calibration data definition repositories. The format is to use four columns defined as follows:
- x0
int X coordinate of bottom left corner of box.
- y0
int Y coordinate of bottom left corner of box.
- width
int X extent of the box.
- height
int Y extent of the box.
- table
- transpose()#
Make a transposed copy of this defect list.
Returns#
- retDefectList
Defects Transposed list of defects.
- retDefectList
- updateCounters(columns=None, hot=None, cold=None)#
Update metadata with pixel and column counts.
Parameters#
- columns
int, optional Number of full columns masked.
- hot
dict[str,int], optional Dictionary with the count of hot pixels, indexed by amplifier name.
- cold
dict[str,int], optional Dictionary with the count of hot pixels, indexed by amplifier name.
- columns