VisitImage#
- class lsst.images.VisitImage(image: Image, *, mask: Mask | None = None, variance: Image | None = None, mask_schema: MaskSchema | None = None, projection: Projection[DetectorFrame] | None = None, obs_info: ObservationInfo | None = None, summary_stats: ObservationSummaryStats | None = None, psf: PointSpreadFunction | ArchiveReadError, metadata: dict[str, MetadataValue] | None = None)#
Bases:
MaskedImageA calibrated single-visit image.
Parameters#
- image
The main image plane. If this has a
Projection, it will be used for all planes unless aprojectionis passed separately.- mask
A bitmask image that annotates the main image plane. Must have the same bounding box as
imageif provided. Any attached projection is replaced (possibly byNone).- variance
The per-pixel uncertainty of the main image as an image of variance values. Must have the same bounding box as
imageif provided, and its units must be the square ofimage.unitorNone. Values default to1.0. Any attached projection is replaced (possibly byNone).- mask_schema
Schema for the mask plane. Must be provided if and only if
maskis not provided.- projection
Projection that maps the pixel grid to the sky. Can only be
Noneif a projection is already attached toimage.- obs_info
General information about this visit in standardized form.
- summary_stats
Optional summary statistics associated with this visit.
- psf
Point-spread function model for this image, or an exception explaining why it could not be read (to be raised if the PSF is requested later).
- metadata
Arbitrary flexible metadata to associate with the image.
Attributes Summary
A proxy object for slicing a generalized image using absolute pixel coordinates.
An Astropy WCS for the pixel arrays (
ProjectionAstropyView).The bounding box shared by all three image planes (
Box).The butler dataset reference for this image (
lsst.daf.butler.SerializedDatasetRef|None).The butler inputs and ID of the task quantum that produced this dataset (
lsst.daf.butler.DatasetProvenance|None)An Astropy FITS WCS for this image's pixel array.
The main image plane (
Image).A proxy object for slicing a generalized image using "local" or "array" pixel coordinates.
The mask plane (
Mask).Arbitrary flexible metadata associated with the image (
dict).General information about this observation in standard form.
The projection that maps the pixel grid to the sky (
Projection[DetectorFrame]).The point-spread function model for this image (
psfs.PointSpreadFunction).Optional summary statistics for this observation (
ObservationSummaryStats).The units of the image plane (
astropy.units.Unit).The variance plane (
Image).Methods Summary
copy()Deep-copy the visit image.
deserialize(model, archive, *[, bbox])Deserialize an image from an input archive.
from_legacy(legacy, *[, unit, plane_map, ...])Convert from an
lsst.afw.image.Exposureinstance.read_fits(url, *[, bbox])Read an image from a FITS file.
Read a FITS file written by
lsst.afw.image.Exposure.writeFits.serialize(archive)Serialize the masked image to an output archive.
to_legacy(*[, copy, plane_map])Convert to an
lsst.afw.image.MaskedImageinstance.write_fits(filename, *[, image_compression, ...])Write the image to a FITS file.
Attributes Documentation
- absolute#
A proxy object for slicing a generalized image using absolute pixel coordinates.
Notes#
In this convention, the first row and column of the pixel grid is
bbox.start. A subimage and its parent image share the same absolute pixel coordinate system, and mostlsst.imagestypes (e.g.Box,Projection,PointSpreadFunction) operate exclusively in this system.Note that
astropy.wcsandnumpy.ndarrayare not aware of thebbox.startoffset that defines tihs coordinates system; uselocalslicing for indices obtained from those.See Also#
lsst.images.BoxSliceFactory lsst.images.IntervalSliceFactory
- astropy_wcs#
An Astropy WCS for the pixel arrays (
ProjectionAstropyView).Notes#
As expected for Astropy WCS objects, this defines pixel coordinates such that the first row and column in the arrays are
(0, 0), notbbox.start, as is the case forprojection.This object satisfies the
astropy.wcs.wcsapi.BaseHighLevelWCSandastropy.wcs.wcsapi.BaseLowLevelWCSinterfaces, but it is not anastropy.wcs.WCS(usefits_wcsfor that).
- butler_dataset#
The butler dataset reference for this image (
lsst.daf.butler.SerializedDatasetRef|None).
- butler_provenance#
The butler inputs and ID of the task quantum that produced this dataset (
lsst.daf.butler.DatasetProvenance|None)
- fits_wcs#
An Astropy FITS WCS for this image’s pixel array.
Notes#
As expected for Astropy WCS objects, this defines pixel coordinates such that the first row and column in any associated arrays are
(0, 0), notbbox.start, as is the case forprojection.This may be an approximation or absent if
projectionis not naturally representable as a FITS WCS.
- local#
A proxy object for slicing a generalized image using “local” or “array” pixel coordinates.
Notes#
In this convention, the first row and column of the pixel grid is always at
(0, 0). This is also the convention used byastropy.wcsobjects. When a subimage is created from a parent image, its “local” coordinate system is offset from the coordinate systems of the parent image.Note that most
lsst.imagestypes (e.g.Box,Projection,PointSpreadFunction) operate instead in “absolute” coordinates, which is shared by subimage and their parents.See Also#
lsst.images.BoxSliceFactory lsst.images.IntervalSliceFactory
- metadata#
Arbitrary flexible metadata associated with the image (
dict).Notes#
Metadata is shared with subimages and other views. It can be disconnected by reassigning to a copy explicitly:
image.metadata = image.metadata.copy()
- obs_info#
General information about this observation in standard form. (
ObservationInfo).
- projection#
The projection that maps the pixel grid to the sky (
Projection[DetectorFrame]).
- psf#
The point-spread function model for this image (
psfs.PointSpreadFunction).
- summary_stats#
Optional summary statistics for this observation (
ObservationSummaryStats).
- unit#
The units of the image plane (
astropy.units.Unit).
Methods Documentation
- copy() VisitImage#
Deep-copy the visit image.
- static deserialize(model: VisitImageSerializationModel[Any], archive: InputArchive[Any], *, bbox: Box | None = None) VisitImage#
Deserialize an image from an input archive.
Parameters#
- model
A Pydantic model representation of the image, holding references to data stored in the archive.
- archive
Archive to read from.
- bbox
Bounding box of a subimage to read instead.
- static from_legacy(legacy: Any, *, unit: Unit | None = None, plane_map: Mapping[str, MaskPlane] | None = None, instrument: str | None = None, visit: int | None = None) VisitImage#
Convert from an
lsst.afw.image.Exposureinstance.Parameters#
- legacy
An
lsst.afw.image.Exposureinstance that will share image and variance (but not mask) pixel data with the returned object.- unit
Units of the image. If not provided, the
BUNITmetadata key will be used, if available.- plane_map
A mapping from legacy mask plane name to the new plane name and description. If
None(default)get_legacy_visit_image_mask_planesis used.- instrument
Name of the instrument. Extracted from the metadata if not provided.
- visit
ID of the visit. Extracted from the metadata if not provided.
- classmethod read_fits(url: str | ParseResult | ResourcePath | Path, *, bbox: Box | None = None) MaskedImage#
Read an image from a FITS file.
Parameters#
- url
URL of the file to read; may be any type supported by
lsst.resources.ResourcePath.- bbox
Bounding box of a subimage to read instead.
- static read_legacy(filename: str, *, component: Literal['bbox']) Box#
- static read_legacy(filename: str, *, preserve_quantization: bool = False, instrument: str | None = None, visit: int | None = None, component: Literal['image']) Image
- static read_legacy(filename: str, *, plane_map: Mapping[str, MaskPlane] | None = None, instrument: str | None = None, visit: int | None = None, component: Literal['mask']) Mask
- static read_legacy(filename: str, *, preserve_quantization: bool = False, instrument: str | None = None, visit: int | None = None, component: Literal['variance']) Image
- static read_legacy(filename: str, *, instrument: str | None = None, visit: int | None = None, component: Literal['projection']) Projection[DetectorFrame]
- static read_legacy(filename: str, *, component: Literal['psf']) PointSpreadFunction
- static read_legacy(filename: str, *, component: Literal['obs_info']) ObservationInfo
- static read_legacy(filename: str, *, component: Literal['summary_stats']) ObservationSummaryStats
- static read_legacy(filename: str, *, preserve_quantization: bool = False, plane_map: Mapping[str, MaskPlane] | None = None, instrument: str | None = None, visit: int | None = None, component: None = None) VisitImage
Read a FITS file written by
lsst.afw.image.Exposure.writeFits.Parameters#
- filename
Full name of the file.
- preserve_quantization
If
True, ensure that writing the masked image back out again will exactly preserve quantization-compressed pixel values. This causes the image and variance plane arrays to be marked as read-only and stores the original binary table data for those planes in memory. If theMaskedImageis copied, the precompressed pixel values are not transferred to the copy.- plane_map
A mapping from legacy mask plane name to the new plane name and description. If
None(default)get_legacy_visit_image_mask_planesis used.- instrument
Name of the instrument. Read from the primary header if not provided.
- visit
ID of the visit. Read from the primary header if not provided.
- component
A component to read instead of the full image.
- serialize(archive: OutputArchive[Any]) VisitImageSerializationModel#
Serialize the masked image to an output archive.
Parameters#
- archive
Archive to write to.
- to_legacy(*, copy: bool | None = None, plane_map: Mapping[str, MaskPlane] | None = None) Any#
Convert to an
lsst.afw.image.MaskedImageinstance.Parameters#
- copy
If
True, always copy the image and variance pixel data. IfFalse, return a view, and raiseTypeErrorif the pixel data is read-only (this is not supported by afw). IfNone, onyl if the pixel data is read-only. Mask pixel data is always copied.- plane_map
A mapping from legacy mask plane name to the new plane name and description.
- write_fits(filename: str, *, image_compression: ~lsst.images.fits._common.FitsCompressionOptions | None = FitsCompressionOptions(algorithm=<FitsCompressionAlgorithm.GZIP_2: 'GZIP_2'>, tile_shape=None, quantization=None), mask_compression: ~lsst.images.fits._common.FitsCompressionOptions | None = FitsCompressionOptions(algorithm=<FitsCompressionAlgorithm.GZIP_2: 'GZIP_2'>, tile_shape=None, quantization=None), variance_compression: ~lsst.images.fits._common.FitsCompressionOptions | None = FitsCompressionOptions(algorithm=<FitsCompressionAlgorithm.GZIP_2: 'GZIP_2'>, tile_shape=None, quantization=None), compression_seed: int | None = None) None#
Write the image to a FITS file.
Parameters#
- filename
Name of the file to write to. Must be a local file.
- image_compression
Compression options for the
imageplane.- mask_compression
Compression options for the
maskplane.- variance_compression
Compression options for the
varianceplane.- compression_seed
A FITS tile compression seed to use whenever the configured compression seed is
Noneor (for backwards compatibility)0. This value is then incremented every time it is used.