LSST Applications g0dd1f4853b+10f999ec6a,g1635faa6d4+87195dc7a7,g1653933729+a8ce1bb630,g28da252d5a+52e63b167c,g2bbee38e9b+de1ea1445d,g2bc492864f+de1ea1445d,g2cdde0e794+c2c89b37c4,g3156d2b45e+41e33cbcdc,g347aa1857d+de1ea1445d,g35bb328faa+a8ce1bb630,g3a166c0a6a+de1ea1445d,g3e281a1b8c+9f2c4e2fc3,g414038480c+077ccc18e7,g41af890bb2+91913bf47e,g531c6476d5+76a064336f,g5fbc88fb19+17cd334064,g781aacb6e4+a8ce1bb630,g7ab3e175f3+c50d54ced3,g80478fca09+fa8a736ab7,g82479be7b0+8047a7f847,g858d7b2824+76a064336f,g9125e01d80+a8ce1bb630,ga5288a1d22+c4b4c41fa2,gae0086650b+a8ce1bb630,gb58c049af0+d64f4d3760,gb9c6c11c1e+e06cc5572d,gc28159a63d+de1ea1445d,gcf0d15dbbd+b5ff149290,gd3624f51fd+4798c71331,gda3e153d99+76a064336f,gda6a2b7d83+b5ff149290,gdaeeff99f8+1711a396fd,ge2409df99d+1433a6c73d,ge33fd446bb+76a064336f,ge79ae78c31+de1ea1445d,gee3d5c6094+118f03e3d0,gf0baf85859+147a0692ba,gf3967379c6+02b11634a5,w.2024.45
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: