Skip to content

Commit 76a78d5

Browse files
authored
Script for making frames for movie
Makes movie frames of velocity and magnetic field plotted on orthographic projection on spherical surfaces (Basemap)
1 parent 7e17d56 commit 76a78d5

File tree

1 file changed

+128
-0
lines changed

1 file changed

+128
-0
lines changed

Mov_plot_vel_mag_frames.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
from __future__ import division
2+
import numpy as N
3+
import pylab as P
4+
from mpl_toolkits.basemap import Basemap
5+
from magic import *
6+
from matplotlib.colors import LinearSegmentedColormap
7+
import matplotlib.pyplot as plt
8+
9+
#------------Custom colormap------------------
10+
cdict1 = {'red': ((0.0, 0.0, 0.75),
11+
(1/8, 0.5, 0.5),
12+
(2/8, 0.0, 0.0),
13+
(3/8, 0.0, 0.0),
14+
(4/8, 0.0, 0.0),
15+
#
16+
(5/8, 0.5, 0.5),
17+
(6/8, 1.0, 1.0),
18+
(7/8, 1.0, 1.0),
19+
(8/8, 1.0, 1.0)),
20+
21+
'green': ((0.0, 0.0, 1.0),
22+
(1/8, 1.0, 1.0),
23+
(2/8, 0.5, 0.5),
24+
(3/8, 0.0, 0.0),
25+
(4/8, 0.0, 0.0),
26+
#
27+
(5/8, 0.0, 0.0),
28+
(6/8, 0.5, 0.5),
29+
(7/8, 1.0, 1.0),
30+
(8/8, 1.0, 1.0)),
31+
32+
'blue': ((0.0, 0.0, 1.0),
33+
(1/8, 1.0, 1.0),
34+
(2/8, 1.0, 1.0),
35+
(3/8, 0.5, 0.5),
36+
(4/8, 0.0, 0.0),
37+
#
38+
(5/8, 0.0, 0.0),
39+
(6/8, 0.0, 0.0),
40+
(7/8, 0.5, 0.5),
41+
(8/8, 0.75, 1.0)),
42+
}
43+
hot_ice = LinearSegmentedColormap('hot_ice', cdict1)
44+
plt.register_cmap(cmap=hot_ice)
45+
46+
47+
48+
mov_frames_mag = movie.Movie(file="Br_R=C6_mov.tag_zzzzl", iplot=False)
49+
mov_frames_vel = movie.Movie(file="Vr_R=C1_mov.tag_zzzzl", iplot=False)
50+
51+
52+
53+
for i in range(0,100):
54+
data= mov_frames_vel.data[i,...]
55+
data= N.clip(data,-1500, 1500)
56+
cmap = 'bwr'
57+
58+
rprof = data
59+
lons = N.linspace(-180, 180, data.shape[0])
60+
lats = N.linspace(-90, 90, data.shape[1])
61+
62+
fig = P.figure(figsize=(10,10))
63+
64+
#-------------------------------------------------------------------
65+
ax1 = fig.add_axes([0.01, 0.01, 0.47, 0.47])
66+
map = Basemap(projection='ortho',lat_0=-50,lon_0=100,resolution=None)
67+
new_dat = map.transform_scalar(rprof.T, lons, lats,
68+
data.shape[0], data.shape[1], masked=True)
69+
im1 = map.imshow(new_dat, cmap=cmap)
70+
ax1.text(0.15, 0.1, 'South', color='w', transform=ax1.transAxes, ha='right')
71+
#para = map.drawparallels([-84.29,0], color='k', dashes=[200,1], linewidth=2)
72+
#del ax1.lines[2]
73+
map.drawmeridians(N.arange(0,360,60), color='k', dashes=[20,10], latmax=90)
74+
map.drawparallels([-60, -30, 30, 60], color='k', dashes=[20,10], latmax=90)
75+
map.drawmapboundary()
76+
#cbar = map.colorbar(im,location='top',pad="7%", extend='both')
77+
#-------------------------------------------------------------------
78+
ax2 = fig.add_axes([0.01, 0.5, 0.47, 0.47])
79+
map = Basemap(projection='ortho',lat_0=50,lon_0=100,resolution=None)
80+
new_dat = map.transform_scalar(rprof.T, lons, lats,
81+
data.shape[0], data.shape[1], masked=True)
82+
im2 = map.imshow(new_dat, cmap=cmap)
83+
ax2.text(0.69, 1.02, 'Radial velocity', color='w', transform=ax2.transAxes, ha='right', fontsize=18)
84+
ax2.text(0.15, 0.9, 'North', color='w', transform=ax2.transAxes, ha='right')
85+
ax2.text(0.15, 0.04, r'$\pm 1500$', color='w', transform=ax2.transAxes, ha='right', fontsize=16)
86+
ax2.text(0.17, 0., '(Reyn. Num.)', color='w', transform=ax2.transAxes, ha='right', fontsize=10)
87+
map.drawmeridians(N.arange(0,360,60), color='k', dashes=[20,10], latmax=90)
88+
map.drawparallels([-60, -30, 30, 60], color='k', dashes=[20,10], latmax=90)
89+
map.drawmapboundary()
90+
#-------------------------------------------------------------------
91+
#----------------------------magnetic-------------------------------
92+
data= mov_frames_mag.data[i,...]*2300/5.97
93+
data= N.clip(data,-10000, 10000)
94+
cmap = plt.get_cmap('hot_ice')
95+
96+
rprof = data#brsurf
97+
98+
ax3 = fig.add_axes([0.5, 0.01, 0.47, 0.47])
99+
map = Basemap(projection='ortho',lat_0=-50,lon_0=100,resolution=None)
100+
new_dat = map.transform_scalar(rprof.T, lons, lats,
101+
data.shape[0], data.shape[1], masked=True)
102+
im3 = map.imshow(new_dat, cmap=cmap)
103+
104+
map.drawmeridians(N.arange(0,360,60), color='w', dashes=[20,10], latmax=90)
105+
map.drawparallels([-60, -30, 30, 60], color='w', dashes=[20,10], latmax=90)
106+
map.drawmapboundary()
107+
#-------------------------------------------------------------------
108+
ax4 = fig.add_axes([0.5, 0.5, 0.47, 0.47])
109+
map = Basemap(projection='ortho',lat_0=50,lon_0=100,resolution=None)
110+
new_dat = map.transform_scalar(rprof.T, lons, lats,
111+
data.shape[0], data.shape[1], masked=True)
112+
im4 = map.imshow(new_dat, cmap=cmap)
113+
ax4.text(0.77, 1.02, 'Radial magnetic field', color='w', transform=ax4.transAxes, ha='right', fontsize=18)
114+
ax4.text(1, 0, r'$\pm 10\,kG$', color='w', transform=ax4.transAxes, ha='right', fontsize=16)
115+
map.drawmeridians(N.arange(0,360,60), color='w', dashes=[20,10], latmax=90)
116+
map.drawparallels([-60, -30, 30, 60], color='w', dashes=[20,10], latmax=90)
117+
map.drawmapboundary()
118+
#-------------------------------------------------------------------
119+
120+
121+
filename = 'movie/img%05d.png' % i
122+
fig.savefig(filename, dpi=100, facecolor='0.1')
123+
im1.lines = []
124+
im2.lines = []
125+
im3.lines = []
126+
im4.lines = []
127+
print 'Frame',i+1,'of',mov_frames_vel.data.shape[0],'is Done.'
128+

0 commit comments

Comments
 (0)