Skip to content

Asymmetric ghosting #2254

Open
Open

Description

@jakirkham

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.

Activity

  1. mrocklin commented on Apr 25, 2017

    @mrocklin
    Member

    +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)

  2. jakirkham commented on Jun 19, 2018

    @jakirkham
    MemberAuthor

    For awareness (and in case it is interesting), cc-ing @jni @stefanv.

  3. jni commented on Jun 20, 2018

    @jni
    Contributor

    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?

  4. shoyer commented on Jun 20, 2018

    @shoyer
    Member

    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)

  5. jakirkham commented on Jun 20, 2018

    @jakirkham
    MemberAuthor

    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?

  6. shoyer commented on Jun 20, 2018

    @shoyer
    Member

    Do you happen to know more about the use case(s) that needed the window of size 2 (i.e. real world applications)?

    It comes up for any even window size, since we need to pad each chunk by n-1 elements.

  7. shoyer commented on Jun 20, 2018

    @shoyer
    Member

    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).

  8. jakirkham commented on May 31, 2019

    @jakirkham
    MemberAuthor
  9. jakirkham commented on Jun 20, 2019

    @jakirkham
    MemberAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions