LSST Applications 24.1.5,g02d81e74bb+fa3a7a026e,g180d380827+a53a32eff8,g2079a07aa2+86d27d4dc4,g2305ad1205+c0501b3732,g295015adf3+7d3e92f0ec,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g33d1c0ed96+0e5473021a,g3a166c0a6a+0e5473021a,g3ddfee87b4+5dd1654d75,g48712c4677+3bf1020dcb,g487adcacf7+065c13d9cf,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+d7ac436cfb,g5a732f18d5+53520f316c,g64a986408d+fa3a7a026e,g858d7b2824+fa3a7a026e,g8a8a8dda67+585e252eca,g99cad8db69+a5a909b84f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+4cf350ccb2,gb0e22166c9+60f28cb32d,gba4ed39666+c2a2e4ac27,gbb8dafda3b+f991a0b59f,gc120e1dc64+9ccbfdb8be,gc28159a63d+0e5473021a,gcf0d15dbbd+5dd1654d75,gd96a1ce819+42fd0ee607,gdaeeff99f8+f9a426f77a,ge6526c86ff+0d71447b4b,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gff1a9f87cc+fa3a7a026e
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.pipe.tasks.extended_psf.StackBrightStarsTask Class Reference
Inheritance diagram for lsst.pipe.tasks.extended_psf.StackBrightStarsTask:

Public Member Functions

 removeInvalidStamps (self, read_stars)
 
 run (self, bss_ref_list, stars_dict, region_name=None)
 

Static Public Attributes

 ConfigClass = StackBrightStarsConfig
 

Protected Member Functions

 _set_up_stacking (self, example_stamp)
 

Static Protected Attributes

str _DefaultName = "stack_bright_stars"
 

Detailed Description

Stack bright stars together to build an extended PSF model.

Definition at line 364 of file extended_psf.py.

Member Function Documentation

◆ _set_up_stacking()

lsst.pipe.tasks.extended_psf.StackBrightStarsTask._set_up_stacking ( self,
example_stamp )
protected
Configure stacking statistic and control from config fields.

Definition at line 370 of file extended_psf.py.

370 def _set_up_stacking(self, example_stamp):
371 """Configure stacking statistic and control from config fields."""
372 stats_control = StatisticsControl(
373 numSigmaClip=self.config.num_sigma_clip,
374 numIter=self.config.num_iter,
375 )
376 if bad_masks := self.config.bad_mask_planes:
377 and_mask = example_stamp.mask.getPlaneBitMask(bad_masks[0])
378 for bm in bad_masks[1:]:
379 and_mask = and_mask | example_stamp.mask.getPlaneBitMask(bm)
380 stats_control.setAndMask(and_mask)
381 stats_flags = stringToStatisticsProperty(self.config.stacking_statistic)
382 return stats_control, stats_flags
383

◆ removeInvalidStamps()

lsst.pipe.tasks.extended_psf.StackBrightStarsTask.removeInvalidStamps ( self,
read_stars )
Remove stamps that do not have enough valid pixels in the annulus.

Parameters
----------
read_stars : `list` of `lsst.pipe.tasks.processBrightStars.BrightStarStamp`
    List of bright star stamps to be stacked.

Definition at line 384 of file extended_psf.py.

384 def removeInvalidStamps(self, read_stars):
385 """Remove stamps that do not have enough valid pixels in the annulus.
386
387 Parameters
388 ----------
389 read_stars : `list` of `lsst.pipe.tasks.processBrightStars.BrightStarStamp`
390 List of bright star stamps to be stacked.
391 """
392 # Find stamps that do not have enough valid pixels in the annulus
393 invalidStamps = []
394 for stamp in read_stars:
395 if stamp.validAnnulusFraction < self.config.minValidAnnulusFraction:
396 invalidStamps.append(stamp)
397 # Remove stamps that do not have enough valid pixels in the annulus
398 if len(invalidStamps):
399 for invalidStamp in invalidStamps:
400 read_stars._stamps.remove(invalidStamp)
401

◆ run()

lsst.pipe.tasks.extended_psf.StackBrightStarsTask.run ( self,
bss_ref_list,
stars_dict,
region_name = None )
Read input bright star stamps and stack them together.

The stacking is done iteratively over smaller areas of the final model
image to allow for a great number of bright star stamps to be used.

Parameters
----------
bss_ref_list : `list` of
        `lsst.daf.butler._deferredDatasetHandle.DeferredDatasetHandle`
    List of available bright star stamps data references.
stars_dict: `dict`
    Dictionary to store the number of stars used to generate the PSF.
region_name : `str`, optional
    Name of the focal plane region, if applicable. Only used for
    logging purposes, when running over multiple such regions
    (typically from `MeasureExtendedPsfTask`)

Definition at line 402 of file extended_psf.py.

402 def run(self, bss_ref_list, stars_dict, region_name=None):
403 """Read input bright star stamps and stack them together.
404
405 The stacking is done iteratively over smaller areas of the final model
406 image to allow for a great number of bright star stamps to be used.
407
408 Parameters
409 ----------
410 bss_ref_list : `list` of
411 `lsst.daf.butler._deferredDatasetHandle.DeferredDatasetHandle`
412 List of available bright star stamps data references.
413 stars_dict: `dict`
414 Dictionary to store the number of stars used to generate the PSF.
415 region_name : `str`, optional
416 Name of the focal plane region, if applicable. Only used for
417 logging purposes, when running over multiple such regions
418 (typically from `MeasureExtendedPsfTask`)
419 """
420 if region_name:
421 region_message = f" for region '{region_name}'."
422 else:
423 region_message = "."
424 if region_name is not None:
425 stars_dict_key = region_name
426 else:
427 stars_dict_key = "all"
428 self.log.info(
429 "Building extended PSF from stamps extracted from %d detector images%s",
430 len(bss_ref_list),
431 region_message,
432 )
433 # read in example set of full stamps
434 example_bss = bss_ref_list[0].get()
435 example_stamp = example_bss[0].stamp_im
436 # create model image
437 ext_psf = MaskedImageF(example_stamp.getBBox())
438 # divide model image into smaller subregions
439 subregion_size = Extent2I(*self.config.subregion_size)
440 sub_bboxes = subBBoxIter(ext_psf.getBBox(), subregion_size)
441 # compute approximate number of subregions
442 n_subregions = ((ext_psf.getDimensions()[0]) // (subregion_size[0] + 1)) * (
443 (ext_psf.getDimensions()[1]) // (subregion_size[1] + 1)
444 )
445 self.log.info(
446 "Stacking performed iteratively over approximately %d smaller areas of the final model image.",
447 n_subregions,
448 )
449 # set up stacking statistic
450 stats_control, stats_flags = self._set_up_stacking(example_stamp)
451 # perform stacking
452 for jbbox, bbox in enumerate(sub_bboxes):
453 all_stars = None
454 for bss_ref in bss_ref_list:
455 read_stars = bss_ref.get(parameters={"bbox": bbox})
456 self.removeInvalidStamps(read_stars)
457 if jbbox == 0:
458 # Store the number of stars used to generate the PSF model
459 # in the metadata dictionary.
460 stars_dict[stars_dict_key] += len(read_stars)
461 if self.config.do_mag_cut:
462 read_stars = read_stars.selectByMag(magMax=self.config.mag_limit)
463 if all_stars:
464 all_stars.extend(read_stars)
465 else:
466 all_stars = read_stars
467 # TODO: DM-27371 add weights to bright stars for stacking
468 coadd_sub_bbox = statisticsStack(all_stars.getMaskedImages(), stats_flags, stats_control)
469 ext_psf.assign(coadd_sub_bbox, bbox)
470 return ext_psf
471
472

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.extended_psf.StackBrightStarsTask._DefaultName = "stack_bright_stars"
staticprotected

Definition at line 368 of file extended_psf.py.

◆ ConfigClass

lsst.pipe.tasks.extended_psf.StackBrightStarsTask.ConfigClass = StackBrightStarsConfig
static

Definition at line 367 of file extended_psf.py.


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