title: Calculating velocity component using polar coordinates - Python
body: <p>In the code below I have calculated the rotation velocity as a function of radius (V_r) for a cartesian grid of xy coordinates, converting the xy coordinates to the polar coordinate r.</p>
  
  <p>I then calculate the polar coordinate phi by taking the arctan(y/x) and from this calculate the V_r component in y using cos(phi) * V_r = V_y:</p>
  
  <pre><code>res = 100
  
  x = np.linspace(-1.2,1.2,res)
  y = np.linspace(-1.2,1.2,res)
  
  r = np.sqrt(x**2 + y**2)
  
  phi = np.arctan2(y, x)
  cosphi = abs(np.cos(phi))
  
  
  
  # Velocity Const.
  V0 = 200.
  # Constants for scaling r
  rpe = 0.164 
  alpha = 0.002
  
  
  V_r = V0 * (1 - np.exp(-r/rpe)) * (1 + (alpha * r / rpe))
  
  V_los = V_r * abs(np.cos(phi))
  
  plt.figure()
  plt.plot(r, V_los)
  </code></pre>
  
  <p>There is no need to actually create arrays x and y, converting to r and phi. I know I can simply input the polar coordinates.</p>
  
  <p>However I am struggling to achieve the same result whereby at phi = 0 (i.e. cos(phi)=1) the V_r = V_y, or at cos(phi) = 0 thus V_y = 0.</p>
  
  <p>How can I input the arrays r and phi to achieve the same result?</p>