From d2894a77490b570d318087ec2a8adddfc87c512c Mon Sep 17 00:00:00 2001
From: Danilo Ferreira de Lima <danilo.enoque.ferreira.de.lima@xfel.de>
Date: Wed, 8 Mar 2023 14:15:11 +0100
Subject: [PATCH] Fixed chi2 plot to include single pulse axis.

---
 pes_to_spec/test/offline_analysis.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pes_to_spec/test/offline_analysis.py b/pes_to_spec/test/offline_analysis.py
index 0b3f2fc..a257ab1 100755
--- a/pes_to_spec/test/offline_analysis.py
+++ b/pes_to_spec/test/offline_analysis.py
@@ -300,7 +300,7 @@ def main():
         # chi2 w.r.t XGM intensity
         erange = spec_raw_pe[0,-1] - spec_raw_pe[0,0]
         de = (spec_raw_pe[0,1] - spec_raw_pe[0,0])
-        chi2 = np.sum((spec_smooth - spec_pred["expected"])**2/(spec_pred["total_unc"]**2), axis=1)
+        chi2 = np.sum((spec_smooth[:, np.newaxis] - spec_pred["expected"])**2/(spec_pred["total_unc"]**2), axis=1)
         ndof = float(spec_smooth.shape[1]) - 1.0
         fig = plt.figure(figsize=(12, 8))
         gs = GridSpec(1, 1)
@@ -369,7 +369,7 @@ def main():
         plt.close(fig)
 
         # rmse
-        rmse = np.sqrt(np.mean((spec_smooth - spec_pred["expected"])**2, axis=1))
+        rmse = np.sqrt(np.mean((spec_smooth[:, np.newaxis] - spec_pred["expected"])**2, axis=1))
         fig = plt.figure(figsize=(12, 8))
         gs = GridSpec(1, 1)
         ax = fig.add_subplot(gs[0, 0])
-- 
GitLab