Commit 1e9ccd46 authored by Reed Essick's avatar Reed Essick

some more error handling

Original: 432cefb1bd74ccca09a51f441f8e5af1fb46c914
parent 3c1adc1c
......@@ -145,7 +145,7 @@ def check_calibration( segs, times, timeseries, FAPthrs):
max_statedFAP = 0.0
for (t, ts) in zip(times, timeseries):
(_segs, _min_ts) = idq.timeseries_to_segments(t, -ts, -FAPthr) # we want FAP <= FAPthr <--> -FAP >= -FAPthr
SEGS += _segs
SEGS += (_segs) ### ensure this is a list in case the behavior of timeseries_to_segments changes...
if _min_ts != None:
statedFAP = -_min_ts
if max_statedFAP < statedFAP:
......
......@@ -2417,7 +2417,7 @@ def timeseries_to_segments(t, ts, thr):
edges = numpy.array(edges)
segs = numpy.transpose( numpy.array([t[edges[:-1:2]], t[edges[1::2]]]) )
return segs, numpy.min(ts[truth])
return [list(seg) for seg in segs], numpy.min(ts[truth])
else:
return [], None
......
......@@ -275,11 +275,14 @@ def __point_wise_optimal_s(eval, scale, pdf):
if s > 0:
return scale * s**-0.5
elif s == 0:
elif s==0:
return scale*1e3 ### just return something big
elif s != s: ### catch NAN returned by interp object, which shouldn't happen but apparently does...
return scale ### again, just return something big reasonable (which is what "scale" is supposed to mean)
else:
raise ValueError( 'ERROR: pilot_interp pdf is not positive definite. Optimal bandwidth is not defined. This could be caused by a spline interpolation...' )
raise ValueError( 'ERROR: pilot_interp pdf is not positive definite. Optimal bandwidth is not defined. This could be caused by a spline interpolation...\npdf(%.6f) = %.6e'%(eval, s) )
#-------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment