From 6f027877e245f95f163644c19d2e50faed5ecae1 Mon Sep 17 00:00:00 2001 From: Michael Krayer Date: Thu, 5 Aug 2021 21:01:42 +0200 Subject: [PATCH] fix if no subfield is returned --- particle.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/particle.py b/particle.py index ce562b3..3a527e8 100644 --- a/particle.py +++ b/particle.py @@ -154,6 +154,8 @@ class Particles: idxlo = np.array(fld.nearest_gridpoint(pos-rp,lower=True)) sfdim = np.ceil(2*rp/fld.spacing+2).astype('int') sf = fld.extract_subfield(idxlo,sfdim,deep=False,strict_bounds=False) + if sf is None: + continue xsf = sf.x().reshape((-1,1,1)) ysf = sf.y().reshape((1,-1,1)) zsf = sf.z().reshape((1,1,-1))