From 1ce6ce9d9d11b834b9a8469a3965367da8d2732a Mon Sep 17 00:00:00 2001 From: Matteo Bachetti Date: Thu, 14 Sep 2023 10:33:46 +0200 Subject: [PATCH] Fix error bars --- hendrics/lcurve.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/hendrics/lcurve.py b/hendrics/lcurve.py index 9ffb958f..dfa1875f 100644 --- a/hendrics/lcurve.py +++ b/hendrics/lcurve.py @@ -425,20 +425,27 @@ def lcurve_from_events( time_ranges = [0, n_times * bintime] time_edges = np.linspace(time_ranges[0], time_ranges[1], n_times + 1) - counts = histogram( + raw_counts = histogram( ev_times, range=time_ranges, bins=n_times, - weights=weights, ) - times = (time_edges[1:] + time_edges[:-1]) / 2 + tstart - - counts_err = None if weights is not None: + weighted = histogram( + ev_times, + range=time_ranges, + bins=n_times, + weights=weights, + ) + counts = weighted + counts_err = raw_counts * np.std(weights) err_dist = "gauss" - counts_err = counts * np.std(weights) else: + counts = raw_counts err_dist = "poisson" + counts_err = None + + times = (time_edges[1:] + time_edges[:-1]) / 2 + tstart lc = Lightcurve( times,