Skip to content

Commit

Permalink
Make interpolate work with MaskedArrays
Browse files Browse the repository at this point in the history
  • Loading branch information
gb119 committed Aug 10, 2016
1 parent 9004d8a commit 09397cd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Stoner/Analysis.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 09397cd

Please sign in to comment.