Defects#

class lsst.ip.isr.Defects(defectList=None, metadata=None, *, normalize_on_init=True, **kwargs)#

Bases: IsrCalib

Calibration 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.Defect or lsst.geom.BoxI.

metadatalsst.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_initbool

If True, normalization is applied to the defects in defectList to 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_update context manager if necessary.

The attributes stored in this calibration are:

_defectslist [lsst.meas.algorithms.Defect]

The collection of Defect objects.

Methods Summary

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.

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 Defects from the contents of a BaseCatalog.

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.

toFitsRegionTable()

Convert defect list to BaseCatalog using the FITS region standard.

toTable()

Convert defects to a simple table form that we use to write to text files.

transpose()

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#

newDefects

New list with new Defect entries.

Notes#

This is not a shallow copy in that new Defect instances are created from the original bounding boxes. It’s also not a deep copy since the bounding boxes are not recreated.

classmethod fromDict(dictionary)#

Construct a calibration from a dictionary of properties.

Must be implemented by the specific calibration subclasses.

Parameters#

dictionarydict

Dictionary of properties.

Returns#

caliblsst.ip.isr.CalibType

Constructed calibration.

Raises#

RuntimeError

Raised if the supplied dictionary is for a different calibration.

classmethod fromFootprintList(fpList)#

Compute a defect list from a footprint list, optionally growing the footprints.

Parameters#

fpListlist of lsst.afw.detection.Footprint

Footprint list to process.

Returns#

defectsDefects

List of defects.

classmethod fromMask(mask, maskName)#

Compute a defect list from a specified mask plane.

Parameters#

masklsst.afw.image.Mask or lsst.afw.image.MaskedImage

Image to process.

maskNamestr or list

Mask plane name, or list of names to convert.

Returns#

defectsDefects

Defect list constructed from masked pixels.

classmethod fromTable(tableList, normalize_on_init=True)#

Construct a Defects from the contents of a BaseCatalog.

Parameters#

tablelsst.afw.table.BaseCatalog

Table with one row per defect.

normalize_on_initbool, 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#

defectsDefects

A Defects list.

Notes#

Two table formats are recognized. The first is the FITS regions definition tabular format written by toFitsRegionTable where the pixel origin is corrected from FITS 1-based to a 0-based origin. The second is the legacy defects format using columns x0, y0 (bottom left hand pixel of box in 0-based coordinates), width and height.

The FITS standard regions can only read BOX, POINT, or ROTBOX with a zero degree rotation.

insert(index, value)#
maskPixels(mask, maskName='BAD')#

Set mask plane based on these defects.

Parameters#

maskedImagelsst.afw.image.MaskedImage or lsst.afw.image.Mask

Image to process. Only the mask plane is updated.

maskNamestr, optional

Mask plane name to use.

classmethod readLsstDefectsFile(filename, normalize_on_init=False)#

Read defects information from a legacy LSST format text file.

Parameters#

filenamestr

Name of text file containing the defect information.

normalize_on_initbool, 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#

defectsDefects

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:

x0int

X coordinate of bottom left corner of box.

y0int

Y coordinate of bottom left corner of box.

widthint

X extent of the box.

heightint

Y extent of the box.

Files of this format were used historically to represent defects in simple text form. Use Defects.readText and Defects.writeText to use the more modern format.

toDict()#

Return a dictionary containing the calibration properties.

The dictionary should be able to be round-tripped through fromDict.

Returns#

dictionarydict

Dictionary of properties.

toFitsRegionTable()#

Convert defect list to BaseCatalog using the FITS region standard.

Returns#

tablelsst.afw.table.BaseCatalog

Defects in tabular form.

Notes#

The table created uses the FITS regions definition tabular format. The X and Y coordinates are converted to FITS Physical coordinates that have origin pixel (1, 1) rather than the (0, 0) used in LSST software.

toTable()#

Convert defects to a simple table form that we use to write to text files.

Returns#

tablelsst.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:

x0int

X coordinate of bottom left corner of box.

y0int

Y coordinate of bottom left corner of box.

widthint

X extent of the box.

heightint

Y extent of the box.

transpose()#

Make a transposed copy of this defect list.

Returns#

retDefectListDefects

Transposed list of defects.

updateCounters(columns=None, hot=None, cold=None)#

Update metadata with pixel and column counts.

Parameters#

columnsint, optional

Number of full columns masked.

hotdict [str, int], optional

Dictionary with the count of hot pixels, indexed by amplifier name.

colddict [str, int], optional

Dictionary with the count of hot pixels, indexed by amplifier name.