2222
2323__all__ = ("ParentDeblenderMetrics" , "SkippedDeblenderMetrics" , "BlendMetrics" , "IsolatedDeblenderMetrics" )
2424
25- from ..actions .scalar .scalarActions import CountAction , MeanAction , SumAction
25+ from ..actions .scalar .scalarActions import CountAction , DivideScalar , MeanAction , SumAction
26+ from ..actions .vector .mathActions import AddVector , SubtractVector
2627from ..actions .vector .selectors import (
2728 ChildObjectSelector ,
2829 FlagSelector ,
2930 ParentObjectSelector ,
3031 ThresholdSelector ,
3132)
33+ from ..actions .vector .vectorActions import LoadVector
3234from ..interfaces import AnalysisTool
3335
3436
@@ -41,22 +43,42 @@ def setDefaults(self):
4143 # Only select parents
4244 self .prep .selectors .parentSelector = ParentObjectSelector ()
4345
46+ # Subtract the number of children+isolated from the number of peaks
47+ # to get the number of peakDropouts. Ideally, this should be zero.
48+ self .process .buildActions .peakDropouts = SubtractVector ()
49+ self .process .buildActions .peakDropouts .actionA = LoadVector (vectorKey = "deblend_nPeaks" )
50+ self .process .buildActions .peakDropouts .actionB = AddVector (
51+ actionA = LoadVector (vectorKey = "deblend_nChild" ),
52+ actionB = LoadVector (vectorKey = "deblend_skipped_isolatedParent" ),
53+ )
54+
4455 # Statistics for parent blends
4556 self .process .calculateActions .numParents = CountAction (vectorKey = "parentObjectId" )
4657 self .process .calculateActions .numDeblendFailed = SumAction (vectorKey = "deblend_failed" )
4758 self .process .calculateActions .numIncompleteData = SumAction (vectorKey = "deblend_incompleteData" )
4859
4960 # Total number of detected peaks
5061 self .process .calculateActions .numDetectedPeaks = SumAction (vectorKey = "deblend_nPeaks" )
62+
5163 # Total number of deblended children
5264 self .process .calculateActions .numDeblendedChildren = SumAction (vectorKey = "deblend_nChild" )
5365
66+ # Total number of peak dropouts
67+ self .process .calculateActions .numPeakDropouts = SumAction (vectorKey = "peakDropouts" )
68+
69+ # Total number of peak dropouts as proportion of total number of peaks
70+ self .process .calculateActions .propPeakDropouts = DivideScalar ()
71+ self .process .calculateActions .propPeakDropouts .actionA = SumAction (vectorKey = "peakDropouts" )
72+ self .process .calculateActions .propPeakDropouts .actionB = SumAction (vectorKey = "deblend_nPeaks" )
73+
5474 self .produce .metric .units = {
5575 "numParents" : "" ,
5676 "numDeblendFailed" : "" ,
5777 "numIncompleteData" : "" ,
5878 "numDetectedPeaks" : "" ,
5979 "numDeblendedChildren" : "" ,
80+ "numPeakDropouts" : "" ,
81+ "propPeakDropouts" : "" ,
6082 }
6183
6284
0 commit comments