import numpy as np
import matplotlib.pyplot as plt

Lx=60.0
Ly=30.0
X=np.linspace(0,1535,1536)
Y=np.linspace(0,767,768)
x=X/1536.0 * Lx -30
y=Y/768.0 * Ly -15

data_B=[],[],[]
file_B='B_cycle12000.vtk'
f_B=open(file_B)
lines_B=f_B.readlines()
f_B.close()
    
for line_B in lines_B[9:]:
    for i in enumerate(line_B.split()):
        data_B[i[0]].append(float(i[1]))
Bx_total,By_total,Bz_total=data_B
Bx=np.array(Bx_total).reshape(768,1536)
By=np.array(By_total).reshape(768,1536)
Bz=np.array(Bz_total).reshape(768,1536)

fig=plt.figure(figsize=[10,8])

ax=fig.add_subplot(111)
ax.set_ylabel('Y/di',fontsize=18)
ax.set_xlabel('X/di',fontsize=18)
picture=ax.contourf(x,y,By)
strmline=ax.streamplot(x,y,Bx,By,color=(0,0,0,1.0),density=0.8,linewidth=0.3,arrowstyle='-')

fig.savefig('DF_magnetic_filed.jpg')




