Fix error calculation for 0-count data points

Fix #47
This commit is contained in:
usov_i 2021-12-01 12:18:24 +01:00
parent b2129805dc
commit 3d5a4ed6aa
2 changed files with 3 additions and 4 deletions

View File

@ -170,7 +170,7 @@ def parse_1D(fileobj, data_type):
while len(counts) < s["n_points"]: while len(counts) < s["n_points"]:
counts.extend(map(float, next(fileobj).split())) counts.extend(map(float, next(fileobj).split()))
s["counts"] = np.array(counts) s["counts"] = np.array(counts)
s["counts_err"] = np.sqrt(s["counts"]) s["counts_err"] = np.sqrt(np.maximum(s["counts"], 1))
if s["h"].is_integer() and s["k"].is_integer() and s["l"].is_integer(): if s["h"].is_integer() and s["k"].is_integer() and s["l"].is_integer():
s["h"], s["k"], s["l"] = map(int, (s["h"], s["k"], s["l"])) s["h"], s["k"], s["l"] = map(int, (s["h"], s["k"], s["l"]))
@ -208,7 +208,7 @@ def parse_1D(fileobj, data_type):
for name in col_names: for name in col_names:
s[name] = np.array(s[name]) s[name] = np.array(s[name])
s["counts_err"] = np.sqrt(s["counts"]) s["counts_err"] = np.sqrt(np.maximum(s["counts"], 1))
s["scan_motors"] = [] s["scan_motors"] = []
for motor, step in zip(motors, steps): for motor, step in zip(motors, steps):

View File

@ -220,8 +220,7 @@ def fit_scan(scan, model_dict, fit_from=None, fit_to=None):
else: else:
model += _model model += _model
weights = [1 / y_err if y_err != 0 else 1 for y_err in y_err] scan["fit"] = model.fit(y_fit, x=x_fit, weights=1 / y_err)
scan["fit"] = model.fit(y_fit, x=x_fit, weights=weights)
def get_area(scan, area_method, lorentz): def get_area(scan, area_method, lorentz):