29import matplotlib.pyplot
as plt
32''' Testing routine for vector potential dipole
34run using "python vectorpotentialdipole_compare_with_data.py [ang]" where
35angle (given in degrees) is the polar angle of the line profile to plot.
36 Plots also Vlasiator BCH profiles at different times
41 line_phi = float(sys.argv[1])
45plt.switch_backend(
'Agg')
47outfilename =
"./vecpotdip_compare_"+str(int(line_phi))+
".png"
49inputLocation=
"/turso/group/spacephysics/vlasiator/data/L0/2D/BCH/bulk/"
50times = [0,10,50,100,200,500]
51colors = [
'r',
'g',
'b',
'magenta',
'k']
52timefulls = [str(time).rjust(7,
'0')
for time
in times]
53file_names = [inputLocation+
"bulk."+timefull+
".vlsv" for timefull
in timefulls]
56for i
in range(len(times)):
57 vlsvobj.append(pt.vlsvfile.VlsvReader(file_name=file_names[i]))
63line_theta = 0. * math.pi/180.
64line_phi = line_phi * math.pi/180.
65line_start = np.array([0,0,0])
79fig.set_size_inches(20,30)
81for i
in range(nsubplots):
82 fig.add_subplot(nsubplots,1,i+1)
85radii = np.arange(0.1,45,step)*RE
89fig.suptitle(
r"Profiles with $\theta="+str(int(line_theta*180./math.pi))+
"$, $\phi="+str(int(line_phi*180./math.pi))+
"$ starting from ("+str(line_start[0])+
","+str(line_start[1])+
","+str(line_start[2])+
") [RE] with dipole tilt $\Phi="+str(int(tilt_angle_phi*180./math.pi))+
"$, $\Theta="+str(int(tilt_angle_theta*180./math.pi))+
"$", fontsize=fontsize)
91xv = line_start[0]*RE + radii*np.sin(line_phi)*np.cos(line_theta)
92yv = line_start[1]*RE + radii*np.sin(line_phi)*np.sin(line_theta)
93zv = line_start[2]*RE + radii*np.cos(line_phi)
102 B1[j,k] = dip.get(xv[j],yv[j],zv[j],0,k,0)
109coords = [
'x',
'y',
'z']
111for k
in range(nsubplots):
113 print(
"component "+coords[k])
114 ax.plot(radiiRE, B1[:,k], c=colors[-1], linestyle=
'-', linewidth=linewidth, label=
'vectorpot B'+coords[k], zorder=-10)
120 for i
in range(len(times)):
122 print(
'time t='+str(int(times[i]*0.5))+
's')
123 res = pt.calculations.cut_through_step(vf, [xv[0],0,zv[0]], [xv[-1],0,zv[-1]])
125 pr_dist = res[1].data
126 pr_coords = res[2].data
127 pr_Re = np.array(pr_dist)/RE
128 pr_B = vf.read_variable(
"B", operator=coords[k],cellids=cut)
130 ax.plot(pr_Re, np.array(pr_B), linestyle=
'-', linewidth=linewidth, label=
'vlsv t='+str(int(times[i]*0.5))+
's',zorder=i)
132 ax.set_xlabel(
r"$r$ [$r_\mathrm{E}$]", fontsize=fontsize)
135 ax.set_yscale(
'symlog', linthreshy=linthresh)
136 for item
in ax.get_xticklabels():
137 item.set_fontsize(fontsize)
138 for item
in ax.get_yticklabels():
139 item.set_fontsize(fontsize)
141 ylims = np.array(ax.get_ylim())
148 handles, labels = ax.get_legend_handles_labels()
149 ax.legend(handles, labels, fontsize=fontsize)
151fig.savefig(outfilename)