Add B streamline plot

This commit is contained in:
Noe Brucy
2020-06-15 14:23:27 +02:00
committed by Noe Brucy
parent d4e1302515
commit 0cc77d69af
2 changed files with 76 additions and 12 deletions
+38
View File
@@ -521,6 +521,32 @@ class Plotter(Aggregator, BaseProcessor):
coordinates="figure",
)
def _overlay_B(self, ax_los):
ax_h = self._axes_h[ax_los]
ax_v = self._axes_v[ax_los]
dmap_Bh_node = self.save.get_node("/maps/B_h_{}".format(ax_los))
dmap_Bh = dmap_Bh_node.read()
dmap_Bv = self.save.get_node("/maps/B_v_{}".format(ax_los)).read()
vel_red = self.pp_params.plot.vel_red
radius = self.save.root.maps._v_attrs.radius
center = self.save.root.maps._v_attrs.center
lbox = self.save.root._v_attrs.lbox
map_Bh_red = dmap_Bh[::vel_red, ::vel_red] # take only a subset of velocities
map_Bv_red = dmap_Bv[::vel_red, ::vel_red]
nh = map_Bh_red.shape[0]
nv = map_Bv_red.shape[1]
vec_h = (
np.arange(nh) * 2.0 / nh * radius - radius + center[0] + radius / nh
) * lbox
vec_v = (
np.arange(nv) * 2.0 / nv * radius - radius + center[1] + radius / nv
) * lbox
hh, vv = np.meshgrid(vec_h, vec_v)
P.streamplot(hh, vv, map_Bh_red, map_Bv_red)
def _plot_radial(self, name, ax_los, label=None, xlog=False, ylog=False):
radial_bins = self.save.get_node("/radial/radial_bins_" + ax_los).read()
@@ -945,6 +971,18 @@ class Plotter(Aggregator, BaseProcessor):
"Density slice with speed overlay",
dependencies=["rho", "speed_h", "speed_v"],
),
"rho_B": PlotRule(
self,
partial(
self._plot_map,
"rho",
label=r"$\rho$",
unit=cst.Msun_pc3,
overlays=[self._overlay_B],
),
"Density slice with magnetic field overlay",
dependencies=["rho", "B_h", "B_v"],
),
"jeans_ratio": PlotRule(
self,
partial(