From 05e006a0a289509fd607448c9966c8f93a5ce6ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Le=20Guyader?= <loic.le.guyader@xfel.eu>
Date: Thu, 7 Nov 2019 15:42:26 +0100
Subject: [PATCH] Fix XAS for data with NaN

---
 XAS.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/XAS.py b/XAS.py
index 8d1b298..54b3c25 100644
--- a/XAS.py
+++ b/XAS.py
@@ -32,9 +32,17 @@ def absorption(T, Io):
                 counts: length of T
     """
 
+    T = np.array(T)
+    Io = np.array(Io)
+
     counts = len(T)
     assert counts == len(Io), "T and Io must have the same length"
 
+    # remove not number from the data
+    good = np.logical_and(np.isfinite(T), np.isfinite(Io))
+    T = T[good]
+    Io = Io[good]
+    
     # return type of the structured array
     fdtype = [('muA', 'f8'), ('sigmaA', 'f8'), ('weights', 'f8'),
         ('muT', 'f8'), ('sigmaT', 'f8'), ('muIo', 'f8'), ('sigmaIo', 'f8'),
-- 
GitLab