From 6ffdd2611d53f5a6811e445d5b07182af163ea23 Mon Sep 17 00:00:00 2001 From: Chris Leaman Date: Mon, 4 Mar 2019 15:41:19 +1100 Subject: [PATCH] Allow crossing to return empty list if all values are masked --- src/utils.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils.py b/src/utils.py index f5b8067..772de7b 100644 --- a/src/utils.py +++ b/src/utils.py @@ -23,6 +23,10 @@ def crossings(profile_x, profile_z, constant_z): profile_z = np.array(profile_z)[valid] profile_x = np.array(profile_x)[valid] + # Return empty list if mask removes all values + if profile_x.size == 0: + return [] + # Normalize the 'signal' to zero. # Use np.subtract rather than a list comprehension for performance reasons z = np.subtract(profile_z, constant_z)