22from __future__
import annotations
24__all__ = [
"writeFitsImage"]
37_LOG = logging.getLogger(__name__)
40def _add_wcs(wcs_name: str, ps: PropertyList, x0: int = 0, y0: int = 0) ->
None:
41 ps.setInt(f
"CRVAL1{wcs_name}", x0,
"(output) Column pixel of Reference Pixel")
42 ps.setInt(f
"CRVAL2{wcs_name}", y0,
"(output) Row pixel of Reference Pixel")
43 ps.setDouble(f
"CRPIX1{wcs_name}", 1.0,
"Column Pixel Coordinate of Reference")
44 ps.setDouble(f
"CRPIX2{wcs_name}", 1.0,
"Row Pixel Coordinate of Reference")
45 ps.setString(f
"CTYPE1{wcs_name}",
"LINEAR",
"Type of projection")
46 ps.setString(f
"CTYPE1{wcs_name}",
"LINEAR",
"Type of projection")
47 ps.setString(f
"CUNIT1{wcs_name}",
"PIXEL",
"Column unit")
48 ps.setString(f
"CUNIT2{wcs_name}",
"PIXEL",
"Row unit")
52 file: str | int | io.BytesIO,
56 metadata: PropertySet |
None =
None,
58 """Write a simple FITS file with no extensions.
63 Path to a file or a file descriptor.
64 data : `lsst.afw.Image` or `lsst.afw.Mask`
66 wcs : `lsst.afw.geom.SkyWcs` or `None`, optional
67 WCS to be written to header to FITS file.
68 title : `str`, optional
69 If defined, the value to be stored in the ``OBJECT`` header.
70 Overrides any value found in ``metadata``.
71 metadata : `lsst.daf.base.PropertySet` or `None`, optional
72 Additional information to be written to FITS header.
88 ps.update(wcs.getFitsMetadata(bbox=data.getBBox()))
90 _LOG.warning(
"WCS is not FITS-compatible and has no FITS approximation; displaying without WCS.")
93 ps.set(
"OBJECT", title,
"Image being displayed")
95 if isinstance(file, str):
96 data.writeFits(file, metadata=ps)
99 data.writeFits(manager=mem, metadata=ps)
100 if isinstance(file, int):
103 with os.fdopen(os.dup(file),
"wb")
as fh:
104 fh.write(mem.getData())
105 elif isinstance(file, subprocess.Popen):
106 file.communicate(input=mem.getData())
109 file.write(mem.getData())
Lifetime-management for memory that goes into FITS memory files.
A 2-dimensional celestial WCS that transform pixels to ICRS RA/Dec, using the LSST standard for pixel...
A class to represent a 2-dimensional array of pixels.
Represent a 2-dimensional array of bitmask pixels.
None writeFitsImage(str|int|io.BytesIO file, lsst.afw.image.Image|lsst.afw.image.Mask data, lsst.afw.geom.SkyWcs|None wcs=None, str title="", PropertySet|None metadata=None)
None _add_wcs(str wcs_name, PropertyList ps, int x0=0, int y0=0)
void stripWcsMetadata(daf::base::PropertySet &metadata)