Skip to content

Commit

Permalink
avoid negative error bars
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesBuchner committed May 26, 2024
1 parent b1e857b commit 8ad6b05
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bxa/xspec/sinning.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,14 @@ def binning(outputfiles_basename, bins, widths, data, models, nmin=20):
best_gof = -numpy.log10(gofpi + 1e-300)
# 1e3 and 1e6 correspond roughly to 3 sigma and 5 sigma
c = 'green' if best_gof < 2 else 'orange' if best_gof < 6. else 'red'
f = 1. / (xhii-xloi) #* deltax
f = 1. / (xhii - xloi)
y = ydatai * f
modelrange_low = scipy.special.gammaincinv(ydatai + 1, 0.1) * f
modelrange_high = scipy.special.gammaincinv(ydatai + 1, 0.9) * f
marked_binned.append(
dict(x=(xloi+xhii)/2., xerr=(-xloi+xhii)/2.,
marked_binned.append(dict(
x=(xloi + xhii)/2., xerr=(xhii - xloi) / 2.,
y = y,
yerr = [[modelrange_high - y], [y - modelrange_low]],
yerr = [[max(0, modelrange_high - y)], [max(0, y - modelrange_low)]],
color=c)
)
ymin = min(ymin, modelrange_low)
Expand Down

0 comments on commit 8ad6b05

Please sign in to comment.