Skip to content

Commit 574ff4b

Browse files
authored
Plot velocity Streamlines on the equator
The script reads MagIC graphic file data, transforms the r-phi velocity component in the equator plane to x-y components and plots the streamlines on a regular x-y grid.
1 parent bfc83da commit 574ff4b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Plot_StreamlinesOnEquator.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from magic import *
2+
from scipy.integrate import trapz
3+
from scipy.interpolate import griddata
4+
import pylab as P
5+
import numpy as N
6+
import os
7+
8+
cm = 'RdYlBu_r'
9+
lev = 100
10+
11+
gr = MagicGraph()
12+
13+
#circular grid
14+
phi = N.linspace(0., 2.*N.pi, gr.nphi-1)
15+
rr, pphi = N.meshgrid(gr.radius, phi)
16+
xx = rr * N.cos(pphi)
17+
yy = rr * N.sin(pphi)
18+
19+
eq_vx = gr.vr[:,gr.ntheta/2,:]*N.cos(pphi) - gr.vphi[:,gr.ntheta/2,:]*N.sin(pphi)
20+
eq_vy = gr.vr[:,gr.ntheta/2,:]*N.sin(pphi) + gr.vphi[:,gr.ntheta/2,:]*N.cos(pphi)
21+
22+
#regular grid
23+
rec_x = N.linspace(-gr.radius[0], gr.radius[0], 1000)
24+
rec_y = rec_x
25+
26+
xx2, yy2 = N.meshgrid(rec_x, rec_y)
27+
28+
regular_vx = griddata((xx.ravel(), yy.ravel()), eq_vx.ravel(), (xx2, yy2), method='nearest')
29+
regular_vy = griddata((xx.ravel(), yy.ravel()), eq_vy.ravel(), (xx2, yy2), method='nearest')
30+
31+
32+
fig2 = P.figure(figsize=(7,6))
33+
ax2 = fig2.add_axes([0.05, 0.05, 0.9, 0.9])
34+
vmax2 = 2*N.std(regular_vy)
35+
vmin2 = -vmax2
36+
print vmin2
37+
cs2 = N.linspace(vmin2, vmax2, lev)
38+
39+
ax2.contourf(xx, yy, gr.vphi[:,gr.ntheta/2,:], cs2, cmap='seismic', extend='both')
40+
41+
im = ax2.streamplot(xx2, yy2, regular_vx, regular_vy, density=[8, 8])
42+
43+
44+
#ax1.axis('off')
45+
46+
P.show()
47+
48+
#fig.savefig('e6_NSD_2e9.png', dpi=100)
49+

0 commit comments

Comments
 (0)