You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Others might also appreciate a general local stencil operation, which could specialize to roll. cc @rabernat . This would presumably actually be powered by ghost, which, while useful is possibly to low-level for many users.
Could you elaborate on what kind of operations you have in mind? Initially I was thinking of roll as just being a combination of slicing and concatenating, which seems to be sufficient to recreate its behavior. What other behavior would these other stencil operations need?
Roll is sometimes used to do finite difference computations like x[1:] - x[:-1]. These can get more involved. If central differencing is [1, 0, -1] then perhaps roll(1) is [0, 1].
Although I might be prematurely generalizing. You could probably implement a decent and efficient roll operation just by using the slicing syntax and da.concatenate
The function that actually does the difference is a method on xarray.Variable objects:
def_roll_one_dim(self, dim, count):
axis=self.get_axis_num(dim)
count%=self.shape[axis]
ifcount!=0:
indices= [slice(-count, None), slice(None, -count)]
else:
indices= [slice(None)]
arrays= [self[(slice(None),) *axis+ (idx,)].dataforidxinindices]
data=ops.concatenate(arrays, axis)
ifisinstance(data, dask_array_type):
# chunked data should come out with the same chunks; this makes# it feasible to combine shifted and unshifted data# TODO: remove this once dask.array automatically aligns chunksdata=data.rechunk(self.data.chunks)
returntype(self)(self.dims, data, self._attrs, fastpath=True)
This does exactly what @jakirkham suggests: slicing and concatenating.
I like the idea of a ghost-backed roll operation in dask, because it would avoid the potentially expensive communication step that occurs when the shifted points (which may lie on different chunks) are added together (as in a finite difference).
Thanks for the feedback @rabernat. Always good to hear one's idea is not wildly off from what others have thought.
Certainly would be interested in other filtering operations as well. If you guys open (or have opened) other issues on convolutions, median/rank filters, etc., please feel free to cc me. Using ghosting (or in other literature haloing) should work very nicely with all of these. Would expect we can get a lot of mileage out of a simple convolve function in Dask.
Activity
mrocklin commentedon Mar 29, 2017
Others might also appreciate a general local stencil operation, which could specialize to roll. cc @rabernat . This would presumably actually be powered by ghost, which, while useful is possibly to low-level for many users.
I'm curious what APIs could be for this.
jakirkham commentedon Mar 29, 2017
Could you elaborate on what kind of operations you have in mind? Initially I was thinking of
rollas just being a combination of slicing and concatenating, which seems to be sufficient to recreate its behavior. What other behavior would these other stencil operations need?mrocklin commentedon Mar 29, 2017
Roll is sometimes used to do finite difference computations like
x[1:] - x[:-1]. These can get more involved. If central differencing is[1, 0, -1]then perhaps roll(1) is[0, 1].Although I might be prematurely generalizing. You could probably implement a decent and efficient roll operation just by using the slicing syntax and
da.concatenaterabernat commentedon Mar 29, 2017
It's probably useful to see how
rollis implemented in xarray, which has special logic for dask:https://github.com/pydata/xarray/blob/master/xarray/core/variable.py#L633
The function that actually does the difference is a method on
xarray.Variableobjects:This does exactly what @jakirkham suggests: slicing and concatenating.
I like the idea of a ghost-backed
rolloperation in dask, because it would avoid the potentially expensive communication step that occurs when the shifted points (which may lie on different chunks) are added together (as in a finite difference).mrocklin commentedon Mar 29, 2017
Yeah, I apologize. Roll and stencil computations are probably best thought about separately.
@jakirkham I think that slicing + concatenation is the way to go. If you have any interest here then I encourage you to submit a PR.
jakirkham commentedon Mar 29, 2017
Thanks for the feedback @rabernat. Always good to hear one's idea is not wildly off from what others have thought.
Certainly would be interested in other filtering operations as well. If you guys open (or have opened) other issues on convolutions, median/rank filters, etc., please feel free to cc me. Using ghosting (or in other literature haloing) should work very nicely with all of these. Would expect we can get a lot of mileage out of a simple convolve function in Dask.
jakirkham commentedon Mar 29, 2017
Where do you think this
rollfunction should live (module-wise), @mrocklin?mrocklin commentedon Mar 29, 2017
Somewhere in dask.array, probably dask.array.core
jakirkham commentedon Mar 29, 2017
Please see PR ( #2135 ) for a proposal to add the
rollfunction.