def plotRF():
    """plot the RF amplitude"""
    xrng = np.linspace(centerxRange[0], centerxRange[1], 10)
    yrng = np.linspace(centeryRange[0], centeryRange[1], 10)
    print xrng
    print yrng
    [X, Y] = np.meshgrid(xrng, yrng, indexing='ij')
    z = 10 * u
    xlist = np.ravel(X)
    ylist = np.ravel(Y)
    V = np.empty(xlist.shape)

    FTrapWorld.set_omega_rf(30E6)

    for i in range(len(xlist)):
        print i
        r = (xlist[i], ylist[i], z)
        print r
        V[i] = FTrapWorld.compute_pseudopot(r)

    V = V.reshape(X.shape)

    from mpl_toolkits.mplot3d import Axes3D
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.plot_surface(X, Y, V)
    plt.show()
def plotRF():
    """plot the RF amplitude"""
    xrng = np.linspace(centerxRange[0], centerxRange[1], 10)
    yrng = np.linspace(centeryRange[0], centeryRange[1], 10)
    print xrng
    print yrng
    [X, Y] = np.meshgrid(xrng, yrng, indexing='ij')
    z = 10*u
    xlist = np.ravel(X)
    ylist = np.ravel(Y)
    V = np.empty(xlist.shape)

    FTrapWorld.set_omega_rf(30E6)

    for i in range(len(xlist)):
        print i
        r = (xlist[i], ylist[i], z)
        print r
        V[i] = FTrapWorld.compute_pseudopot(r)
		
    
    V = V.reshape(X.shape)

    from mpl_toolkits.mplot3d import Axes3D
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.plot_surface(X, Y, V)
    plt.show()
def getMinimumPseudopot(N):
    """ return approximate minimum of the trap pseudopotential
	     in the dumbest way possible
		 sample N^3 points in a cube about the geometric trap center.
		 the saddle point is chosen as that with the minimum magnitude of
		 gradient"""

    x0 = 0.5 * (centerxRange[0] + centerxRange[1])
    y0 = 0.5 * (centeryRange[0] + centeryRange[1])
	
    z0 = 200*u
	
    
    width = 2*z0
    gv = np.linspace(-width/2, width/2, N)
    xrng = gv.copy() + x0
    yrng = gv.copy() + y0
    zrng = gv.copy() + z0
    
   
    V = np.empty([N, N, N])    
    
    for i in range(N):
        for j in range(N):
            for k in range(N):
                #print i, j, k
                r = (xrng[i], yrng[j], zrng[k])
                V[i,j,k] = FTrapWorld.compute_pseudopot(r)

    dV = np.abs(np.gradient(V))
    dVmin = np.amin(dV)
    mn = np.where(dV == dVmin)	
    imin = mn[0][0]
    jmin = mn[1][0]
    kmin = mn[2][0]
    rmin = (xrng[imin], yrng[jmin], zrng[kmin])
				
    return rmin
def getMinimumPseudopot(N):
    """ return approximate minimum of the trap pseudopotential
	     in the dumbest way possible
		 sample N^3 points in a cube about the geometric trap center.
		 the saddle point is chosen as that with the minimum magnitude of
		 gradient"""

    x0 = 0.5 * (centerxRange[0] + centerxRange[1])
    y0 = 0.5 * (centeryRange[0] + centeryRange[1])

    z0 = 200 * u

    width = 2 * z0
    gv = np.linspace(-width / 2, width / 2, N)
    xrng = gv.copy() + x0
    yrng = gv.copy() + y0
    zrng = gv.copy() + z0

    V = np.empty([N, N, N])

    for i in range(N):
        for j in range(N):
            for k in range(N):
                #print i, j, k
                r = (xrng[i], yrng[j], zrng[k])
                V[i, j, k] = FTrapWorld.compute_pseudopot(r)

    dV = np.abs(np.gradient(V))
    dVmin = np.amin(dV)
    mn = np.where(dV == dVmin)
    imin = mn[0][0]
    jmin = mn[1][0]
    kmin = mn[2][0]
    rmin = (xrng[imin], yrng[jmin], zrng[kmin])

    return rmin