LSST Applications g02d81e74bb+86cf3d8bc9,g180d380827+7a4e862ed4,g2079a07aa2+86d27d4dc4,g2305ad1205+e1ca1c66fa,g29320951ab+012e1474a1,g295015adf3+341ea1ce94,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+c429d67c83,g48712c4677+f88676dd22,g487adcacf7+27e1e21933,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+b41db86c35,g5a732f18d5+53520f316c,g64a986408d+86cf3d8bc9,g858d7b2824+86cf3d8bc9,g8a8a8dda67+585e252eca,g99cad8db69+84912a7fdc,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+a2b54eae19,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+6681f309db,gc120e1dc64+f0fcc2f6d8,gc28159a63d+0e5473021a,gcf0d15dbbd+c429d67c83,gdaeeff99f8+f9a426f77a,ge6526c86ff+0433e6603d,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+86cf3d8bc9,w.2024.17
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
lsst.meas.algorithms.brightStarStamps.BrightStarStamps Class Reference
Inheritance diagram for lsst.meas.algorithms.brightStarStamps.BrightStarStamps:
lsst.meas.algorithms.stamps.Stamps lsst.meas.algorithms.stamps.StampsBase

Public Member Functions

 __init__ (self, starStamps, innerRadius=None, outerRadius=None, nb90Rots=None, metadata=None, use_mask=True, use_variance=False, use_archive=False)
 
 initAndNormalize (cls, starStamps, innerRadius, outerRadius, nb90Rots=None, metadata=None, use_mask=True, use_variance=False, use_archive=False, imCenter=None, discardNanFluxObjects=True, forceFindFlux=False, statsControl=StatisticsControl(), statsFlag=stringToStatisticsProperty("MEAN"), badMaskPlanes=("BAD", "SAT", "NO_DATA"))
 
 readFits (cls, filename)
 
 readFitsWithOptions (cls, filename, options)
 
 append (self, item, innerRadius=None, outerRadius=None)
 
 extend (self, bss)
 
 getMagnitudes (self)
 
 getGaiaIds (self)
 
 getAnnularFluxes (self)
 
 getValidPixelsFraction (self)
 
 selectByMag (self, magMin=None, magMax=None)
 

Public Attributes

 normalized
 
 nb90Rots
 

Protected Member Functions

 _refresh_metadata (self)
 
 _checkRadius (self, innerRadius, outerRadius)
 
 _checkNormalization (self, normalize, innerRadius, outerRadius)
 

Protected Attributes

 _innerRadius
 
 _outerRadius
 

Detailed Description

Collection of bright star stamps and associated metadata.

Parameters
----------
starStamps : `collections.abc.Sequence` [`BrightStarStamp`]
    Sequence of star stamps. Cannot contain both normalized and
    unnormalized stamps.
innerRadius : `int`, optional
    Inner radius value, in pixels. This and ``outerRadius`` define the
    annulus used to compute the ``"annularFlux"`` values within each
    ``starStamp``. Must be provided if ``normalize`` is True.
outerRadius : `int`, optional
    Outer radius value, in pixels. This and ``innerRadius`` define the
    annulus used to compute the ``"annularFlux"`` values within each
    ``starStamp``. Must be provided if ``normalize`` is True.
nb90Rots : `int`, optional
    Number of 90 degree rotations required to compensate for detector
    orientation.
metadata : `~lsst.daf.base.PropertyList`, optional
    Metadata associated with the bright stars.
use_mask : `bool`
    If `True` read and write mask data. Default `True`.
use_variance : `bool`
    If ``True`` read and write variance data. Default ``False``.
use_archive : `bool`
    If ``True`` read and write an Archive that contains a Persistable
    associated with each stamp. In the case of bright stars, this is
    usually a ``TransformPoint2ToPoint2``, used to warp each stamp
    to the same pixel grid before stacking.

Raises
------
ValueError
    Raised if one of the star stamps provided does not contain the
    required keys.
AttributeError
    Raised if there is a mix-and-match of normalized and unnormalized
    stamps, stamps normalized with different annulus definitions, or if
    stamps are to be normalized but annular radii were not provided.

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 186 of file brightStarStamps.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.__init__ ( self,
starStamps,
innerRadius = None,
outerRadius = None,
nb90Rots = None,
metadata = None,
use_mask = True,
use_variance = False,
use_archive = False )

Reimplemented from lsst.meas.algorithms.stamps.StampsBase.

Definition at line 239 of file brightStarStamps.py.

249 ):
250 super().__init__(starStamps, metadata, use_mask, use_variance, use_archive)
251 # Ensure stamps contain a flux measure if expected to be normalized.
252 self._checkNormalization(False, innerRadius, outerRadius)
253 self._innerRadius, self._outerRadius = innerRadius, outerRadius
254 if innerRadius is not None and outerRadius is not None:
255 self.normalized = True
256 else:
257 self.normalized = False
258 self.nb90Rots = nb90Rots
259

Member Function Documentation

◆ _checkNormalization()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps._checkNormalization ( self,
normalize,
innerRadius,
outerRadius )
protected
Ensure there is no mixing of normalized and unnormalized stars, and
that, if requested, normalization can be performed.

Definition at line 641 of file brightStarStamps.py.

641 def _checkNormalization(self, normalize, innerRadius, outerRadius):
642 """Ensure there is no mixing of normalized and unnormalized stars, and
643 that, if requested, normalization can be performed.
644 """
645 noneFluxCount = self.getAnnularFluxes().count(None)
646 nStamps = len(self)
647 nFluxVals = nStamps - noneFluxCount
648 if noneFluxCount and noneFluxCount < nStamps:
649 # At least one stamp contains an annularFlux value (i.e. has been
650 # normalized), but not all of them do.
651 raise AttributeError(
652 f"Only {nFluxVals} stamps contain an annularFlux value.\nAll stamps in a BrightStarStamps "
653 "instance must either be normalized with the same annulus definition, or none of them can "
654 "contain an annularFlux value."
655 )
656 elif normalize:
657 # Stamps are to be normalized; ensure annular radii are specified
658 # and they have no annularFlux.
659 if innerRadius is None or outerRadius is None:
660 raise AttributeError(
661 "For stamps to be normalized (normalize=True), please provide a valid value (in pixels) "
662 "for both innerRadius and outerRadius."
663 )
664 elif noneFluxCount < nStamps:
665 raise AttributeError(
666 f"{nFluxVals} stamps already contain an annularFlux value. For stamps to be normalized, "
667 "all their annularFlux must be None."
668 )
669 elif innerRadius is not None and outerRadius is not None:
670 # Radii provided, but normalize=False; check that stamps already
671 # contain annularFluxes.
672 if noneFluxCount:
673 raise AttributeError(
674 f"{noneFluxCount} stamps contain no annularFlux, but annular radius values were provided "
675 "and normalize=False.\nTo normalize stamps, set normalize to True."
676 )
677 else:
678 # At least one radius value is missing; ensure no stamps have
679 # already been normalized.
680 if nFluxVals:
681 raise AttributeError(
682 f"{nFluxVals} stamps contain an annularFlux value. If stamps have been normalized, the "
683 "innerRadius and outerRadius values used must be provided."
684 )
685 return None

◆ _checkRadius()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps._checkRadius ( self,
innerRadius,
outerRadius )
protected
Ensure provided annulus radius is consistent with that already
present in the instance, or with arguments passed on at initialization.

Definition at line 630 of file brightStarStamps.py.

630 def _checkRadius(self, innerRadius, outerRadius):
631 """Ensure provided annulus radius is consistent with that already
632 present in the instance, or with arguments passed on at initialization.
633 """
634 if innerRadius != self._innerRadius or outerRadius != self._outerRadius:
635 raise AttributeError(
636 f"Trying to mix stamps normalized with annulus radii {innerRadius, outerRadius} with those "
637 "of BrightStarStamp instance\n"
638 f"(computed with annular radii {self._innerRadius, self._outerRadius})."
639 )
640

◆ _refresh_metadata()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps._refresh_metadata ( self)
protected
Refresh metadata. Should be called before writing the object out.

This method adds full lists of positions, Gaia magnitudes, IDs and
annular fluxes to the shared metadata.

Reimplemented from lsst.meas.algorithms.stamps.Stamps.

Definition at line 452 of file brightStarStamps.py.

452 def _refresh_metadata(self):
453 """Refresh metadata. Should be called before writing the object out.
454
455 This method adds full lists of positions, Gaia magnitudes, IDs and
456 annular fluxes to the shared metadata.
457 """
458 self._metadata["G_MAGS"] = self.getMagnitudes()
459 self._metadata["GAIA_IDS"] = self.getGaiaIds()
460 positions = self.getPositions()
461 self._metadata["X0S"] = [xy0[0] for xy0 in positions]
462 self._metadata["Y0S"] = [xy0[1] for xy0 in positions]
463 self._metadata["ANNULAR_FLUXES"] = self.getAnnularFluxes()
464 self._metadata["VALID_PIXELS_FRACTION"] = self.getValidPixelsFraction()
465 self._metadata["NORMALIZED"] = self.normalized
466 self._metadata["INNER_RADIUS"] = self._innerRadius
467 self._metadata["OUTER_RADIUS"] = self._outerRadius
468 if self.nb90Rots is not None:
469 self._metadata["NB_90_ROTS"] = self.nb90Rots
470 return None
471

◆ append()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.append ( self,
item,
innerRadius = None,
outerRadius = None )
Add an additional bright star stamp.

Parameters
----------
item : `BrightStarStamp`
    Bright star stamp to append.
innerRadius : `int`, optional
    Inner radius value, in pixels. This and ``outerRadius`` define the
    annulus used to compute the ``"annularFlux"`` values within each
    ``BrightStarStamp``.
outerRadius : `int`, optional
    Outer radius value, in pixels. This and ``innerRadius`` define the
    annulus used to compute the ``"annularFlux"`` values within each
    ``BrightStarStamp``.

Reimplemented from lsst.meas.algorithms.stamps.Stamps.

Definition at line 517 of file brightStarStamps.py.

517 def append(self, item, innerRadius=None, outerRadius=None):
518 """Add an additional bright star stamp.
519
520 Parameters
521 ----------
522 item : `BrightStarStamp`
523 Bright star stamp to append.
524 innerRadius : `int`, optional
525 Inner radius value, in pixels. This and ``outerRadius`` define the
526 annulus used to compute the ``"annularFlux"`` values within each
527 ``BrightStarStamp``.
528 outerRadius : `int`, optional
529 Outer radius value, in pixels. This and ``innerRadius`` define the
530 annulus used to compute the ``"annularFlux"`` values within each
531 ``BrightStarStamp``.
532 """
533 if not isinstance(item, BrightStarStamp):
534 raise ValueError(f"Can only add instances of BrightStarStamp, got {type(item)}.")
535 if (item.annularFlux is None) == self.normalized:
536 raise AttributeError(
537 "Trying to append an unnormalized stamp to a normalized BrightStarStamps "
538 "instance, or vice-versa."
539 )
540 else:
541 self._checkRadius(innerRadius, outerRadius)
542 self._stamps.append(item)
543 return None
544

◆ extend()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.extend ( self,
bss )
Extend BrightStarStamps instance by appending elements from another
instance.

Parameters
----------
bss : `BrightStarStamps`
    Other instance to concatenate.

Reimplemented from lsst.meas.algorithms.stamps.Stamps.

Definition at line 545 of file brightStarStamps.py.

545 def extend(self, bss):
546 """Extend BrightStarStamps instance by appending elements from another
547 instance.
548
549 Parameters
550 ----------
551 bss : `BrightStarStamps`
552 Other instance to concatenate.
553 """
554 if not isinstance(bss, BrightStarStamps):
555 raise ValueError(f"Can only extend with a BrightStarStamps object. Got {type(bss)}.")
556 self._checkRadius(bss._innerRadius, bss._outerRadius)
557 self._stamps += bss._stamps
558

◆ getAnnularFluxes()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.getAnnularFluxes ( self)
Retrieve normalization factor for each star.

These are computed by integrating the flux in annulus centered on the
bright star, far enough from center to be beyond most severe ghosts and
saturation.
The inner and outer radii that define the annulus can be recovered from
the metadata.

Returns
-------
annularFluxes : `list` [`float`]
    Annular fluxes which give the normalization factor for each star.

Definition at line 579 of file brightStarStamps.py.

579 def getAnnularFluxes(self):
580 """Retrieve normalization factor for each star.
581
582 These are computed by integrating the flux in annulus centered on the
583 bright star, far enough from center to be beyond most severe ghosts and
584 saturation.
585 The inner and outer radii that define the annulus can be recovered from
586 the metadata.
587
588 Returns
589 -------
590 annularFluxes : `list` [`float`]
591 Annular fluxes which give the normalization factor for each star.
592 """
593 return [stamp.annularFlux for stamp in self._stamps]
594

◆ getGaiaIds()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.getGaiaIds ( self)
Retrieve Gaia IDs for each star.

Returns
-------
gaiaIds : `list` [`int`]
    Gaia IDs for each star.

Definition at line 569 of file brightStarStamps.py.

569 def getGaiaIds(self):
570 """Retrieve Gaia IDs for each star.
571
572 Returns
573 -------
574 gaiaIds : `list` [`int`]
575 Gaia IDs for each star.
576 """
577 return [stamp.gaiaId for stamp in self._stamps]
578

◆ getMagnitudes()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.getMagnitudes ( self)
Retrieve Gaia G-band magnitudes for each star.

Returns
-------
gaiaGMags : `list` [`float`]
    Gaia G-band magnitudes for each star.

Definition at line 559 of file brightStarStamps.py.

559 def getMagnitudes(self):
560 """Retrieve Gaia G-band magnitudes for each star.
561
562 Returns
563 -------
564 gaiaGMags : `list` [`float`]
565 Gaia G-band magnitudes for each star.
566 """
567 return [stamp.gaiaGMag for stamp in self._stamps]
568

◆ getValidPixelsFraction()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.getValidPixelsFraction ( self)
Retrieve the fraction of valid pixels within the normalization
annulus for each star.

Returns
-------
validPixelsFractions : `list` [`float`]
    Fractions of valid pixels within the normalization annulus for each
    star.

Definition at line 595 of file brightStarStamps.py.

595 def getValidPixelsFraction(self):
596 """Retrieve the fraction of valid pixels within the normalization
597 annulus for each star.
598
599 Returns
600 -------
601 validPixelsFractions : `list` [`float`]
602 Fractions of valid pixels within the normalization annulus for each
603 star.
604 """
605 return [stamp.validAnnulusFraction for stamp in self._stamps]
606

◆ initAndNormalize()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.initAndNormalize ( cls,
starStamps,
innerRadius,
outerRadius,
nb90Rots = None,
metadata = None,
use_mask = True,
use_variance = False,
use_archive = False,
imCenter = None,
discardNanFluxObjects = True,
forceFindFlux = False,
statsControl = StatisticsControl(),
statsFlag = stringToStatisticsProperty("MEAN"),
badMaskPlanes = ("BAD", "SAT", "NO_DATA") )
Normalize a set of bright star stamps and initialize a
BrightStarStamps instance.

Since the center of bright stars are saturated and/or heavily affected
by ghosts, we measure their flux in an annulus with a large enough
inner radius to avoid the most severe ghosts and contain enough
non-saturated pixels.

Parameters
----------
starStamps : `collections.abc.Sequence` [`BrightStarStamp`]
    Sequence of star stamps. Cannot contain both normalized and
    unnormalized stamps.
innerRadius : `int`
    Inner radius value, in pixels. This and ``outerRadius`` define the
    annulus used to compute the ``"annularFlux"`` values within each
    ``starStamp``.
outerRadius : `int`
    Outer radius value, in pixels. This and ``innerRadius`` define the
    annulus used to compute the ``"annularFlux"`` values within each
    ``starStamp``.
nb90Rots : `int`, optional
    Number of 90 degree rotations required to compensate for detector
    orientation.
metadata : `~lsst.daf.base.PropertyList`, optional
    Metadata associated with the bright stars.
use_mask : `bool`
    If `True` read and write mask data. Default `True`.
use_variance : `bool`
    If ``True`` read and write variance data. Default ``False``.
use_archive : `bool`
    If ``True`` read and write an Archive that contains a Persistable
    associated with each stamp. In the case of bright stars, this is
    usually a ``TransformPoint2ToPoint2``, used to warp each stamp
    to the same pixel grid before stacking.
imCenter : `collections.abc.Sequence`, optional
    Center of the object, in pixels. If not provided, the center of the
    first stamp's pixel grid will be used.
discardNanFluxObjects : `bool`
    Whether objects with NaN annular flux should be discarded.
    If False, these objects will not be normalized.
forceFindFlux : `bool`
    Whether to try to find the flux of objects with NaN annular flux
    at a different annulus.
statsControl : `~lsst.afw.math.statistics.StatisticsControl`, optional
    StatisticsControl to be used when computing flux over all pixels
    within the annulus.
statsFlag : `~lsst.afw.math.statistics.Property`, optional
    statsFlag to be passed on to ``~lsst.afw.math.makeStatistics`` to
    compute annularFlux. Defaults to a simple MEAN.
badMaskPlanes : `collections.abc.Collection` [`str`]
    Collection of mask planes to ignore when computing annularFlux.

Raises
------
ValueError
    Raised if one of the star stamps provided does not contain the
    required keys.
AttributeError
    Raised if there is a mix-and-match of normalized and unnormalized
    stamps, stamps normalized with different annulus definitions, or if
    stamps are to be normalized but annular radii were not provided.

Definition at line 261 of file brightStarStamps.py.

277 ):
278 """Normalize a set of bright star stamps and initialize a
279 BrightStarStamps instance.
280
281 Since the center of bright stars are saturated and/or heavily affected
282 by ghosts, we measure their flux in an annulus with a large enough
283 inner radius to avoid the most severe ghosts and contain enough
284 non-saturated pixels.
285
286 Parameters
287 ----------
288 starStamps : `collections.abc.Sequence` [`BrightStarStamp`]
289 Sequence of star stamps. Cannot contain both normalized and
290 unnormalized stamps.
291 innerRadius : `int`
292 Inner radius value, in pixels. This and ``outerRadius`` define the
293 annulus used to compute the ``"annularFlux"`` values within each
294 ``starStamp``.
295 outerRadius : `int`
296 Outer radius value, in pixels. This and ``innerRadius`` define the
297 annulus used to compute the ``"annularFlux"`` values within each
298 ``starStamp``.
299 nb90Rots : `int`, optional
300 Number of 90 degree rotations required to compensate for detector
301 orientation.
302 metadata : `~lsst.daf.base.PropertyList`, optional
303 Metadata associated with the bright stars.
304 use_mask : `bool`
305 If `True` read and write mask data. Default `True`.
306 use_variance : `bool`
307 If ``True`` read and write variance data. Default ``False``.
308 use_archive : `bool`
309 If ``True`` read and write an Archive that contains a Persistable
310 associated with each stamp. In the case of bright stars, this is
311 usually a ``TransformPoint2ToPoint2``, used to warp each stamp
312 to the same pixel grid before stacking.
313 imCenter : `collections.abc.Sequence`, optional
314 Center of the object, in pixels. If not provided, the center of the
315 first stamp's pixel grid will be used.
316 discardNanFluxObjects : `bool`
317 Whether objects with NaN annular flux should be discarded.
318 If False, these objects will not be normalized.
319 forceFindFlux : `bool`
320 Whether to try to find the flux of objects with NaN annular flux
321 at a different annulus.
322 statsControl : `~lsst.afw.math.statistics.StatisticsControl`, optional
323 StatisticsControl to be used when computing flux over all pixels
324 within the annulus.
325 statsFlag : `~lsst.afw.math.statistics.Property`, optional
326 statsFlag to be passed on to ``~lsst.afw.math.makeStatistics`` to
327 compute annularFlux. Defaults to a simple MEAN.
328 badMaskPlanes : `collections.abc.Collection` [`str`]
329 Collection of mask planes to ignore when computing annularFlux.
330
331 Raises
332 ------
333 ValueError
334 Raised if one of the star stamps provided does not contain the
335 required keys.
336 AttributeError
337 Raised if there is a mix-and-match of normalized and unnormalized
338 stamps, stamps normalized with different annulus definitions, or if
339 stamps are to be normalized but annular radii were not provided.
340 """
341 stampSize = starStamps[0].stamp_im.getDimensions()
342 if imCenter is None:
343 imCenter = stampSize[0] // 2, stampSize[1] // 2
344
345 # Create SpanSet of annulus.
346 outerCircle = SpanSet.fromShape(outerRadius, Stencil.CIRCLE, offset=imCenter)
347 innerCircle = SpanSet.fromShape(innerRadius, Stencil.CIRCLE, offset=imCenter)
348 annulusWidth = outerRadius - innerRadius
349 if annulusWidth < 1:
350 raise ValueError("The annulus width must be greater than 1 pixel.")
351 annulus = outerCircle.intersectNot(innerCircle)
352
353 # Initialize (unnormalized) brightStarStamps instance.
354 bss = cls(
355 starStamps,
356 innerRadius=None,
357 outerRadius=None,
358 nb90Rots=nb90Rots,
359 metadata=metadata,
360 use_mask=use_mask,
361 use_variance=use_variance,
362 use_archive=use_archive,
363 )
364
365 # Ensure that no stamps have already been normalized.
366 bss._checkNormalization(True, innerRadius, outerRadius)
367 bss._innerRadius, bss._outerRadius = innerRadius, outerRadius
368
369 # Apply normalization.
370 rejects = []
371 badStamps = []
372 for stamp in bss._stamps:
373 try:
374 stamp.measureAndNormalize(
375 annulus, statsControl=statsControl, statsFlag=statsFlag, badMaskPlanes=badMaskPlanes
376 )
377 # Stars that are missing from input bright star stamps may
378 # still have a flux within the normalization annulus. The
379 # following two lines make sure that these stars are included
380 # in the subtraction process. Failing to assign the optimal
381 # radii values may result in an error in the `createAnnulus`
382 # method of the `SubtractBrightStarsTask` class. An alternative
383 # to handle this is to create two types of stamps that are
384 # missing from the input brightStarStamps object. One for those
385 # that have flux within the normalization annulus and another
386 # for those that do not have a flux within the normalization
387 # annulus.
388 stamp.optimalOuterRadius = outerRadius
389 stamp.optimalInnerRadius = innerRadius
390 except RuntimeError as err:
391 logger.error(err)
392 # Optionally keep NaN flux objects, for bookkeeping purposes,
393 # and to avoid having to re-find and redo the preprocessing
394 # steps needed before bright stars can be subtracted.
395 if discardNanFluxObjects:
396 rejects.append(stamp)
397 elif forceFindFlux:
398 newInnerRadius = innerRadius
399 newOuterRadius = outerRadius
400 while True:
401 newOuterRadius += annulusWidth
402 newInnerRadius += annulusWidth
403 if newOuterRadius > min(imCenter):
404 logger.info("No flux found for the star with Gaia ID of %s", stamp.gaiaId)
405 stamp.annularFlux = None
406 badStamps.append(stamp)
407 break
408 newOuterCircle = SpanSet.fromShape(newOuterRadius, Stencil.CIRCLE, offset=imCenter)
409 newInnerCircle = SpanSet.fromShape(newInnerRadius, Stencil.CIRCLE, offset=imCenter)
410 newAnnulus = newOuterCircle.intersectNot(newInnerCircle)
411 try:
412 stamp.measureAndNormalize(
413 newAnnulus,
414 statsControl=statsControl,
415 statsFlag=statsFlag,
416 badMaskPlanes=badMaskPlanes,
417 )
418
419 except RuntimeError:
420 stamp.annularFlux = np.nan
421 logger.error(
422 "The annular flux was not found for radii %d and %d",
423 newInnerRadius,
424 newOuterRadius,
425 )
426 if stamp.annularFlux and stamp.annularFlux > 0:
427 logger.info("The flux is found within an optimized annulus.")
428 logger.info(
429 "The optimized annulus radii are %d and %d and the flux is %f",
430 newInnerRadius,
431 newOuterRadius,
432 stamp.annularFlux,
433 )
434 stamp.optimalOuterRadius = newOuterRadius
435 stamp.optimalInnerRadius = newInnerRadius
436 break
437 else:
438 stamp.annularFlux = np.nan
439
440 # Remove rejected stamps.
441 bss.normalized = True
442 if discardNanFluxObjects:
443 for reject in rejects:
444 bss._stamps.remove(reject)
445 elif forceFindFlux:
446 for badStamp in badStamps:
447 bss._stamps.remove(badStamp)
448 bss._innerRadius, bss._outerRadius = None, None
449 return bss, badStamps
450 return bss
451
int min

◆ readFits()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.readFits ( cls,
filename )
Build an instance of this class from a file.

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

Reimplemented from lsst.meas.algorithms.stamps.Stamps.

Definition at line 473 of file brightStarStamps.py.

473 def readFits(cls, filename):
474 """Build an instance of this class from a file.
475
476 Parameters
477 ----------
478 filename : `str`
479 Name of the file to read.
480 """
481 return cls.readFitsWithOptions(filename, None)
482

◆ readFitsWithOptions()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.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 from lsst.meas.algorithms.stamps.Stamps.

Definition at line 484 of file brightStarStamps.py.

484 def readFitsWithOptions(cls, filename, options):
485 """Build an instance of this class with options.
486
487 Parameters
488 ----------
489 filename : `str`
490 Name of the file to read.
491 options : `PropertyList`
492 Collection of metadata parameters.
493 """
494 stamps, metadata = readFitsWithOptions(filename, BrightStarStamp.factory, options)
495 nb90Rots = metadata["NB_90_ROTS"] if "NB_90_ROTS" in metadata else None
496 if metadata["NORMALIZED"]:
497 return cls(
498 stamps,
499 innerRadius=metadata["INNER_RADIUS"],
500 outerRadius=metadata["OUTER_RADIUS"],
501 nb90Rots=nb90Rots,
502 metadata=metadata,
503 use_mask=metadata["HAS_MASK"],
504 use_variance=metadata["HAS_VARIANCE"],
505 use_archive=metadata["HAS_ARCHIVE"],
506 )
507 else:
508 return cls(
509 stamps,
510 nb90Rots=nb90Rots,
511 metadata=metadata,
512 use_mask=metadata["HAS_MASK"],
513 use_variance=metadata["HAS_VARIANCE"],
514 use_archive=metadata["HAS_ARCHIVE"],
515 )
516

◆ selectByMag()

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.selectByMag ( self,
magMin = None,
magMax = None )
Return the subset of bright star stamps for objects with specified
magnitude cuts (in Gaia G).

Parameters
----------
magMin : `float`, optional
    Keep only stars fainter than this value.
magMax : `float`, optional
    Keep only stars brighter than this value.

Definition at line 607 of file brightStarStamps.py.

607 def selectByMag(self, magMin=None, magMax=None):
608 """Return the subset of bright star stamps for objects with specified
609 magnitude cuts (in Gaia G).
610
611 Parameters
612 ----------
613 magMin : `float`, optional
614 Keep only stars fainter than this value.
615 magMax : `float`, optional
616 Keep only stars brighter than this value.
617 """
618 subset = [
619 stamp
620 for stamp in self._stamps
621 if (magMin is None or stamp.gaiaGMag > magMin) and (magMax is None or stamp.gaiaGMag < magMax)
622 ]
623 # This saves looping over init when guaranteed to be the correct type.
624 instance = BrightStarStamps(
625 (), innerRadius=self._innerRadius, outerRadius=self._outerRadius, metadata=self._metadata
626 )
627 instance._stamps = subset
628 return instance
629

Member Data Documentation

◆ _innerRadius

lsst.meas.algorithms.brightStarStamps.BrightStarStamps._innerRadius
protected

Definition at line 253 of file brightStarStamps.py.

◆ _outerRadius

lsst.meas.algorithms.brightStarStamps.BrightStarStamps._outerRadius
protected

Definition at line 253 of file brightStarStamps.py.

◆ nb90Rots

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.nb90Rots

Definition at line 258 of file brightStarStamps.py.

◆ normalized

lsst.meas.algorithms.brightStarStamps.BrightStarStamps.normalized

Definition at line 255 of file brightStarStamps.py.


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