-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WIP: Feature/interpolate #1640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Feature/interpolate #1640
Changes from 2 commits
1582c1f
ab727e7
95006c4
4a4f6eb
42d63ef
263ec98
19d21b8
f937c07
8717e38
3d5c1b1
1864e8f
f58d464
1b93808
6f83b7b
33df6af
eafe67a
dd9fa8c
88d1569
3fb9261
37882b7
a04e83e
48505a5
20f957d
282bb65
a6fcb7f
2b0d9e1
d3220f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1214,6 +1214,54 @@ def fillna(self, value): | |
out = ops.fillna(self, value) | ||
return out | ||
|
||
def interpolate_na(self, dim=None, method='linear', inplace=False, | ||
limit=None, **kwargs): | ||
"""Interpolate values according to different methods. | ||
|
||
Parameters | ||
---------- | ||
dim : str | ||
Specifies the dimension along which to interpolate. | ||
method : {'linear', 'time', 'index', 'values', 'nearest'} | ||
'linear': ignore the index and treat the values as equally | ||
spaced. default | ||
'time': interpolation works on daily and higher resolution data to | ||
interpolate given length of interval | ||
'index', 'values': use the actual numerical values of the index | ||
'nearest', 'zero', 'slinear', 'quadratic', 'cubic', 'barycentric', | ||
'polynomial' is passed to scipy.interpolate.interp1d with the | ||
order given both 'polynomial' and 'spline' require that you also | ||
specify and order (int) e.g. da.interpolate_na(method='polynomial', | ||
order=4) | ||
limit : limit : int, default None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Maximum number of consecutive NaNs to fill. Must be greater than 0. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add "or None for no limit" |
||
|
||
Returns | ||
------- | ||
DataArray | ||
""" | ||
from .missing import interp_na | ||
return interp_na(self, dim=dim, method=method, inplace=inplace, | ||
**kwargs) | ||
|
||
def interpolate_at(self, dim, locs, method='linear', inplace=False, | ||
limit=None, **kwargs): | ||
# this is just here so I remember the signature we discussed | ||
# dim: the dimension along which to interpolate | ||
# locs: a broadcastable boolean mask describing where interpolation | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. boolean mask? I'm not quite sure how that would make sense. My immediate thought would be that |
||
# should happen | ||
raise NotImplementedError() | ||
|
||
def ffill(self, dim, limit=None): | ||
'''TODO''' | ||
from .missing import ffill | ||
return ffill(self, dim, limit=limit) | ||
|
||
def bfill(self, dim, limit=None): | ||
'''TODO''' | ||
from .missing import bfill | ||
return bfill(self, dim, limit=limit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need bottleneck installed to use |
||
|
||
def combine_first(self, other): | ||
"""Combine two DataArray objects, with union of coordinates. | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a minor point, but can we format this a little more consistently?
The
compat
arg on the Dataset constructor gets formatted nicely into a list by Sphinx and is still pretty readable as plain text:xarray/xarray/core/dataset.py
Lines 342 to 350 in 0818a36