Incremental Arrays

We often have situations where we would like to have an array that increases over a given range. There are a number of ways to create such an array in python. The simplest is just with a for loop, but numpy also has built in routines for this since it is such a common procedure. If one wanted an array that goes from 0 to 10 in steps of 0.5 one could do any of the following:
b,a=10,0
h=0.5
N= np.floor(b-a/h)
x=[]
for i in range(N):
x.append(a+i*h)
x2=np.arrange(a,b,h)
x3=np.linspace(a,b,num=N)

These are all 1D arrays, but we may want a grid over 2 or even 3 dimensions. Again this can be done with just for statements or using numpy routines, particularly meshgrid which will build you a higher dimension incremental array from 1D arrays.
bx,ax = 10,0
by,ay = 20,0
Nx,Ny = 10,20
x=np.linspace(ax,bx,num=Nx)
y=np.linspace(ay,by,num=Ny)
x2d=np.zeros((Nx,Ny)) #it is usually easier to keep x, y, etc. arrays separate
y2d=np.zeros((Nx,Ny))
for i in range(Nx):
for j in range(Ny):
x2d[i][j]=x[j]
y2d[i][j]=y[i]
#or
xgrid,ygrid=np.meshgrid(x,y)