22__all__ = [
"imageReadFitsWithOptions",]
27from ._imageLib
import ImageOrigin
29_LOG = logging.getLogger(
"lsst.afw.image")
38 """Read an Image, Mask, MaskedImage or Exposure from a FITS file,
44 Fits file path from which to read image, mask, masked image
46 options : `lsst.daf.base.PropertySet` or `dict`
49 - llcX: bbox minimum x (int)
50 - llcY: bbox minimum y (int, must be present if llcX is present)
51 - width: bbox width (int, must be present if llcX is present)
52 - height: bbox height (int, must be present if llcX is present)
53 - imageOrigin: one of "LOCAL" or "PARENT" (has no effect unless
54 a bbox is specified by llcX, etc.)
56 Alternatively, a bounding box () can be passed on with the
57 ``"bbox"'' (`lsst.geom.Box2I`) key.
62 If options contains an unknown value for "imageOrigin"
63 lsst.pex.exceptions.NotFoundError
64 If options contains "llcX" and is missing any of
65 "llcY", "width", or "height".
67 origin = ImageOrigin.PARENT
70 bbox = options[
"bbox"]
71 elif "llcX" in options:
72 llcX = int(options[
"llcX"])
73 llcY = int(options[
"llcY"])
74 width = int(options[
"width"])
75 height = int(options[
"height"])
77 if "imageOrigin" in options:
78 originStr = str(options[
"imageOrigin"])
79 if (originStr ==
"LOCAL"):
80 origin = ImageOrigin.LOCAL
81 elif (originStr ==
"PARENT"):
82 origin = ImageOrigin.PARENT
84 raise RuntimeError(
"Unknown ImageOrigin type {}".format(originStr))
86 return cls(source, bbox=bbox, origin=origin)
90 """Write an Image or Mask to FITS, with options
95 Fits file path to which to write the image or mask.
96 options : `~collections.abc.Mapping`
97 Write options. The item ``item`` is accessed (which defaults to
98 "image"). It must contain a mapping with data for
99 `lsst.afw.fits.CompressionOptions.from_mapping`, or `None` for no
101 item : `str`, optional
102 Item to read from the ``options`` parameter.
104 if options
is not None:
105 writeOptions = CompressionOptions.from_mapping(options[item])
106 self.writeFits(dest, writeOptions)
112 """Write an Exposure or MaskedImage to FITS, with options
117 Fits file path to which to write the exposure or masked image.
118 options : `~collections.abc.Mapping`
119 Write options. The items "image", "mask" and "variance" are read.
120 Each must contain a mapping with data for
121 `lsst.afw.fits.CompressionOptions.from_mapping`, or `None` for no
124 if options
is not None:
125 writeOptionDict = {name +
"Options": CompressionOptions.from_mapping(plane_options)
126 for name
in (
"image",
"mask",
"variance")
127 if (plane_options := options[name])
is not None}
128 self.writeFits(dest, **writeOptionDict)
imageWriteFitsWithOptions(self, dest, options, item="image")
exposureWriteFitsWithOptions(self, dest, options)
imageReadFitsWithOptions(cls, source, options)