Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if plot_single_point and (self.incident_energy_shift_keV ==
self.incident_energy_shift_keV_updated):
# fit_real_time = False
fit_real_time = True # For now let's always do fitting on the fly
if fit_real_time:
# Interpolate references (same function as in the main processing routine)
refs = _interpolate_references(self.energy, self.ref_energy, self.ref_data)
xanes_fit_pt, xanes_fit_rfactor, _ = fit_spectrum(data_selected,
refs,
method=self.fitting_method,
rate=self.fitting_descent_rate)
else:
# Use precomputed data
xanes_fit_pt = self.xanes_map_data[:, yd_px_min, xd_px_min]
# We still compute R-factor
xanes_fit_rfactor = rfactor_compute(data_selected, xanes_fit_pt, self.absorption_refs)
# Compute fit results represented in counts (for output)
xanes_fit_pt_counts = xanes_fit_pt.copy()
for n, v in enumerate(xanes_fit_pt):
xanes_fit_pt_counts[n] = v * np.sum(self.absorption_refs[:, n])
for n, v in enumerate(xanes_fit_pt_counts):
plot_comments += f"\n{self.ref_labels[n]}: {xanes_fit_pt_counts[n]:.2f} c."
plot_comments += f"\nR-factor: {xanes_fit_rfactor:.5g}"
# Labels should always be supplied when calling the function.
# This is not user controlled option, therefore exception should be raised.
assert self.labels, "No labels are provided. Fitting results can not be displayed properly"
refs_scaled = self.absorption_refs.copy()
_, n_refs = refs_scaled.shape