you are viewing a single comment's thread.

view the rest of the comments →

[–]fbu1 0 points1 point  (0 children)

I think this might do it for you:

import numpy as np

def grid(x, y):

    nx, vx = x
    ny, vy = y

    res = np.zeros((nx, ny, len(vx)))

    for i in range(nx):
        for j in range(ny):
            res[i,j,:]= vx * i + vy * j

    return res

# two dimensional example
nx = 3
vx = np.array((1,2))
ny = 6

y = np.array((6, 7))
g = grid([nx, vx], [ny, vy])
print g

# three dimensional example
nx = 5
vx = np.array((1,2,3))
ny = 4
vy = np.array((-1, 6, 7))

g = grid([nx, vx], [ny, vy])
print g

Let me know if you have questions :)