Loading [MathJax]/extensions/tex2jax.js
LSST Applications g0fba68d861+aff6b1d179,g1e78f5e6d3+b2e1eec3e3,g1fd858c14a+eb8d917efb,g35bb328faa+fcb1d3bbc8,g436fd98eb5+de86862952,g4af146b050+2f70285269,g4d2262a081+c17cfe15e3,g4e0f332c67+8616b824a5,g53246c7159+fcb1d3bbc8,g5a012ec0e7+d65fd7031a,g60b5630c4e+de86862952,g67b6fd64d1+c0248a1c13,g78460c75b0+2f9a1b4bcd,g786e29fd12+cf7ec2a62a,g7b71ed6315+fcb1d3bbc8,g87b7deb4dc+1a71b41694,g8852436030+40f6ec51d1,g89139ef638+c0248a1c13,g9125e01d80+fcb1d3bbc8,g94187f82dc+de86862952,g989de1cb63+c0248a1c13,g9f33ca652e+62adb22cd2,g9f7030ddb1+d892b2cb3e,ga2b97cdc51+de86862952,gabe3b4be73+1e0a283bba,gabf8522325+83c19109ce,gb1101e3267+1371da34ff,gb58c049af0+f03b321e39,gb89ab40317+c0248a1c13,gcf25f946ba+40f6ec51d1,gd6cbbdb0b4+d9e8db455e,gd9a9a58781+fcb1d3bbc8,gde0f65d7ad+fc726a16be,gded526ad44+763ef31e97,ge278dab8ac+4ce6343b44,ge410e46f29+c0248a1c13,gf67bdafdda+c0248a1c13,gfe06eef73a+95f9f0e40c,v29.0.0.rc3
LSST Data Management Base Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
lsst.afw.display._write_fits Namespace Reference

Functions

None _add_wcs (str wcs_name, PropertyList ps, int x0=0, int y0=0)
 
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)
 

Function Documentation

◆ _add_wcs()

None lsst.afw.display._write_fits._add_wcs ( str wcs_name,
PropertyList ps,
int x0 = 0,
int y0 = 0 )
protected

Definition at line 37 of file _write_fits.py.

37def _add_wcs(wcs_name: str, ps: PropertyList, x0: int = 0, y0: int = 0) -> None:
38 ps.setInt(f"CRVAL1{wcs_name}", x0, "(output) Column pixel of Reference Pixel")
39 ps.setInt(f"CRVAL2{wcs_name}", y0, "(output) Row pixel of Reference Pixel")
40 ps.setDouble(f"CRPIX1{wcs_name}", 1.0, "Column Pixel Coordinate of Reference")
41 ps.setDouble(f"CRPIX2{wcs_name}", 1.0, "Row Pixel Coordinate of Reference")
42 ps.setString(f"CTYPE1{wcs_name}", "LINEAR", "Type of projection")
43 ps.setString(f"CTYPE1{wcs_name}", "LINEAR", "Type of projection")
44 ps.setString(f"CUNIT1{wcs_name}", "PIXEL", "Column unit")
45 ps.setString(f"CUNIT2{wcs_name}", "PIXEL", "Row unit")
46
47

◆ writeFitsImage()

None lsst.afw.display._write_fits.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 )
Write a simple FITS file with no extensions.

Parameters
----------
file : `str` or `int`
    Path to a file or a file descriptor.
data : `lsst.afw.Image` or `lsst.afw.Mask`
    Data to be displayed.
wcs : `lsst.afw.geom.SkyWcs` or `None`, optional
    WCS to be written to header to FITS file.
title : `str`, optional
    If defined, the value to be stored in the ``OBJECT`` header.
    Overrides any value found in ``metadata``.
metadata : `lsst.daf.base.PropertySet` or `None`, optional
    Additional information to be written to FITS header.

Definition at line 48 of file _write_fits.py.

54) -> None:
55 """Write a simple FITS file with no extensions.
56
57 Parameters
58 ----------
59 file : `str` or `int`
60 Path to a file or a file descriptor.
61 data : `lsst.afw.Image` or `lsst.afw.Mask`
62 Data to be displayed.
63 wcs : `lsst.afw.geom.SkyWcs` or `None`, optional
64 WCS to be written to header to FITS file.
65 title : `str`, optional
66 If defined, the value to be stored in the ``OBJECT`` header.
67 Overrides any value found in ``metadata``.
68 metadata : `lsst.daf.base.PropertySet` or `None`, optional
69 Additional information to be written to FITS header.
70 """
71 ps = PropertyList()
72
73 # Seed with the external metadata, stripping wcs keywords.
74 if metadata:
76 ps.update(metadata)
77
78 # Write WcsB, so that pixel (0,0) is correctly labelled (but ignoring XY0)
79 _add_wcs("B", ps)
80
81 if not wcs:
82 _add_wcs("", ps) # Works around a ds9 bug that WCSA/B is ignored if no WCS is present.
83 else:
84 shift = Extent2D(-data.getX0(), -data.getY0())
85 new_wcs = wcs.copyAtShiftedPixelOrigin(shift)
86 wcs_metadata = new_wcs.getFitsMetadata()
87 ps.update(wcs_metadata)
88
89 if title:
90 ps.set("OBJECT", title, "Image being displayed")
91
92 if isinstance(file, str):
93 data.writeFits(file, metadata=ps)
94 else:
96 data.writeFits(manager=mem, metadata=ps)
97 if isinstance(file, int):
98 # Duplicate to prevent a double close, assuming the caller
99 # will close the file descriptor they passed in.
100 with os.fdopen(os.dup(file), "wb") as fh:
101 fh.write(mem.getData())
102 elif isinstance(file, subprocess.Popen):
103 file.communicate(input=mem.getData())
104 else:
105 # Try the write() method directly.
106 file.write(mem.getData())
Lifetime-management for memory that goes into FITS memory files.
Definition fits.h:125
void stripWcsMetadata(daf::base::PropertySet &metadata)
Definition wcsUtils.cc:215