LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | Public Attributes | List of all members
lsst.meas.algorithms.stamps.StampsBase Class Reference
Inheritance diagram for lsst.meas.algorithms.stamps.StampsBase:
lsst.meas.algorithms.stamps.Stamps lsst.meas.algorithms.brightStarStamps.BrightStarStamps

Public Member Functions

def __init__ (self, stamps, metadata=None, use_mask=True, use_variance=True, use_archive=False)
 
def readFits (cls, filename)
 
def readFitsWithOptions (cls, filename, options)
 
def writeFits (self, filename)
 
def __len__ (self)
 
def __getitem__ (self, index)
 
def __iter__ (self)
 
def getMaskedImages (self)
 
def getArchiveElements (self)
 
def metadata (self)
 

Public Attributes

 use_mask
 
 use_variance
 
 use_archive
 

Detailed Description

Collection of  stamps and associated metadata.

Parameters
----------
stamps : iterable
    This should be an iterable of dataclass objects
    a la ``lsst.meas.algorithms.Stamp``.
metadata : `lsst.daf.base.PropertyList`, optional
    Metadata associated with the objects within the stamps.
use_mask : `bool`, optional
    If ``True`` read and write the mask data.  Default ``True``.
use_variance : `bool`, optional
    If ``True`` read and write the variance data. Default ``True``.
use_archive : `bool`, optional
    If ``True``, read and write an Archive that contains a Persistable
    associated with each stamp, for example a Transform or a WCS.
    Default ``False``.

Notes
-----
A butler can be used to read only a part of the stamps,
specified by a bbox:

>>> starSubregions = butler.get("brightStarStamps", dataId, parameters={'bbox': bbox})

Definition at line 271 of file stamps.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.meas.algorithms.stamps.StampsBase.__init__ (   self,
  stamps,
  metadata = None,
  use_mask = True,
  use_variance = True,
  use_archive = False 
)

Definition at line 298 of file stamps.py.

299  use_archive=False):
300  if not hasattr(stamps, '__iter__'):
301  raise ValueError('The stamps parameter must be iterable.')
302  for stamp in stamps:
303  if not isinstance(stamp, AbstractStamp):
304  raise ValueError('The entries in stamps must inherit from AbstractStamp. '
305  f'Got {type(stamp)}.')
306  self._stamps = stamps
307  self._metadata = PropertyList() if metadata is None else metadata.deepCopy()
308  self.use_mask = use_mask
309  self.use_variance = use_variance
310  self.use_archive = use_archive
311 

Member Function Documentation

◆ __getitem__()

def lsst.meas.algorithms.stamps.StampsBase.__getitem__ (   self,
  index 
)

Definition at line 379 of file stamps.py.

379  def __getitem__(self, index):
380  return self._stamps[index]
381 

◆ __iter__()

def lsst.meas.algorithms.stamps.StampsBase.__iter__ (   self)

Definition at line 382 of file stamps.py.

382  def __iter__(self):
383  return iter(self._stamps)
384 

◆ __len__()

def lsst.meas.algorithms.stamps.StampsBase.__len__ (   self)

Definition at line 376 of file stamps.py.

376  def __len__(self):
377  return len(self._stamps)
378 

◆ getArchiveElements()

def lsst.meas.algorithms.stamps.StampsBase.getArchiveElements (   self)
Retrieve archive elements associated with each stamp.

Returns
-------
archiveElements :
    `list` [`lsst.afwTable.io.Persistable`]

Definition at line 395 of file stamps.py.

395  def getArchiveElements(self):
396  """Retrieve archive elements associated with each stamp.
397 
398  Returns
399  -------
400  archiveElements :
401  `list` [`lsst.afwTable.io.Persistable`]
402  """
403  return [stamp.archive_element for stamp in self._stamps]
404 

◆ getMaskedImages()

def lsst.meas.algorithms.stamps.StampsBase.getMaskedImages (   self)
Retrieve star images.

Returns
-------
maskedImages :
    `list` [`lsst.afw.image.maskedImage.maskedImage.MaskedImageF`]

Definition at line 385 of file stamps.py.

385  def getMaskedImages(self):
386  """Retrieve star images.
387 
388  Returns
389  -------
390  maskedImages :
391  `list` [`lsst.afw.image.maskedImage.maskedImage.MaskedImageF`]
392  """
393  return [stamp.stamp_im for stamp in self._stamps]
394 

◆ metadata()

def lsst.meas.algorithms.stamps.StampsBase.metadata (   self)

Definition at line 406 of file stamps.py.

406  def metadata(self):
407  return self._metadata
408 
409 

◆ readFits()

def lsst.meas.algorithms.stamps.StampsBase.readFits (   cls,
  filename 
)
Build an instance of this class from a file.

Parameters
----------
filename : `str`
    Name of the file to read

Reimplemented in lsst.meas.algorithms.stamps.Stamps, and lsst.meas.algorithms.brightStarStamps.BrightStarStamps.

Definition at line 313 of file stamps.py.

313  def readFits(cls, filename):
314  """Build an instance of this class from a file.
315 
316  Parameters
317  ----------
318  filename : `str`
319  Name of the file to read
320  """
321 
322  return cls.readFitsWithOptions(filename, None)
323 

◆ readFitsWithOptions()

def lsst.meas.algorithms.stamps.StampsBase.readFitsWithOptions (   cls,
  filename,
  options 
)
Build an instance of this class with options.

Parameters
----------
filename : `str`
    Name of the file to read
options : `PropertyList`
    Collection of metadata parameters

Reimplemented in lsst.meas.algorithms.stamps.Stamps, and lsst.meas.algorithms.brightStarStamps.BrightStarStamps.

Definition at line 325 of file stamps.py.

325  def readFitsWithOptions(cls, filename, options):
326  """Build an instance of this class with options.
327 
328  Parameters
329  ----------
330  filename : `str`
331  Name of the file to read
332  options : `PropertyList`
333  Collection of metadata parameters
334  """
335  # To avoid problems since this is no longer an abstract method
336  if cls is not StampsBase:
337  raise NotImplementedError(
338  f"Please implement specific FITS reader for class {cls}"
339  )
340 
341  # Load metadata to get class
342  metadata = afwFits.readMetadata(filename, hdu=0)
343  type_name = metadata.get("STAMPCLS")
344  if type_name is None:
345  raise RuntimeError(
346  f"No class name in file {filename}. Unable to instantiate correct"
347  " stamps subclass. Is this an old version format Stamps file?"
348  )
349 
350  # Import class and override `cls`
351  stamp_type = doImport(type_name)
352  cls = stamp_type
353 
354  return cls.readFitsWithOptions(filename, options)
355 
def readFitsWithOptions(filename, stamp_factory, options)
Definition: stamps.py:101

◆ writeFits()

def lsst.meas.algorithms.stamps.StampsBase.writeFits (   self,
  filename 
)
Write this object to a file.

Parameters
----------
filename : `str`
    Name of file to write

Definition at line 363 of file stamps.py.

363  def writeFits(self, filename):
364  """Write this object to a file.
365 
366  Parameters
367  ----------
368  filename : `str`
369  Name of file to write
370  """
371  self._refresh_metadata()
372  type_name = get_full_type_name(self)
373  writeFits(filename, self._stamps, self._metadata, type_name, self.use_mask, self.use_variance,
374  self.use_archive)
375 
def writeFits(filename, stamps, metadata, type_name, write_mask, write_variance, write_archive=False)
Definition: stamps.py:42

Member Data Documentation

◆ use_archive

lsst.meas.algorithms.stamps.StampsBase.use_archive

Definition at line 310 of file stamps.py.

◆ use_mask

lsst.meas.algorithms.stamps.StampsBase.use_mask

Definition at line 308 of file stamps.py.

◆ use_variance

lsst.meas.algorithms.stamps.StampsBase.use_variance

Definition at line 309 of file stamps.py.


The documentation for this class was generated from the following file: