LSST Applications g034a557a3c+dd8dd8f11d,g0afe43252f+b86e4b8053,g11f7dcd041+017865fdd3,g1cd03abf6b+8446defddb,g1ce3e0751c+f991eae79d,g28da252d5a+ca8a1a9fb3,g2bbee38e9b+b6588ad223,g2bc492864f+b6588ad223,g2cdde0e794+8523d0dbb4,g347aa1857d+b6588ad223,g35bb328faa+b86e4b8053,g3a166c0a6a+b6588ad223,g461a3dce89+b86e4b8053,g52b1c1532d+b86e4b8053,g7f3b0d46df+ad13c1b82d,g80478fca09+f29c5d6c70,g858d7b2824+293f439f82,g8cd86fa7b1+af721d2595,g965a9036f2+293f439f82,g979bb04a14+51ed57f74c,g9ddcbc5298+f24b38b85a,gae0086650b+b86e4b8053,gbb886bcc26+b97e247655,gc28159a63d+b6588ad223,gc30aee3386+a2f0f6cab9,gcaf7e4fdec+293f439f82,gcd45df26be+293f439f82,gcdd4ae20e8+70b5def7e6,gce08ada175+da9c58a417,gcf0d15dbbd+70b5def7e6,gdaeeff99f8+006e14e809,gdbce86181e+6a170ce272,ge3d4d395c2+224150c836,ge5f7162a3a+bb2241c923,ge6cb8fbbf7+d119aed356,ge79ae78c31+b6588ad223,gf048a9a2f4+40ffced2b8,gf0baf85859+b4cca3d10f,w.2024.30
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: