In the example below, it is as if Python does not discriminate between angle[u][v]
and radius[u][v]
.
That is, from the first command in the for loop, an element of the angle
array is evaluated. Then, from the second command in the for loop, the corresponding element of the radius
array is evaluated. My problem is that this value for radius[v][u]
gets then overwritten onto angle[v][u]
.
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from matplotlib.colors import LogNorm
import matplotlib.pyplot as plt
import numpy as np
from pylab import *
import matplotlib as mpl
import math
X = np.arange(0, 656, 1)
Y = np.arange(0, 667, 1)
X, Y = np.meshgrid(X, Y)
X = X - 243 + 0.0
Y = Y - 363 + 0.0
angle = X
radius = X
height = X.shape[0]
width = X.shape[1]
print width
print height
for v in xrange(height):
for u in xrange(width):
angle[v][u] = math.atan2(X[v][u],Y[v][u])
radius[v][u] = math.sqrt(X[v][u]**2 + Y[v][u]**2)
print angle
print radius
What am I missing here?