From 09397cd3c0c9caf87fc0486fd543cb6e7585ed0c Mon Sep 17 00:00:00 2001 From: Gavin Burnell Date: Wed, 10 Aug 2016 16:45:53 +0100 Subject: [PATCH] Make interpolate work with MaskedArrays --- Stoner/Analysis.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Stoner/Analysis.py b/Stoner/Analysis.py index 77a98d76a..d9497cd63 100644 --- a/Stoner/Analysis.py +++ b/Stoner/Analysis.py @@ -964,6 +964,8 @@ def extrapolate(self,new_x,xcol=None,ycol=None,yerr=None,overlap=20,kind='linear scalar_x=not isinstance(new_x,Iterable) if scalar_x: new_x=[new_x] + if isinstance(new_x,ma.MaskedArray): + new_x=new_x.compressed results=_np_.zeros((len(new_x),len(_.ycol))) for ix,x in enumerate(new_x): r=self.closest(x,xcol=_.xcol) @@ -1077,6 +1079,10 @@ def interpolate(self, newX, kind='linear', xcol=None,replace=False): xcol = self.setas._get_cols("xcol") elif isinstance(xcol, bool) and not xcol: xcol = None + + if isinstance(newX,ma.MaskedArray): + newX=newX.compressed() + if xcol is not None: # We need to convert newX to row indices xfunc = interp1d(self.column(xcol), index, kind, 0) # xfunc(x) returns partial index newX = xfunc(newX)