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
It would be very helpful if operations like ghost, trim, and map_overlap would support asymmetric ghosting (a.k.a. haloing).
To provide context, many filters have the option to specify the origin of the footprint (where the result will be placed) be somewhere other than its center. In these instances, one needs a larger halo on edges where the origin of the footprint is closest too. However one can get away with a much smaller halo on edges where the origin of the footprint is further from.
As it stands currently, halos must be symmetric meaning that one ends up having a larger halo in all directions if the origin of the footprint deviates from the center. When in reality the size of the block plus halo should be invariant to the origin of the footprint. This results in some unneeded computational inefficiency in these cases. Given common cases take the origin to an extreme (all the way to one end of the footprint), these inefficiencies are not insignificant.
To fix cases like these, I would propose that we allow a list to be specified for each dimension in addition to the already standard int. We could treat the int as a special form of the list case where both values in the list are the same. One could specify a list only on dimensions in need of this asymmetry. This list syntax can easily be used in conjuction with the tuple or dict syntax as well for improved versatility. This would allow for more appropriate halos to be specified in these cases where the footprint origin is not in the center.
+1 on the idea generally. This is also somewhat similar to what is currently done in dask/dataframe/rolling.py::map_overlap (although in a strictly one dimensional way)
tbh I like this idea for "completeness", but I have yet to see a convincing use-case for setting the origin away from the center. @jakirkham, do you have any of these?
A use case for this came up in xarray when we (likely @fujiisoup) implemented rolling window operations with dask. If you want to do a rolling mean with a window of size 2 along a chunked dimensions, you only need to pad by one element on either the left or right side of each chunk.
(I see now that this is the same scenario @mrocklin mentions for dask.dataframe)
Not personally, @jni. Was wondering if after we talked about it last, you may have encountered someone who did actually need this. :)
Interesting, thanks for sharing, @shoyer. Do you happen to know more about the use case(s) that needed the window of size 2 (i.e. real world applications)? Did it turn out to be better than a window of size 3 for some reason?
A realistic use for applying a function over a size 2 rolling window in particular would be for approximating a first derivative with finite differences. This could come up pretty quickly if anyone tried to do a distributed simulation of partial differential equations (e.g., hooking up dask to bohrium) or analyze simulation results (e.g., with xgcm).
Partially addressed in PR ( #4863 ). This handles the case where no boundary condition is applied. Could also be joined with da.pad to cover boundary conditions as well.
Activity
mrocklin commentedon Apr 25, 2017
+1 on the idea generally. This is also somewhat similar to what is currently done in
dask/dataframe/rolling.py::map_overlap(although in a strictly one dimensional way)jakirkham commentedon Jun 19, 2018
For awareness (and in case it is interesting), cc-ing @jni @stefanv.
jni commentedon Jun 20, 2018
tbh I like this idea for "completeness", but I have yet to see a convincing use-case for setting the origin away from the center. @jakirkham, do you have any of these?
shoyer commentedon Jun 20, 2018
A use case for this came up in xarray when we (likely @fujiisoup) implemented rolling window operations with dask. If you want to do a rolling mean with a window of size 2 along a chunked dimensions, you only need to pad by one element on either the left or right side of each chunk.
(I see now that this is the same scenario @mrocklin mentions for dask.dataframe)
jakirkham commentedon Jun 20, 2018
Not personally, @jni. Was wondering if after we talked about it last, you may have encountered someone who did actually need this. :)
Interesting, thanks for sharing, @shoyer. Do you happen to know more about the use case(s) that needed the window of size 2 (i.e. real world applications)? Did it turn out to be better than a window of size 3 for some reason?
shoyer commentedon Jun 20, 2018
It comes up for any even window size, since we need to pad each chunk by n-1 elements.
shoyer commentedon Jun 20, 2018
A realistic use for applying a function over a size 2 rolling window in particular would be for approximating a first derivative with finite differences. This could come up pretty quickly if anyone tried to do a distributed simulation of partial differential equations (e.g., hooking up dask to bohrium) or analyze simulation results (e.g., with xgcm).
jakirkham commentedon May 31, 2019
cc @mpeaton
jakirkham commentedon Jun 20, 2019
Partially addressed in PR ( #4863 ). This handles the case where no boundary condition is applied. Could also be joined with
da.padto cover boundary conditions as well.