[plotter] add particle scatter overlay

This commit is contained in:
Noe Brucy
2021-01-19 10:08:42 +01:00
parent 3ec31b7fd0
commit 2c1c690ba8
2 changed files with 32 additions and 0 deletions
+27
View File
@@ -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()