[Numpy-discussion] Offset 2D arrays
Mike Romberg
romberg at fsl.noaa.gov
Mon Sep 17 16:21:01 EDT 2001
I am attempting to create 2D arrays which are offset copies of a
given starting array. For example if I have a 2D array like this:
array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
I would like to offset it by some amount in either or both the x and
y dimension. Lets say that both the x and y offset would be 1. Then
I would like to have an array like this:
array([[5, 6, 0],
[8, 9, 0],
[0, 0, 0]])
Here I don't really care about the values which are now zero. The
main point is that now I can compare the data values at any given
(x,y) point with the values at the adjacent point (over one on each
axis). This would be useful for the kinds of calculations we need to
do. I just can't come up with a numeric way to do this. Does anyone
have any ideas?
Thanks alot,
Mike Romberg (romberg at fsl.noaa.gov)
More information about the NumPy-Discussion
mailing list