LSSTApplications  18.1.0
LSSTDataManagementBasePackage
Functions
lsst.afw.image.image.fitsIoWithOptions Namespace Reference

Functions

def imageReadFitsWithOptions (cls, source, options)
 
def imageWriteFitsWithOptions (self, dest, options)
 
def exposureWriteFitsWithOptions (self, dest, options)
 

Function Documentation

◆ exposureWriteFitsWithOptions()

def lsst.afw.image.image.fitsIoWithOptions.exposureWriteFitsWithOptions (   self,
  dest,
  options 
)
Write an Exposure or MaskedImage to FITS, with options

Parameters
----------
dest : `str`
    Fits file path to which to write the exposure or masked image.
options : `lsst.daf.base.PropertySet`
    Write options. The items "image", "mask" and "variance" are read.
    Each must be an `lsst.daf.base.PropertySet` with data for
    ``lsst.afw.fits.ImageWriteOptions``.

Definition at line 107 of file fitsIoWithOptions.py.

107 def exposureWriteFitsWithOptions(self, dest, options):
108  """Write an Exposure or MaskedImage to FITS, with options
109 
110  Parameters
111  ----------
112  dest : `str`
113  Fits file path to which to write the exposure or masked image.
114  options : `lsst.daf.base.PropertySet`
115  Write options. The items "image", "mask" and "variance" are read.
116  Each must be an `lsst.daf.base.PropertySet` with data for
117  ``lsst.afw.fits.ImageWriteOptions``.
118  """
119  if options is not None:
120  try:
121  writeOptionDict = {name + "Options": ImageWriteOptions(options.getPropertySet(name))
122  for name in ("image", "mask", "variance")}
123  except Exception as e:
124  log = Log.getLogger("lsst.afw.image")
125  log.warn("Could not parse options; writing with defaults: {}".format(e))
126  else:
127  self.writeFits(dest, **writeOptionDict)
128  return
129  self.writeFits(dest)
130 
def exposureWriteFitsWithOptions(self, dest, options)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168

◆ imageReadFitsWithOptions()

def lsst.afw.image.image.fitsIoWithOptions.imageReadFitsWithOptions (   cls,
  source,
  options 
)
Read an Image, Mask, MaskedImage or Exposure from  a FITS file,
with options.

Parameters
----------
source : `str`
    Fits file path from which to read image, mask, masked image
    or exposure.
options : `lsst.daf.base.PropertySet`
    Read options:

    - llcX: bbox minimum x (int)
    - llcY: bbox minimum y (int, must be present if llcX is present)
    - width: bbox width (int, must be present if llcX is present)
    - height: bbox height (int, must be present if llcX is present)
    - imageOrigin: one of "LOCAL" or "PARENT" (has no effect unless
        a bbox is specified by llcX, etc.)

Raises
------
RuntimeError
    If options contains an unknown value for "imageOrigin"
lsst.pex.exceptions.NotFoundError
    If options contains "llcX" and is missing any of
    "llcY", "width", or "height".

Definition at line 36 of file fitsIoWithOptions.py.

36 def imageReadFitsWithOptions(cls, source, options):
37  """Read an Image, Mask, MaskedImage or Exposure from a FITS file,
38  with options.
39 
40  Parameters
41  ----------
42  source : `str`
43  Fits file path from which to read image, mask, masked image
44  or exposure.
45  options : `lsst.daf.base.PropertySet`
46  Read options:
47 
48  - llcX: bbox minimum x (int)
49  - llcY: bbox minimum y (int, must be present if llcX is present)
50  - width: bbox width (int, must be present if llcX is present)
51  - height: bbox height (int, must be present if llcX is present)
52  - imageOrigin: one of "LOCAL" or "PARENT" (has no effect unless
53  a bbox is specified by llcX, etc.)
54 
55  Raises
56  ------
57  RuntimeError
58  If options contains an unknown value for "imageOrigin"
59  lsst.pex.exceptions.NotFoundError
60  If options contains "llcX" and is missing any of
61  "llcY", "width", or "height".
62  """
63  bbox = lsst.geom.Box2I()
64  if options.exists("llcX"):
65  llcX = options.getInt("llcX")
66  llcY = options.getInt("llcY")
67  width = options.getInt("width")
68  height = options.getInt("height")
69  bbox = lsst.geom.Box2I(lsst.geom.Point2I(llcX, llcY), lsst.geom.Extent2I(width, height))
70  origin = image.PARENT
71  if options.exists("imageOrigin"):
72  originStr = options.getString("imageOrigin")
73  if (originStr == "LOCAL"):
74  origin = image.LOCAL
75  elif (originStr == "PARENT"):
76  origin = image.PARENT
77  else:
78  raise RuntimeError("Unknown ImageOrigin type {}".format(originStr))
79 
80  return cls(source, bbox=bbox, origin=origin)
81 
82 
def imageReadFitsWithOptions(cls, source, options)
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
An integer coordinate rectangle.
Definition: Box.h:54

◆ imageWriteFitsWithOptions()

def lsst.afw.image.image.fitsIoWithOptions.imageWriteFitsWithOptions (   self,
  dest,
  options 
)
Write an Image or Mask to FITS, with options

Parameters
----------
dest : `str`
    Fits file path to which to write the image or mask.
options : `lsst.daf.base.PropertySet
    Write options. The item "image" is read. It must contain an
    `lsst.daf.base.PropertySet` with data for
    ``lsst.afw.fits.ImageWriteOptions``.

Definition at line 83 of file fitsIoWithOptions.py.

83 def imageWriteFitsWithOptions(self, dest, options):
84  """Write an Image or Mask to FITS, with options
85 
86  Parameters
87  ----------
88  dest : `str`
89  Fits file path to which to write the image or mask.
90  options : `lsst.daf.base.PropertySet
91  Write options. The item "image" is read. It must contain an
92  `lsst.daf.base.PropertySet` with data for
93  ``lsst.afw.fits.ImageWriteOptions``.
94  """
95  if options is not None:
96  try:
97  writeOptions = ImageWriteOptions(options.getPropertySet("image"))
98  except Exception as e:
99  log = Log.getLogger("lsst.afw.image")
100  log.warn("Could not parse options; writing with defaults: {}".format(e))
101  else:
102  self.writeFits(dest, writeOptions)
103  return
104  self.writeFits(dest)
105 
106 
def format(config, name=None, writeSourceLine=True, prefix="", verbose=False)
Definition: history.py:168
def imageWriteFitsWithOptions(self, dest, options)