@@ -94,6 +94,12 @@ class SimpleJumpCorrect(Operator):
9494 help = "Minimum number of good samples in an interval" ,
9595 )
9696
97+ njump_limit = Int (
98+ 10 ,
99+ help = "If the detector has more than `njump_limit` jumps the detector "
100+ "the detector and time stream will be flagged as invalid." ,
101+ )
102+
97103 @traitlets .validate ("det_mask" )
98104 def _check_det_mask (self , proposal ):
99105 check = proposal ["value" ]
@@ -115,6 +121,13 @@ def _check_det_flag_mask(self, proposal):
115121 raise traitlets .TraitError ("Det flag mask should be a positive integer" )
116122 return check
117123
124+ @traitlets .validate ("njump_limit" )
125+ def _check_det_flag_mask (self , proposal ):
126+ check = proposal ["value" ]
127+ if check <= 0 :
128+ raise traitlets .TraitError ("njump limit should be a positive integer" )
129+ return check
130+
118131 def __init__ (self , ** kwargs ):
119132 super ().__init__ (** kwargs )
120133 self .net_factors = []
@@ -165,7 +178,8 @@ def _find_peaks(self, toi, flag, flag_out, lim=3.0, tol=1e4, sigma_in=None):
165178 npeak = np .ma .sum (np .abs (mytoi ) > sigma * lim )
166179
167180 # Only one jump per iteration
168- while npeak > 0 :
181+ # And skip remaining if find more than `njump_limit` jumps
182+ while (npeak > 0 ) and (len (peaks ) <= self .njump_limit ) :
169183 imax = np .argmax (np .abs (mytoi ))
170184 amplitude = mytoi [imax ]
171185 significance = np .abs (amplitude ) / sigma
@@ -271,8 +285,10 @@ def _exec(self, data, detectors=None, **kwargs):
271285 njump = len (peaks )
272286 if njump == 0 :
273287 continue
274- if njump > 10 :
275- raise RuntimeError (f"Found { njump } jumps!" )
288+ if njump > self .njump_limit :
289+ ob ._detflags [name ] |= self .det_mask
290+ det_flags [ind ] |= self .det_flag_mask
291+ continue
276292
277293 corrected_signal , flag_out = self ._remove_jumps (
278294 sig_view , bad_view , peaks , self .jump_radius
0 commit comments