From bafa97ec69c2555a4c128ac4b3f2f8fb5189c8e6 Mon Sep 17 00:00:00 2001 From: "Omry Volk (NR PhD) October 2017" Date: Tue, 25 Feb 2020 12:19:44 +0000 Subject: [PATCH] fix bug when more than 2 traces are present --- msnoise/api.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/msnoise/api.py b/msnoise/api.py index 64b397db..c8152f2e 100644 --- a/msnoise/api.py +++ b/msnoise/api.py @@ -1745,17 +1745,14 @@ def make_same_length(st): # get the mask of all traces, i.e. the parts where at least one trace has # a gap - # TODO add cases with more than 2 or 3 traces (could append?) - # TODO is there a better way to AND masks ? - mask = [] + if len(st) < 2: return st - elif len(st) == 2: - mask = np.logical_or(st[0].data.mask, st[1].data.mask) - elif len(st) == 3: - mask = np.logical_or(st[0].data.mask, st[1].data.mask, st[2].data.mask) - if not len(mask): - return st.split() + + masks=[] + for tr in st: + masks.append(tr.data.mask) + mask = np.any(masks,axis=0) # apply the mask to all traces for tr in st: