Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

ENH: Initial implementation of a 'neighbor' calculation #303

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
Contributor

timcera commented Jun 9, 2012

Each element is assigned the result of a function based on it's neighbors.
Neighbors are selected based on a weight array.

It uses the new pad routines to pad arrays if neighboring values are required that would be off the edge of the input array.

Will be great to have the masked array settled because right now you can only sort of exclude from the neighborhood using a zero in the weight array. Zero or np.IGNORE don't affect np.sum, but functions like np.mean and np.std would give different answers. Because of this my early implementations of neighbor included an optional mask array along with the weight array, but I decided would be best to wait for the new masked arrays.

This in some ways could be considered a generalization of a convolution, and comparison with existing numpy/scipy convolution results are included in the tests. The advantage to neighbor is that any function that accepts a 1-d array, and returns a single result, can be used instead of convolution only using summation. The convolution functions require the weight array to be flipped to get the same answer as neighbor.

@timcera timcera ENH: Initial implementation of a 'neighbor' calculation where the each
element is assigned the result of a function based on it's neighbors.
Neighbors are selected based on a weight array.
452e583
Owner

teoliphant commented Oct 10, 2012

I'm not sure what to make of no comments on this PR. This seems like a useful addition. @timcera are you still interested in having this PR merged?

Contributor

ewmoore commented Oct 10, 2012

This seems to be trying to solve a very similar problem to #31

Contributor

timcera commented Oct 16, 2012

Closing. scipy.ndimage.generic_filter has identical functionality.

@timcera timcera closed this Oct 16, 2012

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