Modifying 'cos' to get the angle beween v fluctuations and the magnetic field
This commit is contained in:
+1
-1
@@ -1091,7 +1091,7 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
self,
|
||||
partial(self._plot_hist, "cos_pdf"),
|
||||
"cos-PDF",
|
||||
dependencies=["cos_pdf"],
|
||||
dependencies=["cos_pdf", "mwa_speed"],
|
||||
),
|
||||
"avg_coldens_pdf": PlotRule(
|
||||
self,
|
||||
|
||||
+17
-10
@@ -8,14 +8,6 @@ vol_func = lambda dset: dset["dx"] ** 3 # Volume function
|
||||
getter_T = lambda dset: dset["P"] / dset["rho"] # Temperature
|
||||
|
||||
|
||||
def getter_abs_cos_vB(dset):
|
||||
B_norm = np.sqrt(np.sum(dset["Br"] ** 2, axis=1))
|
||||
v_norm = np.sqrt(np.sum(dset["vel"] ** 2, axis=1))
|
||||
# Compute the dot product in each cell
|
||||
dot_prod = np.einsum("ij,ij->i", dset["vel"], dset["Br"])
|
||||
return np.abs(dot_prod) / (v_norm * B_norm)
|
||||
|
||||
|
||||
def getter_B_int(dset):
|
||||
B_norm = np.sqrt(np.sum(dset["Br"] ** 2, axis=1))
|
||||
return B_norm
|
||||
@@ -341,6 +333,20 @@ class PostProcessor(HDF5Container):
|
||||
self.unload_cells()
|
||||
return ({"rho": centers, "B": B_mean}, {"logbins": logbins})
|
||||
|
||||
def cos_vfluct_B(self):
|
||||
|
||||
mean_speed = self.save.get_node("/globals/mwa_speed").read()
|
||||
|
||||
def getter_cos_vfluct_B(dset):
|
||||
vel_fluct = dset["vel"] - mean_speed
|
||||
B_norm = np.sqrt(np.sum(dset["Br"] ** 2, axis=1))
|
||||
v_norm = np.sqrt(np.sum(vel_fluct ** 2, axis=1))
|
||||
# Compute the dot product in each cell
|
||||
dot_prod = np.einsum("ij,ij->i", vel_fluct, dset["Br"])
|
||||
return np.abs(dot_prod) / (v_norm * B_norm)
|
||||
|
||||
return self._vol_pdf(getter_cos_vfluct_B)
|
||||
|
||||
def _mwa_sigma(self, axes=["x", "y", "z"]):
|
||||
mw_speed = self.save.get_node("/globals/mwa_speed").read()
|
||||
|
||||
@@ -817,9 +823,10 @@ class PostProcessor(HDF5Container):
|
||||
),
|
||||
"cos_pdf": Rule(
|
||||
self,
|
||||
partial(self._vol_pdf, getter_abs_cos_vB, logbins=False),
|
||||
"Global cos-PDF",
|
||||
partial(self.cos_vfluct_B),
|
||||
"Global cos fluctuation-PDF",
|
||||
"/hist",
|
||||
dependencies=["mwa_speed"],
|
||||
unit=cst.none,
|
||||
),
|
||||
"Brho": Rule(
|
||||
|
||||
Reference in New Issue
Block a user