I have a numpy array that represents a 3d grid over a volume of space, with each cell representing a non-cubic voxel (the scaling is arbitrary in all three dimensions). The array is O(500) voxels per dimension.
I would like to fill that array with the distance from a given XYZ point to the center of each voxel.
I can fill the array by using python for-loops, but that's slower than I would like. Is there a way to do so quickly using numpy/scipy?
The conversion to XYZ coordinates is done with two tuples, one giving the XYZ coordinates of the center of the 0,0,0 voxel, and the other giving the size of the voxels in XYZ units.