[plotter] add particle scatter overlay
This commit is contained in:
+27
@@ -689,6 +689,32 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
def _overlay_particles(self, ax_los, im_extent, **kwargs):
|
||||
"""
|
||||
Add an overlay with particles data
|
||||
"""
|
||||
|
||||
# Open particle HDF5 file
|
||||
filename = self.save.get_node("/hdf5/particles").read()
|
||||
hdf5_parts = tables.open(filename, "r")
|
||||
part_pos = hdf5_parts.get_node("/data/pos").read()
|
||||
|
||||
# index of the horizontal axis
|
||||
ih = self._ax_nb[self._axes_h[ax_los]]
|
||||
# index of the vertical axis
|
||||
iv = self._ax_nb[self._axes_v[ax_los]]
|
||||
|
||||
# horizontal coordinates
|
||||
part_h = part_pos[:, ih]
|
||||
part_v = part_pos[:, iv]
|
||||
|
||||
# Renormalize
|
||||
part_h = im_extent[0] + (im_extent[1] - im_extent[0]) * part_h
|
||||
part_v = im_extent[2] + (im_extent[3] - im_extent[2]) * part_v
|
||||
|
||||
# Scatter plot
|
||||
plt.scatter(part_h, part_v)
|
||||
|
||||
def _overlay_speed(
|
||||
self, ax_los, im_extent, unit=U.km_s, unit_coeff=1.0, key_v=None, **kwargs
|
||||
):
|
||||
@@ -1739,6 +1765,7 @@ class Plotter(Aggregator, BaseProcessor):
|
||||
"speed": self._overlay_speed,
|
||||
"levels": self._overlay_levels,
|
||||
"contour": self._overlay_contour,
|
||||
"particles": self._overlay_particles,
|
||||
}
|
||||
|
||||
super(Plotter, self).def_rules()
|
||||
|
||||
@@ -213,6 +213,10 @@ class PostProcessor(HDF5Container):
|
||||
self.path_out + "/cells_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.parts_filename = (
|
||||
self.path_out + "/parts_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
|
||||
self.pspec_filename = (
|
||||
self.path_out + "/pspec_" + tag_name + format(num, "05") + ".h5"
|
||||
)
|
||||
@@ -1160,6 +1164,7 @@ class PostProcessor(HDF5Container):
|
||||
"""Ensure particles are written in the hdf5 file"""
|
||||
self.load_parts()
|
||||
self.unload_parts()
|
||||
return self.parts_filename
|
||||
|
||||
def _filaments(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user