INDICES Purpose
This procedure creates coordinate arrays for each dimension in an
input array. The coordinate arrays have the same shape as the
input, and the i'th pixel in those arrays denote that dimension's
coordinate value at the i'th location in the input
Inputs
array: An array to generate indices for
Keyword Parameters
center: Optionally, set to an array with ndim elements, where ndim
is the dimensionality of array. The output indices will be centered
around the coordinates of center.
Outputs
x: The coordinate array for dimension 1
y: The coordinate array for dimension 2
z: The coordinate array for dimension 3
a: The coordinate array for dimension 4
b: The coordinate array for dimension 5
c: The coordinate array for dimension 6
d: The coordinate array for dimension 7
e: The coordinate array for dimension 8
Examples
array = findgen(3,3)
indices, array, x, y
print, x
0 1 2
0 1 2
0 1 2
print, y
0 0 0
1 1 1
2 2 2
Modification History
April 2010: Written by Chris Beaumont
July 29 2010: Now handles 1D arrays correctly. cnb.
Mar 15 2011: Added parameter checking and center keyword. cnb.
June 21 2011: Fixed bug when center=0. cnb.
June 23 2011: Optimized for speed and memory (10x speedup). cnb.